diff --git a/build-mingw b/build-mingw index 879d24bb..5e7e493a 100755 --- a/build-mingw +++ b/build-mingw @@ -10,11 +10,9 @@ set -e PATH="$PATH:./contrib/gtk-2.22.1/bin" M4PATH="$M4PATH:./contrib/gtk-2.22.1/share/aclocal" -M4PATH="$M4PATH:./contrib/cppunit-1.12.2/share/aclocal" export M4PATH # This looks necessary PKG_CONFIG_PATH="$PKG_CONFIG_PATH:`pwd`/contrib/gtkglarea-2.0.1/lib/pkgconfig" -PKG_CONFIG_PATH="$PKG_CONFIG_PATH:`pwd`/contrib/cppunit-1.12.2/lib/pkgconfig" export PKG_CONFIG_PATH # This looks necessary, too # SDL include path @@ -36,9 +34,6 @@ CPPFLAGS="$CPPFLAGS -I`pwd`/contrib/gtk-2.22.1/include/gdk-pixbuf-2.0" CPPFLAGS="$CPPFLAGS -I`pwd`/contrib/gtk-2.22.1/include/atk-1.0" CPPFLAGS="$CPPFLAGS -I`pwd`/contrib/gtkglarea-2.0.1/include" -# CppUnit include path -CPPFLAGS="$CPPFLAGS -I`pwd`/contrib/cppunit-1.12.2/include" - # SDL library path LDFLAGS="$LDFLAGS -L`pwd`/contrib/sdl-1.2.14/lib" LDFLAGS="$LDFLAGS -L`pwd`/contrib/sdl-image-1.2.10/lib" @@ -52,9 +47,6 @@ LDFLAGS="$LDFLAGS -L`pwd`/contrib/gtk-2.22.1/lib" LDFLAGS="$LDFLAGS -L`pwd`/contrib/gtk-2.22.1/bin" LDFLAGS="$LDFLAGS -L`pwd`/contrib/gtkglarea-2.0.1/lib" -# CppUnit library path -LDFLAGS="$LDFLAGS -L`pwd`/contrib/cppunit-1.12.2/lib" - # Prevent issues with GTK+ internals CPPFLAGS="$CPPFLAGS -mms-bitfields" diff --git a/build/bitten.xml b/build/bitten.xml index a5d85064..6bb7d7af 100644 --- a/build/bitten.xml +++ b/build/bitten.xml @@ -14,7 +14,6 @@ windows-i386) PATH="$''PATH:./contrib/gtk-2.22.1/bin"; M4PATH="$''M4PATH:./contrib/gtk-2.22.1/share/aclocal"; - M4PATH="$''M4PATH:./contrib/cppunit-1.12.2/share/aclocal"; PATH="$''PATH" M4PATH="$''M4PATH" ./bootstrap; ;; *) @@ -34,7 +33,6 @@ ;; windows-i386) PKG_CONFIG_PATH="$''PKG_CONFIG_PATH:$''PWD/contrib/gtkglarea-2.0.1/lib/pkgconfig"; - PKG_CONFIG_PATH="$''PKG_CONFIG_PATH:$''PWD/contrib/cppunit-1.12.2/lib/pkgconfig"; CPPFLAGS="$''CPPFLAGS -I$''PWD/contrib/sdl-1.2.14/include"; CPPFLAGS="$''CPPFLAGS -I$''PWD/contrib/sdl-image-1.2.10/include"; CPPFLAGS="$''CPPFLAGS -I$''PWD/contrib/sdl-mixer-1.2.11/include"; @@ -48,7 +46,6 @@ CPPFLAGS="$''CPPFLAGS -I$''PWD/contrib/gtk-2.22.1/include/gdk-pixbuf-2.0"; CPPFLAGS="$''CPPFLAGS -I$''PWD/contrib/gtk-2.22.1/include/atk-1.0"; CPPFLAGS="$''CPPFLAGS -I$''PWD/contrib/gtkglarea-2.0.1/include"; - CPPFLAGS="$''CPPFLAGS -I$''PWD/contrib/cppunit-1.12.2/include"; LDFLAGS="$''LDFLAGS -L$''PWD/contrib/sdl-1.2.14/lib"; LDFLAGS="$''LDFLAGS -L$''PWD/contrib/sdl-image-1.2.10/lib"; LDFLAGS="$''LDFLAGS -L$''PWD/contrib/sdl-mixer-1.2.11/lib"; @@ -56,7 +53,6 @@ LDFLAGS="$''LDFLAGS -L$''PWD/contrib/gtk-2.22.1/lib"; LDFLAGS="$''LDFLAGS -L$''PWD/contrib/gtk-2.22.1/bin"; LDFLAGS="$''LDFLAGS -L$''PWD/contrib/gtkglarea-2.0.1/lib"; - LDFLAGS="$''LDFLAGS -L$''PWD/contrib/cppunit-1.12.2/lib"; CPPFLAGS="$''CPPFLAGS -mms-bitfields"; LDFLAGS="$''LDFLAGS -static-libgcc -static-libstdc++"; GTK_LIBS="$''GTK_LIBS -lgtkgl-2.0 -lopengl32 -lglew32 -lgdi32"; diff --git a/configure.ac b/configure.ac index 02d28b81..5c85fccb 100644 --- a/configure.ac +++ b/configure.ac @@ -46,9 +46,6 @@ AC_ARG_ENABLE(release, AC_ARG_ENABLE(experimental, [ --enable-experimental experimental build (default no)]) -AC_ARG_ENABLE(cppunit, - [ --enable-cppunit use cppunit for unit tests (autodetected)]) - AC_CHECK_HEADERS(stdio.h stdarg.h inttypes.h endian.h stdint.h getopt.h fastmath.h) if test "${enable_debug}" = "yes"; then @@ -242,11 +239,6 @@ fi AM_CONDITIONAL(USE_GTKGL, test "${ac_cv_my_have_gtkgl}" != "no") -dnl Use cppunit for unit tests? -PKG_CHECK_MODULES(CPPUNIT, cppunit, [CPPUNIT="yes"], [CPPUNIT="no"]) -AM_CONDITIONAL(USE_CPPUNIT, test "$CPPUNIT" = "yes") - - dnl How to use the Lol Engine inside this tree LOL_CFLAGS="$LOL_CFLAGS -I \$(top_srcdir)/src" LOL_CFLAGS="$LOL_CFLAGS $SDL_CFLAGS $GL_CFLAGS $EGL_CFLAGS $LIBPNG_CFLAGS" diff --git a/src/Makefile.am b/src/Makefile.am index 60c21843..e4f7f4f0 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -12,6 +12,8 @@ liblol_a_SOURCES = \ worldentity.cpp worldentity.h gradient.cpp gradient.h half.cpp half.h \ platform.cpp platform.h sprite.cpp sprite.h trig.cpp trig.h \ \ + lol/unit.h \ + \ eglapp.cpp eglapp.h \ \ platform/sdl/sdlapp.cpp platform/sdl/sdlapp.h \ diff --git a/src/lol/unit.h b/src/lol/unit.h new file mode 100644 index 00000000..7c46f2c6 --- /dev/null +++ b/src/lol/unit.h @@ -0,0 +1,182 @@ +// +// Lol Engine +// +// Copyright: (c) 2010-2011 Sam Hocevar +// This program is free software; you can redistribute it and/or +// modify it under the terms of the Do What The Fuck You Want To +// Public License, Version 2, as published by Sam Hocevar. See +// http://sam.zoy.org/projects/COPYING.WTFPL for more details. +// + +// +// The Unit test framework +// ----------------------- +// + +#if !defined __LOL_UNIT_H__ +#define __LOL_UNIT_H__ + +#include +#include +#include + +namespace lol +{ + +using namespace std; + +class FixtureBase +{ + friend class TestRunner; + +public: + virtual void setUp(void) {}; + virtual void tearDown(void) {}; + +protected: + FixtureBase() : m_next(NULL), m_tests(0), m_fails(0) {} + virtual ~FixtureBase() {} + + /* The FixtureBase class keeps track of all instanciated children + * fixtures through this method. */ + static FixtureBase *GetOrSetTest(FixtureBase *set = NULL) + { + static FixtureBase *head = NULL, *tail = NULL; + if (set) + { + if (!head) + head = set; + if (tail) + tail->m_next = set; + tail = set; + } + return head; + } + + virtual int RunFixture() = 0; + + /* Prevent compiler complaints about unreachable code */ + static inline bool True() { return true; } + + FixtureBase *m_next; + int m_tests, m_fails; +}; + +template class Fixture : protected FixtureBase +{ +public: + typedef T FixtureClass; + + class TestCase + { + public: + void (FixtureClass::* m_fun)(); + char const *m_name; + TestCase *m_next; + + static void AddTestCase(TestCase *that, char const *name, + void (FixtureClass::*fun)()) + { + that->m_name = name; + that->m_fun = fun; + GetOrSetTestCase(that); + } + }; + + Fixture() + { + GetOrSetTest(this); + } + + /* Run all test cases in this fixture. */ + virtual int RunFixture() + { + for (TestCase *head = GetOrSetTestCase(); head; head = head->m_next) + { + (static_cast(this)->*head->m_fun)(); + std::cout << "."; + } + return 0; + } + + /* Each Fixture class specialisation keeps track of its instanciated + * test cases through this method. */ + static TestCase *GetOrSetTestCase(TestCase *set = NULL) + { + static TestCase *head = NULL, *tail = NULL; + if (set) + { + if (!head) head = set; + if (tail) tail->m_next = set; + tail = set; + } + return head; + } +}; + +class TestRunner +{ +public: + int Run() + { + int ret = 0; + for (FixtureBase *head = FixtureBase::GetOrSetTest(); head; head = head->m_next) + { + head->setUp(); + if (head->RunFixture()) + ret = 1; + head->tearDown(); + } + std::cout << std::endl; + return ret; + } +}; + +#define LOLUNIT_FIXTURE(FixtureName) \ + class FixtureName : public lol::Fixture + +#define LOLUNIT_TEST(TestCaseName) \ + class TestCase##TestCaseName : public TestCase \ + { \ + public: \ + TestCase##TestCaseName() \ + { \ + AddTestCase(this, #TestCaseName, \ + (void (FixtureClass::*)()) &FixtureClass::TestCaseName); \ + } \ + }; \ + TestCase##TestCaseName test_case_##TestCaseName; \ + void TestCaseName() + +#define LOLUNIT_SETUP_FIXTURE(ClassName) \ + ClassName ClassName##Test_Instance; + +#define LOLUNIT_ASSERT(cond) \ + do { if (True() && !(cond)) \ + { \ + std::cout << "FAIL! " #cond << std::endl; \ + return; \ + } } while(!True()) + +#define LOLUNIT_ASSERT_EQUAL(a, b) \ + do { if (True() && (a) != (b)) \ + { \ + std::cout << "FAIL! " #a " != " #b << std::endl; \ + std::cout << "expected: " << (a) << std::endl; \ + std::cout << "returned: " << (b) << std::endl; \ + return; \ + } } while(!True()) + +#define LOLUNIT_ASSERT_DOUBLES_EQUAL(a, b, t) \ + do { if (True() && fabs((a) - (b)) > fabs((t))) \ + { \ + std::cout << "FAIL! " #a " != " #b << std::endl; \ + std::cout << "expected: " << (a) << std::endl; \ + std::cout << "returned: " << (b) << std::endl; \ + return; \ + } } while(!True()) + +} /* namespace lol */ + +#endif // __LOL_UNIT_H__ + diff --git a/test/Makefile.am b/test/Makefile.am index 5c29de96..d6e03adb 100644 --- a/test/Makefile.am +++ b/test/Makefile.am @@ -1,10 +1,6 @@ AM_CPPFLAGS = -I$(top_srcdir)/src -if USE_CPPUNIT -cppunit_tests = lol-test -endif - bench: lol-bench$(EXEEXT) ./lol-bench$(EXEEXT) @@ -12,17 +8,16 @@ all-local: quad$(EXEEXT) lol-bench$(EXEEXT) test x$(MAKE_FSELF) = xno || make_fself quad$(EXEEXT) quad.self test x$(MAKE_FSELF) = xno || make_fself sandbox$(EXEEXT) sandbox.self test x$(MAKE_FSELF) = xno || make_fself lol-bench$(EXEEXT) lol-bench.self + test x$(MAKE_FSELF) = xno || make_fself lol-test$(EXEEXT) lol-test.self -CLEANFILES = quad.self sandbox lol-bench.self +CLEANFILES = quad.self sandbox lol-bench.self lol-test.self -noinst_PROGRAMS = quad sandbox lol-bench $(cppunit_tests) +noinst_PROGRAMS = quad sandbox lol-bench lol-test -TESTS = $(cppunit_tests) +TESTS = lol-test lol_test_SOURCES = lol-test.cpp matrix.cpp half.cpp trig.cpp -lol_test_CXXFLAGS = $(CPPUNIT_CFLAGS) lol_test_CPPFLAGS = @LOL_CFLAGS@ @PIPI_CFLAGS@ -lol_test_LDADD = $(CPPUNIT_LIBS) lol_test_LDFLAGS = $(top_builddir)/src/liblol.a @LOL_LIBS@ @PIPI_LIBS@ lol_test_DEPENDENCIES = $(top_builddir)/src/liblol.a diff --git a/test/half.cpp b/test/half.cpp index 886df578..2c07590b 100644 --- a/test/half.cpp +++ b/test/half.cpp @@ -12,14 +12,10 @@ # include "config.h" #endif -#include -#include -#include -#include - #include #include "core.h" +#include "lol/unit.h" /* Ensure isnan() is present even on systems that don't define it, or * when -ffast-math is being used. */ @@ -37,159 +33,139 @@ static inline int isnan(float f) namespace lol { -class HalfTest : public CppUnit::TestCase +LOLUNIT_FIXTURE(HalfTest) { - CPPUNIT_TEST_SUITE(HalfTest); - CPPUNIT_TEST(test_half_from_float); - CPPUNIT_TEST(test_half_makeaccurate); - CPPUNIT_TEST(test_half_makebits); - CPPUNIT_TEST(test_half_is_nan); - CPPUNIT_TEST(test_half_is_inf); - CPPUNIT_TEST(test_half_is_finite); - CPPUNIT_TEST(test_half_is_normal); - CPPUNIT_TEST(test_half_classify); - CPPUNIT_TEST(test_half_to_float); - CPPUNIT_TEST(test_half_to_int); - CPPUNIT_TEST(test_float_op_half); - CPPUNIT_TEST(test_half_op_float); - CPPUNIT_TEST_SUITE_END(); - public: - HalfTest() : CppUnit::TestCase("Matrix Test") {} - - void setUp() - { - } - + void setUp() {} void tearDown() {} - void test_half_from_float() + LOLUNIT_TEST(test_half_from_float) { for (size_t i = 0; i < sizeof(pairs) / sizeof(*pairs); i++) { half a = (half)pairs[i].f; uint16_t b = pairs[i].x; - CPPUNIT_ASSERT_EQUAL(a.bits, b); + LOLUNIT_ASSERT_EQUAL(a.bits, b); } } - void test_half_makeaccurate() + LOLUNIT_TEST(test_half_makeaccurate) { for (size_t i = 0; i < sizeof(pairs) / sizeof(*pairs); i++) { half a = half::makeaccurate(pairs[i].f); uint16_t b = pairs[i].x; - CPPUNIT_ASSERT_EQUAL(a.bits, b); + LOLUNIT_ASSERT_EQUAL(a.bits, b); } } - void test_half_makebits() + LOLUNIT_TEST(test_half_makebits) { for (unsigned int i = 0; i < 0x10000; i++) { half a = half::makebits(i); uint16_t b = i; - CPPUNIT_ASSERT_EQUAL(a.bits, b); + LOLUNIT_ASSERT_EQUAL(a.bits, b); } } - void test_half_is_nan() + LOLUNIT_TEST(test_half_is_nan) { - CPPUNIT_ASSERT(half::makebits(0x7c01).is_nan()); - CPPUNIT_ASSERT(half::makebits(0xfc01).is_nan()); - CPPUNIT_ASSERT(half::makebits(0x7e00).is_nan()); - CPPUNIT_ASSERT(half::makebits(0xfe00).is_nan()); - - CPPUNIT_ASSERT(!half::makebits(0x7c00).is_nan()); - CPPUNIT_ASSERT(!half::makebits(0xfc00).is_nan()); - - CPPUNIT_ASSERT(!half(0.0f).is_nan()); - CPPUNIT_ASSERT(!half(-0.0f).is_nan()); - CPPUNIT_ASSERT(!half(2.0f).is_nan()); - CPPUNIT_ASSERT(!half(-2.0f).is_nan()); + LOLUNIT_ASSERT(half::makebits(0x7c01).is_nan()); + LOLUNIT_ASSERT(half::makebits(0xfc01).is_nan()); + LOLUNIT_ASSERT(half::makebits(0x7e00).is_nan()); + LOLUNIT_ASSERT(half::makebits(0xfe00).is_nan()); + + LOLUNIT_ASSERT(!half::makebits(0x7c00).is_nan()); + LOLUNIT_ASSERT(!half::makebits(0xfc00).is_nan()); + + LOLUNIT_ASSERT(!half(0.0f).is_nan()); + LOLUNIT_ASSERT(!half(-0.0f).is_nan()); + LOLUNIT_ASSERT(!half(2.0f).is_nan()); + LOLUNIT_ASSERT(!half(-2.0f).is_nan()); } - void test_half_is_inf() + LOLUNIT_TEST(test_half_is_inf) { - CPPUNIT_ASSERT(half(65536.0f).is_inf()); - CPPUNIT_ASSERT(half(-65536.0f).is_inf()); + LOLUNIT_ASSERT(half(65536.0f).is_inf()); + LOLUNIT_ASSERT(half(-65536.0f).is_inf()); - CPPUNIT_ASSERT(!half(0.0f).is_inf()); - CPPUNIT_ASSERT(!half(-0.0f).is_inf()); - CPPUNIT_ASSERT(!half(65535.0f).is_inf()); - CPPUNIT_ASSERT(!half(-65535.0f).is_inf()); + LOLUNIT_ASSERT(!half(0.0f).is_inf()); + LOLUNIT_ASSERT(!half(-0.0f).is_inf()); + LOLUNIT_ASSERT(!half(65535.0f).is_inf()); + LOLUNIT_ASSERT(!half(-65535.0f).is_inf()); - CPPUNIT_ASSERT(half::makebits(0x7c00).is_inf()); - CPPUNIT_ASSERT(half::makebits(0xfc00).is_inf()); + LOLUNIT_ASSERT(half::makebits(0x7c00).is_inf()); + LOLUNIT_ASSERT(half::makebits(0xfc00).is_inf()); - CPPUNIT_ASSERT(!half::makebits(0x7e00).is_inf()); - CPPUNIT_ASSERT(!half::makebits(0xfe00).is_inf()); + LOLUNIT_ASSERT(!half::makebits(0x7e00).is_inf()); + LOLUNIT_ASSERT(!half::makebits(0xfe00).is_inf()); } - void test_half_is_finite() + LOLUNIT_TEST(test_half_is_finite) { - CPPUNIT_ASSERT(half(0.0f).is_finite()); - CPPUNIT_ASSERT(half(-0.0f).is_finite()); - CPPUNIT_ASSERT(half(65535.0f).is_finite()); - CPPUNIT_ASSERT(half(-65535.0f).is_finite()); + LOLUNIT_ASSERT(half(0.0f).is_finite()); + LOLUNIT_ASSERT(half(-0.0f).is_finite()); + LOLUNIT_ASSERT(half(65535.0f).is_finite()); + LOLUNIT_ASSERT(half(-65535.0f).is_finite()); - CPPUNIT_ASSERT(!half(65536.0f).is_finite()); - CPPUNIT_ASSERT(!half(-65536.0f).is_finite()); + LOLUNIT_ASSERT(!half(65536.0f).is_finite()); + LOLUNIT_ASSERT(!half(-65536.0f).is_finite()); - CPPUNIT_ASSERT(!half::makebits(0x7c00).is_finite()); - CPPUNIT_ASSERT(!half::makebits(0xfc00).is_finite()); + LOLUNIT_ASSERT(!half::makebits(0x7c00).is_finite()); + LOLUNIT_ASSERT(!half::makebits(0xfc00).is_finite()); - CPPUNIT_ASSERT(!half::makebits(0x7e00).is_finite()); - CPPUNIT_ASSERT(!half::makebits(0xfe00).is_finite()); + LOLUNIT_ASSERT(!half::makebits(0x7e00).is_finite()); + LOLUNIT_ASSERT(!half::makebits(0xfe00).is_finite()); } - void test_half_is_normal() + LOLUNIT_TEST(test_half_is_normal) { - CPPUNIT_ASSERT(half(0.0f).is_normal()); - CPPUNIT_ASSERT(half(-0.0f).is_normal()); - CPPUNIT_ASSERT(half(65535.0f).is_normal()); - CPPUNIT_ASSERT(half(-65535.0f).is_normal()); + LOLUNIT_ASSERT(half(0.0f).is_normal()); + LOLUNIT_ASSERT(half(-0.0f).is_normal()); + LOLUNIT_ASSERT(half(65535.0f).is_normal()); + LOLUNIT_ASSERT(half(-65535.0f).is_normal()); - CPPUNIT_ASSERT(!half(65536.0f).is_normal()); - CPPUNIT_ASSERT(!half(-65536.0f).is_normal()); + LOLUNIT_ASSERT(!half(65536.0f).is_normal()); + LOLUNIT_ASSERT(!half(-65536.0f).is_normal()); - CPPUNIT_ASSERT(!half::makebits(0x7c00).is_normal()); - CPPUNIT_ASSERT(!half::makebits(0xfc00).is_normal()); + LOLUNIT_ASSERT(!half::makebits(0x7c00).is_normal()); + LOLUNIT_ASSERT(!half::makebits(0xfc00).is_normal()); - CPPUNIT_ASSERT(!half::makebits(0x7e00).is_normal()); - CPPUNIT_ASSERT(!half::makebits(0xfe00).is_normal()); + LOLUNIT_ASSERT(!half::makebits(0x7e00).is_normal()); + LOLUNIT_ASSERT(!half::makebits(0xfe00).is_normal()); } - void test_half_classify() + LOLUNIT_TEST(test_half_classify) { for (uint32_t i = 0; i < 0x10000; i++) { half h = half::makebits(i); if (h.is_nan()) { - CPPUNIT_ASSERT(!h.is_inf()); - CPPUNIT_ASSERT(!h.is_normal()); - CPPUNIT_ASSERT(!h.is_finite()); + LOLUNIT_ASSERT(!h.is_inf()); + LOLUNIT_ASSERT(!h.is_normal()); + LOLUNIT_ASSERT(!h.is_finite()); } else if (h.is_inf()) { - CPPUNIT_ASSERT(!h.is_normal()); - CPPUNIT_ASSERT(!h.is_finite()); + LOLUNIT_ASSERT(!h.is_normal()); + LOLUNIT_ASSERT(!h.is_finite()); } else { - CPPUNIT_ASSERT(h.is_finite()); + LOLUNIT_ASSERT(h.is_finite()); } } } - void test_half_to_float() + LOLUNIT_TEST(test_half_to_float) { for (size_t i = 0; i < sizeof(pairs) / sizeof(*pairs); i++) { float a = (float)half::makebits(pairs[i].x); float b = pairs[i].f; - CPPUNIT_ASSERT_EQUAL(a, b); + LOLUNIT_ASSERT_EQUAL(a, b); } for (uint32_t i = 0; i < 0x10000; i++) @@ -199,73 +175,73 @@ public: half g = (half)f; if (h.is_nan()) { - CPPUNIT_ASSERT(isnan(f)); - CPPUNIT_ASSERT(g.is_nan()); + LOLUNIT_ASSERT(isnan(f)); + LOLUNIT_ASSERT(g.is_nan()); } else { - CPPUNIT_ASSERT(!isnan(f)); - CPPUNIT_ASSERT_EQUAL(g.bits, h.bits); + LOLUNIT_ASSERT(!isnan(f)); + LOLUNIT_ASSERT_EQUAL(g.bits, h.bits); } } } - void test_half_to_int() + LOLUNIT_TEST(test_half_to_int) { - CPPUNIT_ASSERT_EQUAL((int)(half)(0.0f), 0); - CPPUNIT_ASSERT_EQUAL((int)(half)(-0.0f), 0); - CPPUNIT_ASSERT_EQUAL((int)(half)(0.9f), 0); - CPPUNIT_ASSERT_EQUAL((int)(half)(-0.9f), 0); - CPPUNIT_ASSERT_EQUAL((int)(half)(1.0f), 1); - CPPUNIT_ASSERT_EQUAL((int)(half)(-1.0f), -1); - CPPUNIT_ASSERT_EQUAL((int)(half)(1.9f), 1); - CPPUNIT_ASSERT_EQUAL((int)(half)(-1.9f), -1); - CPPUNIT_ASSERT_EQUAL((int)(half)(65504.0f), 65504); - CPPUNIT_ASSERT_EQUAL((int)(half)(-65504.0f), -65504); + LOLUNIT_ASSERT_EQUAL((int)(half)(0.0f), 0); + LOLUNIT_ASSERT_EQUAL((int)(half)(-0.0f), 0); + LOLUNIT_ASSERT_EQUAL((int)(half)(0.9f), 0); + LOLUNIT_ASSERT_EQUAL((int)(half)(-0.9f), 0); + LOLUNIT_ASSERT_EQUAL((int)(half)(1.0f), 1); + LOLUNIT_ASSERT_EQUAL((int)(half)(-1.0f), -1); + LOLUNIT_ASSERT_EQUAL((int)(half)(1.9f), 1); + LOLUNIT_ASSERT_EQUAL((int)(half)(-1.9f), -1); + LOLUNIT_ASSERT_EQUAL((int)(half)(65504.0f), 65504); + LOLUNIT_ASSERT_EQUAL((int)(half)(-65504.0f), -65504); } - void test_float_op_half() + LOLUNIT_TEST(test_float_op_half) { half zero = 0; half one = 1; half two = 2; float a = zero + one; - CPPUNIT_ASSERT_EQUAL(1.0f, a); + LOLUNIT_ASSERT_EQUAL(1.0f, a); a += zero; - CPPUNIT_ASSERT_EQUAL(1.0f, a); + LOLUNIT_ASSERT_EQUAL(1.0f, a); a -= zero; - CPPUNIT_ASSERT_EQUAL(1.0f, a); + LOLUNIT_ASSERT_EQUAL(1.0f, a); a *= one; - CPPUNIT_ASSERT_EQUAL(1.0f, a); + LOLUNIT_ASSERT_EQUAL(1.0f, a); a /= one; - CPPUNIT_ASSERT_EQUAL(1.0f, a); + LOLUNIT_ASSERT_EQUAL(1.0f, a); float b = one + zero; - CPPUNIT_ASSERT_EQUAL(1.0f, b); + LOLUNIT_ASSERT_EQUAL(1.0f, b); b += one; - CPPUNIT_ASSERT_EQUAL(2.0f, b); + LOLUNIT_ASSERT_EQUAL(2.0f, b); b *= two; - CPPUNIT_ASSERT_EQUAL(4.0f, b); + LOLUNIT_ASSERT_EQUAL(4.0f, b); b -= two; - CPPUNIT_ASSERT_EQUAL(2.0f, b); + LOLUNIT_ASSERT_EQUAL(2.0f, b); b /= two; - CPPUNIT_ASSERT_EQUAL(1.0f, b); + LOLUNIT_ASSERT_EQUAL(1.0f, b); float c = one - zero; - CPPUNIT_ASSERT_EQUAL(1.0f, c); + LOLUNIT_ASSERT_EQUAL(1.0f, c); float d = two - one; - CPPUNIT_ASSERT_EQUAL(1.0f, d); + LOLUNIT_ASSERT_EQUAL(1.0f, d); float e = two + (-one); - CPPUNIT_ASSERT_EQUAL(1.0f, e); + LOLUNIT_ASSERT_EQUAL(1.0f, e); float f = (two * two) / (one + one); - CPPUNIT_ASSERT_EQUAL(2.0f, f); + LOLUNIT_ASSERT_EQUAL(2.0f, f); } - void test_half_op_float() + LOLUNIT_TEST(test_half_op_float) { half zero = 0; half one = 1; @@ -273,38 +249,38 @@ public: half four = 4; half a = one + 0.0f; - CPPUNIT_ASSERT_EQUAL(one.bits, a.bits); + LOLUNIT_ASSERT_EQUAL(one.bits, a.bits); a += 0.0f; - CPPUNIT_ASSERT_EQUAL(one.bits, a.bits); + LOLUNIT_ASSERT_EQUAL(one.bits, a.bits); a -= 0.0f; - CPPUNIT_ASSERT_EQUAL(one.bits, a.bits); + LOLUNIT_ASSERT_EQUAL(one.bits, a.bits); a *= 1.0f; - CPPUNIT_ASSERT_EQUAL(one.bits, a.bits); + LOLUNIT_ASSERT_EQUAL(one.bits, a.bits); a /= 1.0f; - CPPUNIT_ASSERT_EQUAL(one.bits, a.bits); + LOLUNIT_ASSERT_EQUAL(one.bits, a.bits); half b = one + 0.0f; - CPPUNIT_ASSERT_EQUAL(one.bits, b.bits); + LOLUNIT_ASSERT_EQUAL(one.bits, b.bits); b += 1.0f; - CPPUNIT_ASSERT_EQUAL(two.bits, b.bits); + LOLUNIT_ASSERT_EQUAL(two.bits, b.bits); b *= 2.0f; - CPPUNIT_ASSERT_EQUAL(four.bits, b.bits); + LOLUNIT_ASSERT_EQUAL(four.bits, b.bits); b -= 2.0f; - CPPUNIT_ASSERT_EQUAL(two.bits, b.bits); + LOLUNIT_ASSERT_EQUAL(two.bits, b.bits); b /= 2.0f; - CPPUNIT_ASSERT_EQUAL(one.bits, b.bits); + LOLUNIT_ASSERT_EQUAL(one.bits, b.bits); half c = 1.0f - zero; - CPPUNIT_ASSERT_EQUAL(one.bits, c.bits); + LOLUNIT_ASSERT_EQUAL(one.bits, c.bits); half d = 2.0f - one; - CPPUNIT_ASSERT_EQUAL(one.bits, d.bits); + LOLUNIT_ASSERT_EQUAL(one.bits, d.bits); half e = 2.0f + (-one); - CPPUNIT_ASSERT_EQUAL(one.bits, e.bits); + LOLUNIT_ASSERT_EQUAL(one.bits, e.bits); half f = (2.0f * two) / (1.0f + one); - CPPUNIT_ASSERT_EQUAL(two.bits, f.bits); + LOLUNIT_ASSERT_EQUAL(two.bits, f.bits); } private: @@ -329,7 +305,7 @@ HalfTest::TestPair const HalfTest::pairs[] = { 31.0f / (1 << 19), 0x03e0 }, /* 0x1.fp-15, denormal */ }; -CPPUNIT_TEST_SUITE_REGISTRATION(HalfTest); +LOLUNIT_SETUP_FIXTURE(HalfTest); } /* namespace lol */ diff --git a/test/lol-test.cpp b/test/lol-test.cpp index a03eb9b3..f2a52a9c 100644 --- a/test/lol-test.cpp +++ b/test/lol-test.cpp @@ -14,19 +14,12 @@ #include -#include -#include +#include -int main(int argc, char *argv[]) +int main(void) { - CppUnit::TextTestRunner runner; - runner.addTest(CppUnit::TestFactoryRegistry::getRegistry().makeTest()); - - int ret = !runner.run(); - -#if defined _WIN32 - getchar(); -#endif + lol::TestRunner runner; + int ret = !runner.Run(); return ret; } diff --git a/test/matrix.cpp b/test/matrix.cpp index 0b49c77a..c5eece5a 100644 --- a/test/matrix.cpp +++ b/test/matrix.cpp @@ -12,31 +12,15 @@ # include "config.h" #endif -#include -#include -#include -#include - #include "core.h" +#include "lol/unit.h" namespace lol { -class MatrixTest : public CppUnit::TestCase +LOLUNIT_FIXTURE(MatrixTest) { - CPPUNIT_TEST_SUITE(MatrixTest); - CPPUNIT_TEST(test_vec_eq); - CPPUNIT_TEST(test_vec_lt); - CPPUNIT_TEST(test_vec_unary); - CPPUNIT_TEST(test_vec_cast); - CPPUNIT_TEST(test_mat_det); - CPPUNIT_TEST(test_mat_mul); - CPPUNIT_TEST(test_mat_inv); - CPPUNIT_TEST_SUITE_END(); - public: - MatrixTest() : CppUnit::TestCase("Matrix Test") {} - void setUp() { identity = mat4(1.0f); @@ -52,34 +36,34 @@ public: void tearDown() {} - void test_vec_eq() + LOLUNIT_TEST(test_vec_eq) { vec2 a2(1.0f, 2.0f); vec2 b2(0.0f, 2.0f); vec2 c2(1.0f, 0.0f); - CPPUNIT_ASSERT(a2 == a2); - CPPUNIT_ASSERT(!(a2 != a2)); + LOLUNIT_ASSERT(a2 == a2); + LOLUNIT_ASSERT(!(a2 != a2)); - CPPUNIT_ASSERT(a2 != b2); - CPPUNIT_ASSERT(!(a2 == b2)); - CPPUNIT_ASSERT(a2 != c2); - CPPUNIT_ASSERT(!(a2 == c2)); + LOLUNIT_ASSERT(a2 != b2); + LOLUNIT_ASSERT(!(a2 == b2)); + LOLUNIT_ASSERT(a2 != c2); + LOLUNIT_ASSERT(!(a2 == c2)); vec3 a3(1.0f, 2.0f, 3.0f); vec3 b3(0.0f, 2.0f, 3.0f); vec3 c3(1.0f, 0.0f, 3.0f); vec3 d3(1.0f, 2.0f, 0.0f); - CPPUNIT_ASSERT(a3 == a3); - CPPUNIT_ASSERT(!(a3 != a3)); + LOLUNIT_ASSERT(a3 == a3); + LOLUNIT_ASSERT(!(a3 != a3)); - CPPUNIT_ASSERT(a3 != b3); - CPPUNIT_ASSERT(!(a3 == b3)); - CPPUNIT_ASSERT(a3 != c3); - CPPUNIT_ASSERT(!(a3 == c3)); - CPPUNIT_ASSERT(a3 != d3); - CPPUNIT_ASSERT(!(a3 == d3)); + LOLUNIT_ASSERT(a3 != b3); + LOLUNIT_ASSERT(!(a3 == b3)); + LOLUNIT_ASSERT(a3 != c3); + LOLUNIT_ASSERT(!(a3 == c3)); + LOLUNIT_ASSERT(a3 != d3); + LOLUNIT_ASSERT(!(a3 == d3)); vec4 a4(1.0f, 2.0f, 3.0f, 4.0f); vec4 b4(0.0f, 2.0f, 3.0f, 4.0f); @@ -87,20 +71,20 @@ public: vec4 d4(1.0f, 2.0f, 0.0f, 4.0f); vec4 e4(1.0f, 2.0f, 3.0f, 0.0f); - CPPUNIT_ASSERT(a4 == a4); - CPPUNIT_ASSERT(!(a4 != a4)); - - CPPUNIT_ASSERT(a4 != b4); - CPPUNIT_ASSERT(!(a4 == b4)); - CPPUNIT_ASSERT(a4 != c4); - CPPUNIT_ASSERT(!(a4 == c4)); - CPPUNIT_ASSERT(a4 != d4); - CPPUNIT_ASSERT(!(a4 == d4)); - CPPUNIT_ASSERT(a4 != e4); - CPPUNIT_ASSERT(!(a4 == e4)); + LOLUNIT_ASSERT(a4 == a4); + LOLUNIT_ASSERT(!(a4 != a4)); + + LOLUNIT_ASSERT(a4 != b4); + LOLUNIT_ASSERT(!(a4 == b4)); + LOLUNIT_ASSERT(a4 != c4); + LOLUNIT_ASSERT(!(a4 == c4)); + LOLUNIT_ASSERT(a4 != d4); + LOLUNIT_ASSERT(!(a4 == d4)); + LOLUNIT_ASSERT(a4 != e4); + LOLUNIT_ASSERT(!(a4 == e4)); } - void test_vec_lt() + LOLUNIT_TEST(test_vec_lt) { vec2 a2(1.0f, 3.0f); vec2 b2(0.0f, 0.0f); @@ -109,118 +93,118 @@ public: vec2 e2(3.0f, 3.0f); vec2 f2(4.0f, 4.0f); - CPPUNIT_ASSERT(a2 <= a2); - CPPUNIT_ASSERT(!(a2 < a2)); - - CPPUNIT_ASSERT(!(a2 <= b2)); - CPPUNIT_ASSERT(!(a2 < b2)); - CPPUNIT_ASSERT(!(a2 <= c2)); - CPPUNIT_ASSERT(!(a2 < c2)); - CPPUNIT_ASSERT(!(a2 <= d2)); - CPPUNIT_ASSERT(!(a2 < d2)); - CPPUNIT_ASSERT(a2 <= e2); - CPPUNIT_ASSERT(!(a2 < e2)); - CPPUNIT_ASSERT(a2 <= f2); - CPPUNIT_ASSERT(a2 < f2); + LOLUNIT_ASSERT(a2 <= a2); + LOLUNIT_ASSERT(!(a2 < a2)); + + LOLUNIT_ASSERT(!(a2 <= b2)); + LOLUNIT_ASSERT(!(a2 < b2)); + LOLUNIT_ASSERT(!(a2 <= c2)); + LOLUNIT_ASSERT(!(a2 < c2)); + LOLUNIT_ASSERT(!(a2 <= d2)); + LOLUNIT_ASSERT(!(a2 < d2)); + LOLUNIT_ASSERT(a2 <= e2); + LOLUNIT_ASSERT(!(a2 < e2)); + LOLUNIT_ASSERT(a2 <= f2); + LOLUNIT_ASSERT(a2 < f2); } - void test_vec_unary() + LOLUNIT_TEST(test_vec_unary) { vec2 a(1.0f, 3.0f); vec2 b(-1.0f, -3.0f); - CPPUNIT_ASSERT(a == -b); - CPPUNIT_ASSERT(-a == b); + LOLUNIT_ASSERT(a == -b); + LOLUNIT_ASSERT(-a == b); } - void test_vec_cast() + LOLUNIT_TEST(test_vec_cast) { vec2 a1(1.0f, 3.0f); vec3 b(a1); vec2 a2(b); - CPPUNIT_ASSERT_EQUAL(b.x, a1.x); - CPPUNIT_ASSERT_EQUAL(b.y, a1.y); - CPPUNIT_ASSERT_EQUAL(b.z, 0.0f); - CPPUNIT_ASSERT(a2 == a1); + LOLUNIT_ASSERT_EQUAL(b.x, a1.x); + LOLUNIT_ASSERT_EQUAL(b.y, a1.y); + LOLUNIT_ASSERT_EQUAL(b.z, 0.0f); + LOLUNIT_ASSERT(a2 == a1); vec4 c(a1); vec2 a3(c); - CPPUNIT_ASSERT_EQUAL(c.x, a1.x); - CPPUNIT_ASSERT_EQUAL(c.y, a1.y); - CPPUNIT_ASSERT_EQUAL(c.z, 0.0f); - CPPUNIT_ASSERT_EQUAL(c.w, 0.0f); - CPPUNIT_ASSERT(a3 == a1); + LOLUNIT_ASSERT_EQUAL(c.x, a1.x); + LOLUNIT_ASSERT_EQUAL(c.y, a1.y); + LOLUNIT_ASSERT_EQUAL(c.z, 0.0f); + LOLUNIT_ASSERT_EQUAL(c.w, 0.0f); + LOLUNIT_ASSERT(a3 == a1); } - void test_mat_det() + LOLUNIT_TEST(test_mat_det) { float d1 = triangular.det(); - CPPUNIT_ASSERT_EQUAL(d1, 24.0f); + LOLUNIT_ASSERT_EQUAL(d1, 24.0f); float d2 = invertible.det(); - CPPUNIT_ASSERT_EQUAL(d2, -1.0f); + LOLUNIT_ASSERT_EQUAL(d2, -1.0f); } - void test_mat_mul() + LOLUNIT_TEST(test_mat_mul) { mat4 m0 = identity; mat4 m1 = identity; mat4 m2 = m0 * m1; - CPPUNIT_ASSERT_EQUAL(m2[0][0], 1.0f); - CPPUNIT_ASSERT_EQUAL(m2[1][0], 0.0f); - CPPUNIT_ASSERT_EQUAL(m2[2][0], 0.0f); - CPPUNIT_ASSERT_EQUAL(m2[3][0], 0.0f); - - CPPUNIT_ASSERT_EQUAL(m2[0][1], 0.0f); - CPPUNIT_ASSERT_EQUAL(m2[1][1], 1.0f); - CPPUNIT_ASSERT_EQUAL(m2[2][1], 0.0f); - CPPUNIT_ASSERT_EQUAL(m2[3][1], 0.0f); - - CPPUNIT_ASSERT_EQUAL(m2[0][2], 0.0f); - CPPUNIT_ASSERT_EQUAL(m2[1][2], 0.0f); - CPPUNIT_ASSERT_EQUAL(m2[2][2], 1.0f); - CPPUNIT_ASSERT_EQUAL(m2[3][2], 0.0f); - - CPPUNIT_ASSERT_EQUAL(m2[0][3], 0.0f); - CPPUNIT_ASSERT_EQUAL(m2[1][3], 0.0f); - CPPUNIT_ASSERT_EQUAL(m2[2][3], 0.0f); - CPPUNIT_ASSERT_EQUAL(m2[3][3], 1.0f); + LOLUNIT_ASSERT_EQUAL(m2[0][0], 1.0f); + LOLUNIT_ASSERT_EQUAL(m2[1][0], 0.0f); + LOLUNIT_ASSERT_EQUAL(m2[2][0], 0.0f); + LOLUNIT_ASSERT_EQUAL(m2[3][0], 0.0f); + + LOLUNIT_ASSERT_EQUAL(m2[0][1], 0.0f); + LOLUNIT_ASSERT_EQUAL(m2[1][1], 1.0f); + LOLUNIT_ASSERT_EQUAL(m2[2][1], 0.0f); + LOLUNIT_ASSERT_EQUAL(m2[3][1], 0.0f); + + LOLUNIT_ASSERT_EQUAL(m2[0][2], 0.0f); + LOLUNIT_ASSERT_EQUAL(m2[1][2], 0.0f); + LOLUNIT_ASSERT_EQUAL(m2[2][2], 1.0f); + LOLUNIT_ASSERT_EQUAL(m2[3][2], 0.0f); + + LOLUNIT_ASSERT_EQUAL(m2[0][3], 0.0f); + LOLUNIT_ASSERT_EQUAL(m2[1][3], 0.0f); + LOLUNIT_ASSERT_EQUAL(m2[2][3], 0.0f); + LOLUNIT_ASSERT_EQUAL(m2[3][3], 1.0f); } - void test_mat_inv() + LOLUNIT_TEST(test_mat_inv) { mat4 m0 = invertible; mat4 m1 = m0.invert(); mat4 m2 = m0 * m1; - CPPUNIT_ASSERT_EQUAL(m2[0][0], 1.0f); - CPPUNIT_ASSERT_EQUAL(m2[1][0], 0.0f); - CPPUNIT_ASSERT_EQUAL(m2[2][0], 0.0f); - CPPUNIT_ASSERT_EQUAL(m2[3][0], 0.0f); - - CPPUNIT_ASSERT_EQUAL(m2[0][1], 0.0f); - CPPUNIT_ASSERT_EQUAL(m2[1][1], 1.0f); - CPPUNIT_ASSERT_EQUAL(m2[2][1], 0.0f); - CPPUNIT_ASSERT_EQUAL(m2[3][1], 0.0f); - - CPPUNIT_ASSERT_EQUAL(m2[0][2], 0.0f); - CPPUNIT_ASSERT_EQUAL(m2[1][2], 0.0f); - CPPUNIT_ASSERT_EQUAL(m2[2][2], 1.0f); - CPPUNIT_ASSERT_EQUAL(m2[3][2], 0.0f); - - CPPUNIT_ASSERT_EQUAL(m2[0][3], 0.0f); - CPPUNIT_ASSERT_EQUAL(m2[1][3], 0.0f); - CPPUNIT_ASSERT_EQUAL(m2[2][3], 0.0f); - CPPUNIT_ASSERT_EQUAL(m2[3][3], 1.0f); + LOLUNIT_ASSERT_EQUAL(m2[0][0], 1.0f); + LOLUNIT_ASSERT_EQUAL(m2[1][0], 0.0f); + LOLUNIT_ASSERT_EQUAL(m2[2][0], 0.0f); + LOLUNIT_ASSERT_EQUAL(m2[3][0], 0.0f); + + LOLUNIT_ASSERT_EQUAL(m2[0][1], 0.0f); + LOLUNIT_ASSERT_EQUAL(m2[1][1], 1.0f); + LOLUNIT_ASSERT_EQUAL(m2[2][1], 0.0f); + LOLUNIT_ASSERT_EQUAL(m2[3][1], 0.0f); + + LOLUNIT_ASSERT_EQUAL(m2[0][2], 0.0f); + LOLUNIT_ASSERT_EQUAL(m2[1][2], 0.0f); + LOLUNIT_ASSERT_EQUAL(m2[2][2], 1.0f); + LOLUNIT_ASSERT_EQUAL(m2[3][2], 0.0f); + + LOLUNIT_ASSERT_EQUAL(m2[0][3], 0.0f); + LOLUNIT_ASSERT_EQUAL(m2[1][3], 0.0f); + LOLUNIT_ASSERT_EQUAL(m2[2][3], 0.0f); + LOLUNIT_ASSERT_EQUAL(m2[3][3], 1.0f); } private: mat4 triangular, identity, invertible; }; -CPPUNIT_TEST_SUITE_REGISTRATION(MatrixTest); +LOLUNIT_SETUP_FIXTURE(MatrixTest); } /* namespace lol */ diff --git a/test/trig.cpp b/test/trig.cpp index d1643abd..9fa86241 100644 --- a/test/trig.cpp +++ b/test/trig.cpp @@ -12,32 +12,21 @@ # include "config.h" #endif -#include -#include -#include -#include - #include #include "core.h" +#include "lol/unit.h" namespace lol { -class TrigTest : public CppUnit::TestCase +LOLUNIT_FIXTURE(TrigTest) { - CPPUNIT_TEST_SUITE(TrigTest); - CPPUNIT_TEST(test_sin); - CPPUNIT_TEST_SUITE_END(); - public: - TrigTest() : CppUnit::TestCase("Trigonometry Test") {} - void setUp() {} - void tearDown() {} - void test_sin() + LOLUNIT_TEST(test_sin) { for (int i = -10000; i < 10000; i++) { @@ -48,7 +37,7 @@ public: double a = sin(f); #endif double b = lol_sin(f); - CPPUNIT_ASSERT_DOUBLES_EQUAL(a, b, fabs(f) * 1e-11); + LOLUNIT_ASSERT_DOUBLES_EQUAL(a, b, fabs(f) * 1e-11); } for (int i = -10000; i < 10000; i++) @@ -60,9 +49,12 @@ public: double a = sin(f); #endif double b = lol_sin(f); - CPPUNIT_ASSERT_DOUBLES_EQUAL(a, b, fabs(f) * 1e-11); + LOLUNIT_ASSERT_DOUBLES_EQUAL(a, b, fabs(f) * 1e-11); } + } + LOLUNIT_TEST(test_cos) + { for (int i = -10000; i < 10000; i++) { double f = (double)i * (1.0 / 1000.0); @@ -72,7 +64,7 @@ public: double a = cos(f); #endif double b = lol_cos(f); - CPPUNIT_ASSERT_DOUBLES_EQUAL(a, b, fabs(f) * 1e-11); + LOLUNIT_ASSERT_DOUBLES_EQUAL(a, b, fabs(f) * 1e-11); } for (int i = -10000; i < 10000; i++) @@ -84,9 +76,12 @@ public: double a = cos(f); #endif double b = lol_cos(f); - CPPUNIT_ASSERT_DOUBLES_EQUAL(a, b, fabs(f) * 1e-11); + LOLUNIT_ASSERT_DOUBLES_EQUAL(a, b, fabs(f) * 1e-11); } + } + LOLUNIT_TEST(test_sincos) + { for (int i = -10000; i < 10000; i++) { double f = (double)i * (1.0 / 1000.0); @@ -99,8 +94,8 @@ public: #endif double b1, b2; lol_sincos(f, &b1, &b2); - CPPUNIT_ASSERT_DOUBLES_EQUAL(a1, b1, fabs(f) * 1e-11); - CPPUNIT_ASSERT_DOUBLES_EQUAL(a2, b2, fabs(f) * 1e-11); + LOLUNIT_ASSERT_DOUBLES_EQUAL(a1, b1, fabs(f) * 1e-11); + LOLUNIT_ASSERT_DOUBLES_EQUAL(a2, b2, fabs(f) * 1e-11); } for (int i = -10000; i < 10000; i++) @@ -115,10 +110,13 @@ public: #endif double b1, b2; lol_sincos(f, &b1, &b2); - CPPUNIT_ASSERT_DOUBLES_EQUAL(a1, b1, fabs(f) * 1e-11); - CPPUNIT_ASSERT_DOUBLES_EQUAL(a2, b2, fabs(f) * 1e-11); + LOLUNIT_ASSERT_DOUBLES_EQUAL(a1, b1, fabs(f) * 1e-11); + LOLUNIT_ASSERT_DOUBLES_EQUAL(a2, b2, fabs(f) * 1e-11); } + } + LOLUNIT_TEST(test_tan) + { for (int i = -100000; i < 100000; i++) { double f = (double)i * (1.0 / 10000.0); @@ -129,11 +127,11 @@ public: #endif double b = lol_tan(f); if (fabs(a) > 1e4) - CPPUNIT_ASSERT_DOUBLES_EQUAL(a, b, fabs(a) * fabs(a) * 1e-11); + LOLUNIT_ASSERT_DOUBLES_EQUAL(a, b, fabs(a) * fabs(a) * 1e-11); else if (fabs(a) > 1.0) - CPPUNIT_ASSERT_DOUBLES_EQUAL(a, b, fabs(a) * 1e-11); + LOLUNIT_ASSERT_DOUBLES_EQUAL(a, b, fabs(a) * 1e-11); else - CPPUNIT_ASSERT_DOUBLES_EQUAL(a, b, fabs(f) * 1e-11); + LOLUNIT_ASSERT_DOUBLES_EQUAL(a, b, fabs(f) * 1e-11); } for (int i = -10000; i < 10000; i++) @@ -146,16 +144,16 @@ public: #endif double b = lol_tan(f); if (fabs(a) > 1e4) - CPPUNIT_ASSERT_DOUBLES_EQUAL(a, b, fabs(a) * fabs(a) * 1e-11); + LOLUNIT_ASSERT_DOUBLES_EQUAL(a, b, fabs(a) * fabs(a) * 1e-11); else if (fabs(a) > 1.0) - CPPUNIT_ASSERT_DOUBLES_EQUAL(a, b, fabs(a) * 1e-11); + LOLUNIT_ASSERT_DOUBLES_EQUAL(a, b, fabs(a) * 1e-11); else - CPPUNIT_ASSERT_DOUBLES_EQUAL(a, b, fabs(f) * 1e-11); + LOLUNIT_ASSERT_DOUBLES_EQUAL(a, b, fabs(f) * 1e-11); } } }; -CPPUNIT_TEST_SUITE_REGISTRATION(TrigTest); +LOLUNIT_SETUP_FIXTURE(TrigTest); } /* namespace lol */ diff --git a/win32/Contribs.props b/win32/Contribs.props index 3944681f..293882d8 100644 --- a/win32/Contribs.props +++ b/win32/Contribs.props @@ -3,18 +3,15 @@ $(SolutionDir)\..\contrib - $(ContribDir)\cppunit-1.12.2 $(ContribDir)\glew-1.6.0 $(ContribDir)\gtk-2.22.1 $(ContribDir)\gtkglarea-2.0.1 $(ContribDir)\sdl-1.2.14 $(ContribDir)\sdl-image-1.2.10 $(ContribDir)\sdl-mixer-1.2.11 - $(CppUnitDir)\include $(GlewDir)\include $(GtkDir)\lib\glib-2.0\include;$(GtkDir)\lib\gtk-2.0\include;$(GtkDir)\include\glib-2.0;$(GtkDir)\include\gtk-2.0;$(GtkDir)\include\cairo;$(GtkDir)\include\pango-1.0;$(GtkDir)\include\gdk-pixbuf-2.0;$(GtkDir)\include\atk-1.0;$(GtkGlDir)\include $(SdlDir)\include;$(SdlImageDir)\include;$(SdlMixerDir)\include - $(CppUnitDir)\lib $(GlewDir)\lib $(GtkDir)\lib;$(GtkDir)\bin;$(GtkGlDir)\lib $(SdlDir)\lib;$(SdlImageDir)\lib;$(SdlMixerDir)\lib @@ -27,18 +24,15 @@ $(ContribDir) - $(CppUnitDir) $(GlewDir) $(GtkDir) $(GtkGlDir) $(SdlDir) $(SdlImageDir) $(SdlMixerDir) - $(CppUnitIncludes) $(GlIncludes) $(GtkIncludes) $(SdlIncludes) - $(CppUnitLibss) $(GlLibs) $(GtkLibs) $(SdlLibs) diff --git a/win32/lol-test.vcxproj b/win32/lol-test.vcxproj index 7b9e5a1c..ec87352c 100644 --- a/win32/lol-test.vcxproj +++ b/win32/lol-test.vcxproj @@ -62,13 +62,13 @@ Level3 Disabled WIN32;_DEBUG;_CONSOLE;$(LolDefines);%(PreprocessorDefinitions) - $(SolutionDir)\..\src;$(CppUnitIncludes);$(GlIncludes);$(SdlIncludes);%(AdditionalIncludeDirectories) + $(SolutionDir)\..\src;$(GlIncludes);$(SdlIncludes);%(AdditionalIncludeDirectories) Console true - kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies);$(SdlDeps);libcppunit_msvcd.lib;$(GlDeps);$(OutDir)\lolcore.lib - $(SdlLibs);$(CppUnitLibs);$(GlLibs);%(AdditionalLibraryDirectories) + kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies);$(SdlDeps);$(GlDeps);$(OutDir)\lolcore.lib + $(SdlLibs);$(GlLibs);%(AdditionalLibraryDirectories) for %%I in ($(SdlLibs)) do xcopy /y /c /d %%I\*.dll $(TargetDir) @@ -83,15 +83,15 @@ true true WIN32;NDEBUG;_CONSOLE;$(LolDefines);%(PreprocessorDefinitions) - $(SolutionDir)\..\src;$(CppUnitIncludes);$(GlIncludes);$(SdlIncludes);%(AdditionalIncludeDirectories) + $(SolutionDir)\..\src;$(GlIncludes);$(SdlIncludes);%(AdditionalIncludeDirectories) Console true true true - kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies);$(SdlDeps);libcppunit_msvc.lib;$(GlDeps);$(OutDir)\lolcore.lib - $(SdlLibs);$(CppUnitLibs);$(GlLibs);%(AdditionalLibraryDirectories) + kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies);$(SdlDeps);$(GlDeps);$(OutDir)\lolcore.lib + $(SdlLibs);$(GlLibs);%(AdditionalLibraryDirectories) for %%I in ($(SdlLibs)) do xcopy /y /c /d %%I\*.dll $(TargetDir)