// -----------
// CppUnit.c++
// -----------

/*
/usr/local/lib/libcppunit.a
% g++ -ansi -pedantic -lcppunit -ldl -Wall CppUnit.c++ -o CppUnit.app
% CppUnit.app
*/

#include <iostream> // cout, endl

#include "cppunit/extensions/HelperMacros.h" // CPPUNIT_TEST, CPPUNIT_TEST_SUITE, CPPUNIT_TEST_SUITE_END
#include "cppunit/TestFixture.h"             // TestFixture
#include "cppunit/TextTestRunner.h"          // TextTestRunner

// ---
// Foo
// ---

struct Foo : CppUnit::TestFixture {
    void bar1 () {
        CPPUNIT_ASSERT(true);}

    void bar2 () {
        CPPUNIT_ASSERT(false);}

    void bar3 () {
        CPPUNIT_ASSERT(true);}

    void bar4 () {
        CPPUNIT_ASSERT(false);}

    CPPUNIT_TEST_SUITE(Foo);
    CPPUNIT_TEST(bar1);
    CPPUNIT_TEST(bar2);
    CPPUNIT_TEST(bar3);
    CPPUNIT_TEST(bar4);
    CPPUNIT_TEST_SUITE_END();};

// ----
// main
// ----

int main () {
    using namespace std;
    cout << "CppUnit.c++" << endl;

    CppUnit::TextTestRunner tr;
    tr.addTest(Foo::suite());
    tr.run();

    cout << "Done." << endl;
    return 0;}

/*
CppUnit.c++
..F..F


!!!FAILURES!!!
Test Results:
Run:  4   Failures: 2   Errors: 0


1) test: Foo::bar2 (F) line: 29 CppUnit.c++
assertion failed
- Expression: false


2) test: Foo::bar4 (F) line: 35 CppUnit.c++
assertion failed
- Expression: false


Done.
*/


syntax highlighted by Code2HTML, v. 0.9.1