TheDailyWTF that C++ could run code before main()
by clever use of static variables, and used this to auto-register tests.
fork()
, and communicated test results back to the parent using a simple length-prefixed packet format called netstrings. At the time I had no idea who djb was – netstrings.txt was just some useful thing that another student had found.The original name was simply "UnitTests" – I renamed it after realizing that CppUnit abbreviated to "CU", the chemical name for copper.
Use the standard UNIX install stanza ./configure && make && make install
to install Copper. Optionally, you may run the included self-tests with make check
. Copper does not have any dependencies aside from a reasonably capable C++ compiler. If present, Copper will take advantage of advanced features such as RTTI and std::stringstream
.
Copper is installed as a static library and set of header files; use $(pkg-config --cflags --libs copper)
when compiling tests. For example, after installing Copper, you may build and run the included sample tests with:
$ g++ -o samples tests/sample_tests.cpp tests/main.cpp $(pkg-config --cflags --libs copper) $ ./samples FAILURE in tests/sample_tests.cpp:111: sample_suite.assertion_failure: equal("the answer", "42") "the answer" != "42" ERROR in tests/sample_tests.cpp: sample_suite.NULL_pointer_dereference: Segmentation fault ERROR in tests/sample_tests.cpp: sample_suite.division_by_zero: Floating point exception 10 tests passed 1 test failed 2 errors
The best compiler available to us was a horrible hacked-up fork of GCC 2.95 installed on the DEC Tru64 machine.
We could use modern GCC 4.1 at home, but your code had to work with whatever compiler the professor used.