A micro test runner, even smaller than the one at VisualCeePlusPlus, and just as coupled to the VC++ IDE. Part of MsWindowsResourceLint.

Use EditPage to avoid any Wikifications, and save this as ''test.h'':


  //  lite test rig

  //  WPL - the Whatever Public License. Have fun; don't sue

    #ifndef TEST_

    #   include <iostream>
    #   include <list>
    #   include <sstream>
    #   define WIN32_LEAN_AND_MEAN
    #   include <windows.h>


        class
    TestCase
    {
      public:
        typedef std::list<TestCase *> TestCases_t;
        TestCases_t static cases;
        
        TestCase()  {  cases.push_back(this);  }
        virtual void setUp() {}
        virtual void runCase() = 0;
        virtual void tearDown() {}
        static bool runTests();
        
      protected:
        static bool all_tests_passed;
    };


        inline bool
    TestCase::runTests()
    {
        TestCase::TestCases_t::iterator it(TestCase::cases.begin());
        
        for ( ;  it != TestCase::cases.end();  ++it )
            {
            TestCase & aCase = **it;
            aCase.setUp();
            aCase.runCase();
            aCase.tearDown();
            }
        return TestCase::all_tests_passed;
    }

    #define TEST_(suite, target)                    struct suite##_##target##_test:  public suite         { void runCase(); }                         a_##suite##_##target##_test;                void suite##_##target##_test::runCase()

    #define CPPUNIT_ASSERT_EQUAL(sample, result)                  if ((sample) != (result))  {  std::stringstream out;             out << __FILE__ << "(" << __LINE__ << ") : ";             out << #sample << "(" << (sample) << ") != ";             out << #result << "(" << (result) << ")";                 std::cout << out.str() << std::endl;                      OutputDebugString(out.str().c_str());                     OutputDebugString("\n");                                  all_tests_passed = false;                                 __asm { int 3 }  }

    #endif

----
CategoryLint