Ignore:
Timestamp:
Sep 7, 2011, 7:17:07 PM (9 years ago)
Author:
sam
Message:

test: replace CppUnit with our LolUnit test suite.

CppUnit is really too large for our needs, would require to be precompiled
for many platforms, in all combinations of debug and release modes, with
additional variants for libstdc++ versions. We replace it with our own
lightweight implementation, LolUnit. Good riddance.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/test/trig.cpp

    r911 r912  
    1313#endif
    1414
    15 #include <cppunit/extensions/HelperMacros.h>
    16 #include <cppunit/TestCaller.h>
    17 #include <cppunit/TestCase.h>
    18 #include <cppunit/TestSuite.h>
    19 
    2015#include <cmath>
    2116
    2217#include "core.h"
     18#include "lol/unit.h"
    2319
    2420namespace lol
    2521{
    2622
    27 class TrigTest : public CppUnit::TestCase
     23LOLUNIT_FIXTURE(TrigTest)
    2824{
    29     CPPUNIT_TEST_SUITE(TrigTest);
    30     CPPUNIT_TEST(test_sin);
    31     CPPUNIT_TEST_SUITE_END();
    32 
    3325public:
    34     TrigTest() : CppUnit::TestCase("Trigonometry Test") {}
    35 
    3626    void setUp() {}
    37 
    3827    void tearDown() {}
    3928
    40     void test_sin()
     29    LOLUNIT_TEST(test_sin)
    4130    {
    4231        for (int i = -10000; i < 10000; i++)
     
    4938#endif
    5039            double b = lol_sin(f);
    51             CPPUNIT_ASSERT_DOUBLES_EQUAL(a, b, fabs(f) * 1e-11);
     40            LOLUNIT_ASSERT_DOUBLES_EQUAL(a, b, fabs(f) * 1e-11);
    5241        }
    5342
     
    6150#endif
    6251            double b = lol_sin(f);
    63             CPPUNIT_ASSERT_DOUBLES_EQUAL(a, b, fabs(f) * 1e-11);
     52            LOLUNIT_ASSERT_DOUBLES_EQUAL(a, b, fabs(f) * 1e-11);
    6453        }
     54    }
    6555
     56    LOLUNIT_TEST(test_cos)
     57    {
    6658        for (int i = -10000; i < 10000; i++)
    6759        {
     
    7365#endif
    7466            double b = lol_cos(f);
    75             CPPUNIT_ASSERT_DOUBLES_EQUAL(a, b, fabs(f) * 1e-11);
     67            LOLUNIT_ASSERT_DOUBLES_EQUAL(a, b, fabs(f) * 1e-11);
    7668        }
    7769
     
    8577#endif
    8678            double b = lol_cos(f);
    87             CPPUNIT_ASSERT_DOUBLES_EQUAL(a, b, fabs(f) * 1e-11);
     79            LOLUNIT_ASSERT_DOUBLES_EQUAL(a, b, fabs(f) * 1e-11);
    8880        }
     81    }
    8982
     83    LOLUNIT_TEST(test_sincos)
     84    {
    9085        for (int i = -10000; i < 10000; i++)
    9186        {
     
    10095            double b1, b2;
    10196            lol_sincos(f, &b1, &b2);
    102             CPPUNIT_ASSERT_DOUBLES_EQUAL(a1, b1, fabs(f) * 1e-11);
    103             CPPUNIT_ASSERT_DOUBLES_EQUAL(a2, b2, fabs(f) * 1e-11);
     97            LOLUNIT_ASSERT_DOUBLES_EQUAL(a1, b1, fabs(f) * 1e-11);
     98            LOLUNIT_ASSERT_DOUBLES_EQUAL(a2, b2, fabs(f) * 1e-11);
    10499        }
    105100
     
    116111            double b1, b2;
    117112            lol_sincos(f, &b1, &b2);
    118             CPPUNIT_ASSERT_DOUBLES_EQUAL(a1, b1, fabs(f) * 1e-11);
    119             CPPUNIT_ASSERT_DOUBLES_EQUAL(a2, b2, fabs(f) * 1e-11);
     113            LOLUNIT_ASSERT_DOUBLES_EQUAL(a1, b1, fabs(f) * 1e-11);
     114            LOLUNIT_ASSERT_DOUBLES_EQUAL(a2, b2, fabs(f) * 1e-11);
    120115        }
     116    }
    121117
     118    LOLUNIT_TEST(test_tan)
     119    {
    122120        for (int i = -100000; i < 100000; i++)
    123121        {
     
    130128            double b = lol_tan(f);
    131129            if (fabs(a) > 1e4)
    132                 CPPUNIT_ASSERT_DOUBLES_EQUAL(a, b, fabs(a) * fabs(a) * 1e-11);
     130                LOLUNIT_ASSERT_DOUBLES_EQUAL(a, b, fabs(a) * fabs(a) * 1e-11);
    133131            else if (fabs(a) > 1.0)
    134                 CPPUNIT_ASSERT_DOUBLES_EQUAL(a, b, fabs(a) * 1e-11);
     132                LOLUNIT_ASSERT_DOUBLES_EQUAL(a, b, fabs(a) * 1e-11);
    135133            else
    136                 CPPUNIT_ASSERT_DOUBLES_EQUAL(a, b, fabs(f) * 1e-11);
     134                LOLUNIT_ASSERT_DOUBLES_EQUAL(a, b, fabs(f) * 1e-11);
    137135        }
    138136
     
    147145            double b = lol_tan(f);
    148146            if (fabs(a) > 1e4)
    149                 CPPUNIT_ASSERT_DOUBLES_EQUAL(a, b, fabs(a) * fabs(a) * 1e-11);
     147                LOLUNIT_ASSERT_DOUBLES_EQUAL(a, b, fabs(a) * fabs(a) * 1e-11);
    150148            else if (fabs(a) > 1.0)
    151                 CPPUNIT_ASSERT_DOUBLES_EQUAL(a, b, fabs(a) * 1e-11);
     149                LOLUNIT_ASSERT_DOUBLES_EQUAL(a, b, fabs(a) * 1e-11);
    152150            else
    153                 CPPUNIT_ASSERT_DOUBLES_EQUAL(a, b, fabs(f) * 1e-11);
     151                LOLUNIT_ASSERT_DOUBLES_EQUAL(a, b, fabs(f) * 1e-11);
    154152        }
    155153    }
    156154};
    157155
    158 CPPUNIT_TEST_SUITE_REGISTRATION(TrigTest);
     156LOLUNIT_SETUP_FIXTURE(TrigTest);
    159157
    160158} /* namespace lol */
Note: See TracChangeset for help on using the changeset viewer.