crpcut 1.9.2

The Compartmented Robust Posix C++ Unit Tester

  Add it to your Download Basket!

 Add it to your Watch List!


Rate it!

What's new in crpcut 1.9.2:

  • This version supports distributions with old versions of CMake.
Read full changelog
send us
an update
BSD License 
Bjorn Fahller
ROOT \ Programming \ Quality Assurance and Testing
1 crpcut Screenshot:
crpcut (pronounced "crap cut") is the Compartmented Robust Posix C++ Unit Tester. With crpcut it's easy to write tests that other unit-test frameworks cannot manage.

Introductory example:

An example testing parts of std::string:

 #include < crpcut.hpp >
 #include < string >

 struct apastr // fixture for mosts tests
 apastr() : s("apa") {}
 std::string s;

 std::string s;
 ASSERT_EQ(s.length(), 0);
 TEST(constr_from_char_array, apastr,
 ASSERT_EQ(s.length(), 3UL);
 TEST(at, apastr,
 ASSERT_EQ(, 'p');

 TEST(at_out_of_range, apastr,
 TEST(index_oper_out_of_range, apastr,

 int main(int argc, char *argv[])
 return crpcut::test_case_factory::run_test(argc, argv);

Similar tests benefits from being grouped into test-suites. Test-suites can depend on other test-suites, meaning that the contained tests will only run if all tests it depends on have completed successfully. Results can be validated using a number of ASSERT macros. Tests can use fixtures to express common contents. Tests can be expected to exit by exception, or die. Expectations that are not met are errors. Messages on stderr and stdout are gaught, and included in the result log.

Why crpcut

Most importantly, it must be easy to write tests. With crpcut, you focus on your test structure and test logic, not on the limits imposed by your test environment.

With crpcut, every test case runs in its own process and its own working directory. If a test case fails, the process terminates immediately, before it does further harm. This means that every test case starts from a clean slate, unaffected by other tests. This is the compartmentalization.

It also means that the test suite continues, even if a test crashes. You can set deadlines for test cases, and if the allowed time is seriously overdrawn, the test case process is killed. These two make up the robustness part.

You can define dependencies between test cases and between test suites, so that if a fundamental tests fails, the tests that are based on the fundamental functionality will not even be run.

The crpcut main process does not have any dynamic memory allocated at the time a test case process is started, so you can run crpcut using a memory test tool, such as valgrind, and if there is memory allocated when the test case process terminates, you can be assured that you have found a memory leak in your test.

If you have a multi-core CPU, it may be beneficial to run several test cases in parallel. crpcut allows that.

If there are files left in the test process' working directory after the test case process has terminated, the test case is considered failed. The working directory is left untouched by crpcut, for you to examine.

Last updated on April 8th, 2013

#unit tester #unit-test framework #C++ #unit #tester #framework

Add your review!