| @@ -30,13 +30,13 @@ struct TrackedObj | |||
| int TrackedObj::m_ctor = 0; | |||
| int TrackedObj::m_dtor = 0; | |||
| LOLUNIT_FIXTURE(ArrayTest) | |||
| lolunit_declare_fixture(ArrayTest) | |||
| { | |||
| void SetUp() {} | |||
| void TearDown() {} | |||
| LOLUNIT_TEST(ArrayPush) | |||
| lolunit_declare_test(ArrayPush) | |||
| { | |||
| array<int> a; | |||
| a.Push(0); | |||
| @@ -44,188 +44,188 @@ LOLUNIT_FIXTURE(ArrayTest) | |||
| a.Push(2); | |||
| a.Push(3); | |||
| LOLUNIT_ASSERT_EQUAL(a[0], 0); | |||
| LOLUNIT_ASSERT_EQUAL(a[1], 1); | |||
| LOLUNIT_ASSERT_EQUAL(a[2], 2); | |||
| LOLUNIT_ASSERT_EQUAL(a[3], 3); | |||
| lolunit_assert_equal(a[0], 0); | |||
| lolunit_assert_equal(a[1], 1); | |||
| lolunit_assert_equal(a[2], 2); | |||
| lolunit_assert_equal(a[3], 3); | |||
| } | |||
| LOLUNIT_TEST(ArrayInitializer) | |||
| lolunit_declare_test(ArrayInitializer) | |||
| { | |||
| array<int> a({ 2, 4, 6 }); | |||
| LOLUNIT_ASSERT_EQUAL(a[0], 2); | |||
| LOLUNIT_ASSERT_EQUAL(a[1], 4); | |||
| LOLUNIT_ASSERT_EQUAL(a[2], 6); | |||
| lolunit_assert_equal(a[0], 2); | |||
| lolunit_assert_equal(a[1], 4); | |||
| lolunit_assert_equal(a[2], 6); | |||
| array<int> b = { 2, 4, 6 }; | |||
| LOLUNIT_ASSERT_EQUAL(b[0], 2); | |||
| LOLUNIT_ASSERT_EQUAL(b[1], 4); | |||
| LOLUNIT_ASSERT_EQUAL(b[2], 6); | |||
| lolunit_assert_equal(b[0], 2); | |||
| lolunit_assert_equal(b[1], 4); | |||
| lolunit_assert_equal(b[2], 6); | |||
| array<int, float> c = { { 2, 3.0f }, | |||
| { 4, 5.0f }, | |||
| { 6, 7.0f } }; | |||
| LOLUNIT_ASSERT_EQUAL(c[0].m1, 2); | |||
| LOLUNIT_ASSERT_EQUAL(c[0].m2, 3.0f); | |||
| LOLUNIT_ASSERT_EQUAL(c[1].m1, 4); | |||
| LOLUNIT_ASSERT_EQUAL(c[1].m2, 5.0f); | |||
| LOLUNIT_ASSERT_EQUAL(c[2].m1, 6); | |||
| LOLUNIT_ASSERT_EQUAL(c[2].m2, 7.0f); | |||
| lolunit_assert_equal(c[0].m1, 2); | |||
| lolunit_assert_equal(c[0].m2, 3.0f); | |||
| lolunit_assert_equal(c[1].m1, 4); | |||
| lolunit_assert_equal(c[1].m2, 5.0f); | |||
| lolunit_assert_equal(c[2].m1, 6); | |||
| lolunit_assert_equal(c[2].m2, 7.0f); | |||
| } | |||
| LOLUNIT_TEST(ArrayPushWithShift) | |||
| lolunit_declare_test(ArrayPushWithShift) | |||
| { | |||
| array<int> a; | |||
| a << 0 << 1 << 2 << 3; | |||
| LOLUNIT_ASSERT_EQUAL(a[0], 0); | |||
| LOLUNIT_ASSERT_EQUAL(a[1], 1); | |||
| LOLUNIT_ASSERT_EQUAL(a[2], 2); | |||
| LOLUNIT_ASSERT_EQUAL(a[3], 3); | |||
| lolunit_assert_equal(a[0], 0); | |||
| lolunit_assert_equal(a[1], 1); | |||
| lolunit_assert_equal(a[2], 2); | |||
| lolunit_assert_equal(a[3], 3); | |||
| } | |||
| LOLUNIT_TEST(ArrayCopy) | |||
| lolunit_declare_test(ArrayCopy) | |||
| { | |||
| array<int> a; | |||
| a << 0 << 1 << 2 << 3; | |||
| array<int> b = a; | |||
| LOLUNIT_ASSERT_EQUAL(b[0], 0); | |||
| LOLUNIT_ASSERT_EQUAL(b[1], 1); | |||
| LOLUNIT_ASSERT_EQUAL(b[2], 2); | |||
| LOLUNIT_ASSERT_EQUAL(b[3], 3); | |||
| lolunit_assert_equal(b[0], 0); | |||
| lolunit_assert_equal(b[1], 1); | |||
| lolunit_assert_equal(b[2], 2); | |||
| lolunit_assert_equal(b[3], 3); | |||
| } | |||
| LOLUNIT_TEST(ArrayRemove) | |||
| lolunit_declare_test(ArrayRemove) | |||
| { | |||
| array<int> a; | |||
| a << 0 << 1 << 2 << 3; | |||
| a.Remove(1); | |||
| LOLUNIT_ASSERT_EQUAL(a.Count(), 3); | |||
| LOLUNIT_ASSERT_EQUAL(a[0], 0); | |||
| LOLUNIT_ASSERT_EQUAL(a[1], 2); | |||
| LOLUNIT_ASSERT_EQUAL(a[2], 3); | |||
| lolunit_assert_equal(a.Count(), 3); | |||
| lolunit_assert_equal(a[0], 0); | |||
| lolunit_assert_equal(a[1], 2); | |||
| lolunit_assert_equal(a[2], 3); | |||
| array<int> b; | |||
| b << 0 << 1 << 2 << 3; | |||
| b.Remove(-2); | |||
| LOLUNIT_ASSERT_EQUAL(b.Count(), 3); | |||
| LOLUNIT_ASSERT_EQUAL(b[0], 0); | |||
| LOLUNIT_ASSERT_EQUAL(b[1], 1); | |||
| LOLUNIT_ASSERT_EQUAL(b[2], 3); | |||
| lolunit_assert_equal(b.Count(), 3); | |||
| lolunit_assert_equal(b[0], 0); | |||
| lolunit_assert_equal(b[1], 1); | |||
| lolunit_assert_equal(b[2], 3); | |||
| } | |||
| LOLUNIT_TEST(ArrayRemoveSwap) | |||
| lolunit_declare_test(ArrayRemoveSwap) | |||
| { | |||
| array<int> a; | |||
| a << 0 << 1 << 2 << 3; | |||
| a.RemoveSwap(1); | |||
| LOLUNIT_ASSERT_EQUAL(a.Count(), 3); | |||
| LOLUNIT_ASSERT_EQUAL(a[0], 0); | |||
| LOLUNIT_ASSERT_EQUAL(a[1], 3); | |||
| LOLUNIT_ASSERT_EQUAL(a[2], 2); | |||
| lolunit_assert_equal(a.Count(), 3); | |||
| lolunit_assert_equal(a[0], 0); | |||
| lolunit_assert_equal(a[1], 3); | |||
| lolunit_assert_equal(a[2], 2); | |||
| array<int> b; | |||
| b << 0 << 1 << 2 << 3; | |||
| b.Remove(1, 2); | |||
| LOLUNIT_ASSERT_EQUAL(b.Count(), 2); | |||
| LOLUNIT_ASSERT_EQUAL(b[0], 0); | |||
| LOLUNIT_ASSERT_EQUAL(b[1], 3); | |||
| lolunit_assert_equal(b.Count(), 2); | |||
| lolunit_assert_equal(b[0], 0); | |||
| lolunit_assert_equal(b[1], 3); | |||
| } | |||
| LOLUNIT_TEST(EightElements) | |||
| lolunit_declare_test(EightElements) | |||
| { | |||
| array<int, long, float, double, unsigned, char, bool, void *> a; | |||
| a.Push(1, 2, 3.f, 4.0, 5, 'a', true, 0); | |||
| LOLUNIT_ASSERT_EQUAL(a[0].m1, 1); | |||
| LOLUNIT_ASSERT_EQUAL(a[0].m2, 2); | |||
| LOLUNIT_ASSERT_EQUAL(a[0].m3, 3.f); | |||
| LOLUNIT_ASSERT_EQUAL(a[0].m4, 4.0); | |||
| LOLUNIT_ASSERT_EQUAL(a[0].m5, 5); | |||
| LOLUNIT_ASSERT_EQUAL(a[0].m6, 'a'); | |||
| LOLUNIT_ASSERT_EQUAL(a[0].m7, true); | |||
| LOLUNIT_ASSERT_EQUAL(a[0].m8, 0); | |||
| lolunit_assert_equal(a[0].m1, 1); | |||
| lolunit_assert_equal(a[0].m2, 2); | |||
| lolunit_assert_equal(a[0].m3, 3.f); | |||
| lolunit_assert_equal(a[0].m4, 4.0); | |||
| lolunit_assert_equal(a[0].m5, 5); | |||
| lolunit_assert_equal(a[0].m6, 'a'); | |||
| lolunit_assert_equal(a[0].m7, true); | |||
| lolunit_assert_equal(a[0].m8, 0); | |||
| } | |||
| LOLUNIT_TEST(ArraySwap) | |||
| lolunit_declare_test(ArraySwap) | |||
| { | |||
| array<int, int> a; | |||
| a.Push(10, 20); | |||
| a.Push(30, 40); | |||
| a.Swap(0, 1); | |||
| LOLUNIT_ASSERT_EQUAL(30, a[0].m1); | |||
| LOLUNIT_ASSERT_EQUAL(40, a[0].m2); | |||
| LOLUNIT_ASSERT_EQUAL(10, a[1].m1); | |||
| LOLUNIT_ASSERT_EQUAL(20, a[1].m2); | |||
| lolunit_assert_equal(30, a[0].m1); | |||
| lolunit_assert_equal(40, a[0].m2); | |||
| lolunit_assert_equal(10, a[1].m1); | |||
| lolunit_assert_equal(20, a[1].m2); | |||
| } | |||
| LOLUNIT_TEST(ArrayInsert) | |||
| lolunit_declare_test(ArrayInsert) | |||
| { | |||
| array<int> a; | |||
| a << 1 << 2; | |||
| a.Insert(5, 0); | |||
| LOLUNIT_ASSERT_EQUAL(5, a[0]); | |||
| LOLUNIT_ASSERT_EQUAL(1, a[1]); | |||
| LOLUNIT_ASSERT_EQUAL(2, a[2]); | |||
| lolunit_assert_equal(5, a[0]); | |||
| lolunit_assert_equal(1, a[1]); | |||
| lolunit_assert_equal(2, a[2]); | |||
| a.Insert(6, 3); | |||
| LOLUNIT_ASSERT_EQUAL(5, a[0]); | |||
| LOLUNIT_ASSERT_EQUAL(1, a[1]); | |||
| LOLUNIT_ASSERT_EQUAL(2, a[2]); | |||
| LOLUNIT_ASSERT_EQUAL(6, a[3]); | |||
| lolunit_assert_equal(5, a[0]); | |||
| lolunit_assert_equal(1, a[1]); | |||
| lolunit_assert_equal(2, a[2]); | |||
| lolunit_assert_equal(6, a[3]); | |||
| a.Insert(7, 2); | |||
| LOLUNIT_ASSERT_EQUAL(5, a[0]); | |||
| LOLUNIT_ASSERT_EQUAL(1, a[1]); | |||
| LOLUNIT_ASSERT_EQUAL(7, a[2]); | |||
| LOLUNIT_ASSERT_EQUAL(2, a[3]); | |||
| LOLUNIT_ASSERT_EQUAL(6, a[4]); | |||
| lolunit_assert_equal(5, a[0]); | |||
| lolunit_assert_equal(1, a[1]); | |||
| lolunit_assert_equal(7, a[2]); | |||
| lolunit_assert_equal(2, a[3]); | |||
| lolunit_assert_equal(6, a[4]); | |||
| } | |||
| LOLUNIT_TEST(ArrayConcat) | |||
| lolunit_declare_test(ArrayConcat) | |||
| { | |||
| array<int> a, b; | |||
| a << 0 << 1; | |||
| b << 2 << 3; | |||
| array<int> c = a + b; | |||
| LOLUNIT_ASSERT_EQUAL(c[0], 0); | |||
| LOLUNIT_ASSERT_EQUAL(c[1], 1); | |||
| LOLUNIT_ASSERT_EQUAL(c[2], 2); | |||
| LOLUNIT_ASSERT_EQUAL(c[3], 3); | |||
| lolunit_assert_equal(c[0], 0); | |||
| lolunit_assert_equal(c[1], 1); | |||
| lolunit_assert_equal(c[2], 2); | |||
| lolunit_assert_equal(c[3], 3); | |||
| } | |||
| LOLUNIT_TEST(ArrayAppend) | |||
| lolunit_declare_test(ArrayAppend) | |||
| { | |||
| array<int> a, b; | |||
| a << 0 << 1; | |||
| b << 2 << 3; | |||
| a += b; | |||
| LOLUNIT_ASSERT_EQUAL(a[0], 0); | |||
| LOLUNIT_ASSERT_EQUAL(a[1], 1); | |||
| LOLUNIT_ASSERT_EQUAL(a[2], 2); | |||
| LOLUNIT_ASSERT_EQUAL(a[3], 3); | |||
| lolunit_assert_equal(a[0], 0); | |||
| lolunit_assert_equal(a[1], 1); | |||
| lolunit_assert_equal(a[2], 2); | |||
| lolunit_assert_equal(a[3], 3); | |||
| b += b; | |||
| LOLUNIT_ASSERT_EQUAL(b[0], 2); | |||
| LOLUNIT_ASSERT_EQUAL(b[1], 3); | |||
| LOLUNIT_ASSERT_EQUAL(b[2], 2); | |||
| LOLUNIT_ASSERT_EQUAL(b[3], 3); | |||
| lolunit_assert_equal(b[0], 2); | |||
| lolunit_assert_equal(b[1], 3); | |||
| lolunit_assert_equal(b[2], 2); | |||
| lolunit_assert_equal(b[3], 3); | |||
| } | |||
| LOLUNIT_TEST(ElementCtorDtor) | |||
| lolunit_declare_test(ElementCtorDtor) | |||
| { | |||
| /* Ensure array elements get created and destroyed the proper | |||
| * number of times. */ | |||
| @@ -236,7 +236,7 @@ LOLUNIT_FIXTURE(ArrayTest) | |||
| a.Push(TrackedObj()); | |||
| } | |||
| LOLUNIT_ASSERT_EQUAL(TrackedObj::m_ctor, TrackedObj::m_dtor); | |||
| lolunit_assert_equal(TrackedObj::m_ctor, TrackedObj::m_dtor); | |||
| TrackedObj::m_ctor = 0; | |||
| TrackedObj::m_dtor = 0; | |||
| @@ -247,7 +247,7 @@ LOLUNIT_FIXTURE(ArrayTest) | |||
| a.Resize(4); | |||
| a.Resize(1); | |||
| } | |||
| LOLUNIT_ASSERT_EQUAL(TrackedObj::m_ctor, TrackedObj::m_dtor); | |||
| lolunit_assert_equal(TrackedObj::m_ctor, TrackedObj::m_dtor); | |||
| } | |||
| }; | |||
| @@ -18,13 +18,13 @@ | |||
| namespace lol | |||
| { | |||
| LOLUNIT_FIXTURE(EnumTest) | |||
| lolunit_declare_fixture(EnumTest) | |||
| { | |||
| void SetUp() {} | |||
| void TearDown() {} | |||
| LOLUNIT_TEST(EnumToString) | |||
| lolunit_declare_test(EnumToString) | |||
| { | |||
| LOL_SAFE_ENUM(MyEnum, | |||
| First = -10, | |||
| @@ -33,18 +33,18 @@ LOLUNIT_FIXTURE(EnumTest) | |||
| ); | |||
| MyEnum e = MyEnum::First; | |||
| LOLUNIT_ASSERT(e.ToString() == "First"); | |||
| lolunit_assert(e.ToString() == "First"); | |||
| e = MyEnum::Second; | |||
| LOLUNIT_ASSERT(e.ToString() == "Second"); | |||
| lolunit_assert(e.ToString() == "Second"); | |||
| e = MyEnum::Third; | |||
| LOLUNIT_ASSERT(e.ToString() == "Third"); | |||
| lolunit_assert(e.ToString() == "Third"); | |||
| e = MyEnum(42); | |||
| LOLUNIT_ASSERT(e.ToString() != "First"); | |||
| LOLUNIT_ASSERT(e.ToString() != "Second"); | |||
| LOLUNIT_ASSERT(e.ToString() != "Third"); | |||
| lolunit_assert(e.ToString() != "First"); | |||
| lolunit_assert(e.ToString() != "Second"); | |||
| lolunit_assert(e.ToString() != "Third"); | |||
| } | |||
| }; | |||
| @@ -18,13 +18,13 @@ | |||
| namespace lol | |||
| { | |||
| LOLUNIT_FIXTURE(MapTest) | |||
| lolunit_declare_fixture(MapTest) | |||
| { | |||
| void SetUp() {} | |||
| void TearDown() {} | |||
| LOLUNIT_TEST(MapDeclare) | |||
| lolunit_declare_test(MapDeclare) | |||
| { | |||
| map<uint8_t, uint8_t> m1; | |||
| map<int, int> m2; | |||
| @@ -32,7 +32,7 @@ LOLUNIT_FIXTURE(MapTest) | |||
| map<char const *, char const *> m4; | |||
| } | |||
| LOLUNIT_TEST(MapSet) | |||
| lolunit_declare_test(MapSet) | |||
| { | |||
| map<int, int> map; | |||
| @@ -43,22 +43,22 @@ LOLUNIT_FIXTURE(MapTest) | |||
| map[i] = i; | |||
| for (int i = 0; i < 1000; i++) | |||
| LOLUNIT_ASSERT_EQUAL(map[i], i); | |||
| lolunit_assert_equal(map[i], i); | |||
| } | |||
| LOLUNIT_TEST(MapHasKey) | |||
| lolunit_declare_test(MapHasKey) | |||
| { | |||
| map<int, int> map; | |||
| map[0] = 1; | |||
| map[2] = 2; | |||
| LOLUNIT_ASSERT(map.HasKey(0)); | |||
| LOLUNIT_ASSERT(!map.HasKey(1)); | |||
| LOLUNIT_ASSERT(map.HasKey(2)); | |||
| lolunit_assert(map.HasKey(0)); | |||
| lolunit_assert(!map.HasKey(1)); | |||
| lolunit_assert(map.HasKey(2)); | |||
| } | |||
| LOLUNIT_TEST(StringMap) | |||
| lolunit_declare_test(StringMap) | |||
| { | |||
| map<char const *, int> map; | |||
| @@ -70,9 +70,9 @@ LOLUNIT_FIXTURE(MapTest) | |||
| int bar = map["bar"]; | |||
| int baz = map["baz"]; | |||
| LOLUNIT_ASSERT_EQUAL(42, foo); | |||
| LOLUNIT_ASSERT_EQUAL(12, bar); | |||
| LOLUNIT_ASSERT_EQUAL(2, baz); | |||
| lolunit_assert_equal(42, foo); | |||
| lolunit_assert_equal(12, bar); | |||
| lolunit_assert_equal(2, baz); | |||
| } | |||
| }; | |||
| @@ -18,163 +18,163 @@ | |||
| namespace lol | |||
| { | |||
| LOLUNIT_FIXTURE(StringTest) | |||
| lolunit_declare_fixture(StringTest) | |||
| { | |||
| void SetUp() {} | |||
| void TearDown() {} | |||
| LOLUNIT_TEST(StringBuild) | |||
| lolunit_declare_test(StringBuild) | |||
| { | |||
| String s1; | |||
| LOLUNIT_ASSERT_EQUAL(s1.Count(), 0); | |||
| LOLUNIT_ASSERT_EQUAL(s1[0], '\0'); | |||
| lolunit_assert_equal(s1.Count(), 0); | |||
| lolunit_assert_equal(s1[0], '\0'); | |||
| String s2(""); | |||
| LOLUNIT_ASSERT_EQUAL(s2.Count(), 0); | |||
| LOLUNIT_ASSERT_EQUAL(s2[0], '\0'); | |||
| lolunit_assert_equal(s2.Count(), 0); | |||
| lolunit_assert_equal(s2[0], '\0'); | |||
| String s3("a"); | |||
| LOLUNIT_ASSERT_EQUAL(s3.Count(), 1); | |||
| LOLUNIT_ASSERT_EQUAL(s3[0], 'a'); | |||
| LOLUNIT_ASSERT_EQUAL(s3[1], '\0'); | |||
| lolunit_assert_equal(s3.Count(), 1); | |||
| lolunit_assert_equal(s3[0], 'a'); | |||
| lolunit_assert_equal(s3[1], '\0'); | |||
| String s4(s3); | |||
| LOLUNIT_ASSERT_EQUAL(s4.Count(), 1); | |||
| LOLUNIT_ASSERT_EQUAL(s4[0], 'a'); | |||
| LOLUNIT_ASSERT_EQUAL(s4[1], '\0'); | |||
| lolunit_assert_equal(s4.Count(), 1); | |||
| lolunit_assert_equal(s4[0], 'a'); | |||
| lolunit_assert_equal(s4[1], '\0'); | |||
| } | |||
| LOLUNIT_TEST(StringAppendChar) | |||
| lolunit_declare_test(StringAppendChar) | |||
| { | |||
| String s; | |||
| s += 'a'; | |||
| s += 'b'; | |||
| s += 'c'; | |||
| LOLUNIT_ASSERT_EQUAL(s[0], 'a'); | |||
| LOLUNIT_ASSERT_EQUAL(s[1], 'b'); | |||
| LOLUNIT_ASSERT_EQUAL(s[2], 'c'); | |||
| LOLUNIT_ASSERT_EQUAL(s[3], '\0'); | |||
| lolunit_assert_equal(s[0], 'a'); | |||
| lolunit_assert_equal(s[1], 'b'); | |||
| lolunit_assert_equal(s[2], 'c'); | |||
| lolunit_assert_equal(s[3], '\0'); | |||
| } | |||
| LOLUNIT_TEST(StringCopy) | |||
| lolunit_declare_test(StringCopy) | |||
| { | |||
| String s1 = "abc"; | |||
| String s2 = s1; | |||
| LOLUNIT_ASSERT_EQUAL(s1[0], s2[0]); | |||
| LOLUNIT_ASSERT_EQUAL(s1[1], s2[1]); | |||
| LOLUNIT_ASSERT_EQUAL(s1[2], s2[2]); | |||
| LOLUNIT_ASSERT_EQUAL(s1[3], s2[3]); | |||
| lolunit_assert_equal(s1[0], s2[0]); | |||
| lolunit_assert_equal(s1[1], s2[1]); | |||
| lolunit_assert_equal(s1[2], s2[2]); | |||
| lolunit_assert_equal(s1[3], s2[3]); | |||
| } | |||
| LOLUNIT_TEST(StringConcat) | |||
| lolunit_declare_test(StringConcat) | |||
| { | |||
| String s1("ab"), s2("cd"); | |||
| String s3 = s1 + s2; | |||
| LOLUNIT_ASSERT_EQUAL(s3[0], 'a'); | |||
| LOLUNIT_ASSERT_EQUAL(s3[1], 'b'); | |||
| LOLUNIT_ASSERT_EQUAL(s3[2], 'c'); | |||
| LOLUNIT_ASSERT_EQUAL(s3[3], 'd'); | |||
| LOLUNIT_ASSERT_EQUAL(s3[4], '\0'); | |||
| lolunit_assert_equal(s3[0], 'a'); | |||
| lolunit_assert_equal(s3[1], 'b'); | |||
| lolunit_assert_equal(s3[2], 'c'); | |||
| lolunit_assert_equal(s3[3], 'd'); | |||
| lolunit_assert_equal(s3[4], '\0'); | |||
| } | |||
| LOLUNIT_TEST(StringAppendString) | |||
| lolunit_declare_test(StringAppendString) | |||
| { | |||
| String s1("ab"), s2("cd"); | |||
| s1 += s2; | |||
| LOLUNIT_ASSERT_EQUAL(s1.Count(), 4); | |||
| LOLUNIT_ASSERT_EQUAL(s1[0], 'a'); | |||
| LOLUNIT_ASSERT_EQUAL(s1[1], 'b'); | |||
| LOLUNIT_ASSERT_EQUAL(s1[2], 'c'); | |||
| LOLUNIT_ASSERT_EQUAL(s1[3], 'd'); | |||
| LOLUNIT_ASSERT_EQUAL(s1[4], '\0'); | |||
| lolunit_assert_equal(s1.Count(), 4); | |||
| lolunit_assert_equal(s1[0], 'a'); | |||
| lolunit_assert_equal(s1[1], 'b'); | |||
| lolunit_assert_equal(s1[2], 'c'); | |||
| lolunit_assert_equal(s1[3], 'd'); | |||
| lolunit_assert_equal(s1[4], '\0'); | |||
| s2 += s2; | |||
| LOLUNIT_ASSERT_EQUAL(s2.Count(), 4); | |||
| LOLUNIT_ASSERT_EQUAL(s2[0], 'c'); | |||
| LOLUNIT_ASSERT_EQUAL(s2[1], 'd'); | |||
| LOLUNIT_ASSERT_EQUAL(s2[2], 'c'); | |||
| LOLUNIT_ASSERT_EQUAL(s2[3], 'd'); | |||
| LOLUNIT_ASSERT_EQUAL(s2[4], '\0'); | |||
| lolunit_assert_equal(s2.Count(), 4); | |||
| lolunit_assert_equal(s2[0], 'c'); | |||
| lolunit_assert_equal(s2[1], 'd'); | |||
| lolunit_assert_equal(s2[2], 'c'); | |||
| lolunit_assert_equal(s2[3], 'd'); | |||
| lolunit_assert_equal(s2[4], '\0'); | |||
| } | |||
| LOLUNIT_TEST(StringEqual) | |||
| lolunit_declare_test(StringEqual) | |||
| { | |||
| String s1("abc"); | |||
| String s2("abc"); | |||
| String s3("ab"); | |||
| LOLUNIT_ASSERT(s1 == s2); | |||
| LOLUNIT_ASSERT(!(s1 == s3)); | |||
| lolunit_assert(s1 == s2); | |||
| lolunit_assert(!(s1 == s3)); | |||
| } | |||
| LOLUNIT_TEST(StringDifferent) | |||
| lolunit_declare_test(StringDifferent) | |||
| { | |||
| String s1("abc"); | |||
| String s2("ab"); | |||
| String s3("abc"); | |||
| LOLUNIT_ASSERT(s1 != s2); | |||
| LOLUNIT_ASSERT(!(s1 != s3)); | |||
| lolunit_assert(s1 != s2); | |||
| lolunit_assert(!(s1 != s3)); | |||
| } | |||
| LOLUNIT_TEST(StringCharsEqual) | |||
| lolunit_declare_test(StringCharsEqual) | |||
| { | |||
| char const* sz = "abc"; | |||
| String s1("abc"); | |||
| String s2("ab"); | |||
| LOLUNIT_ASSERT(s1 == sz); | |||
| LOLUNIT_ASSERT(sz == s1); | |||
| LOLUNIT_ASSERT(!(s2 == sz)); | |||
| LOLUNIT_ASSERT(!(sz == s2)); | |||
| lolunit_assert(s1 == sz); | |||
| lolunit_assert(sz == s1); | |||
| lolunit_assert(!(s2 == sz)); | |||
| lolunit_assert(!(sz == s2)); | |||
| } | |||
| LOLUNIT_TEST(StringCharsDifferent) | |||
| lolunit_declare_test(StringCharsDifferent) | |||
| { | |||
| char const* sz = "abc"; | |||
| String s1("ab"); | |||
| String s2("abc"); | |||
| LOLUNIT_ASSERT(s1 != sz); | |||
| LOLUNIT_ASSERT(sz != s1); | |||
| LOLUNIT_ASSERT(!(s2 != sz)); | |||
| LOLUNIT_ASSERT(!(sz != s2)); | |||
| lolunit_assert(s1 != sz); | |||
| lolunit_assert(sz != s1); | |||
| lolunit_assert(!(s2 != sz)); | |||
| lolunit_assert(!(sz != s2)); | |||
| } | |||
| LOLUNIT_TEST(StringPrintf) | |||
| lolunit_declare_test(StringPrintf) | |||
| { | |||
| String s1 = "3a"; | |||
| String s2 = String::Printf("%d%x", 3, 10); | |||
| LOLUNIT_ASSERT(s1 == s2); | |||
| lolunit_assert(s1 == s2); | |||
| String s3 = "abc 3"; | |||
| String s4 = String::Printf("abc %d", 3); | |||
| LOLUNIT_ASSERT(s3 == s4); | |||
| lolunit_assert(s3 == s4); | |||
| } | |||
| LOLUNIT_TEST(SubString) | |||
| lolunit_declare_test(SubString) | |||
| { | |||
| String s1 = "Hello World"; | |||
| String s2 = s1.Sub(0, 5); | |||
| String s3 = "Hello"; | |||
| LOLUNIT_ASSERT(s2 == s3); | |||
| lolunit_assert(s2 == s3); | |||
| String s4 = s1.Sub(6, 5); | |||
| String s5 = "World"; | |||
| LOLUNIT_ASSERT(s4 == s5); | |||
| lolunit_assert(s4 == s5); | |||
| } | |||
| LOLUNIT_TEST(IndexOf) | |||
| lolunit_declare_test(IndexOf) | |||
| { | |||
| String s1 = "Hello World"; | |||
| ptrdiff_t i1 = s1.IndexOf('H'); | |||
| @@ -186,17 +186,17 @@ LOLUNIT_FIXTURE(StringTest) | |||
| ptrdiff_t i7 = s1.IndexOf("Hello World"); | |||
| ptrdiff_t i8 = s1.IndexOf("Sup' dude"); | |||
| LOLUNIT_ASSERT(i1 == 0); | |||
| LOLUNIT_ASSERT(i2 == 6); | |||
| LOLUNIT_ASSERT(i3 == 10); | |||
| LOLUNIT_ASSERT(i4 == i1); | |||
| LOLUNIT_ASSERT(i5 == i2); | |||
| LOLUNIT_ASSERT(i6 == 3); | |||
| LOLUNIT_ASSERT(i7 == 0); | |||
| LOLUNIT_ASSERT(i8 == -1); | |||
| lolunit_assert(i1 == 0); | |||
| lolunit_assert(i2 == 6); | |||
| lolunit_assert(i3 == 10); | |||
| lolunit_assert(i4 == i1); | |||
| lolunit_assert(i5 == i2); | |||
| lolunit_assert(i6 == 3); | |||
| lolunit_assert(i7 == 0); | |||
| lolunit_assert(i8 == -1); | |||
| } | |||
| LOLUNIT_TEST(LastIndexOf) | |||
| lolunit_declare_test(LastIndexOf) | |||
| { | |||
| String s1 = "Hello World"; | |||
| ptrdiff_t i1 = s1.LastIndexOf('H'); | |||
| @@ -209,26 +209,26 @@ LOLUNIT_FIXTURE(StringTest) | |||
| ptrdiff_t i8 = s1.LastIndexOf("Sup' dude"); | |||
| ptrdiff_t i9 = s1.LastIndexOf('l'); | |||
| LOLUNIT_ASSERT(i1 == 0); | |||
| LOLUNIT_ASSERT(i2 == 6); | |||
| LOLUNIT_ASSERT(i3 == 10); | |||
| LOLUNIT_ASSERT(i4 == i1); | |||
| LOLUNIT_ASSERT(i5 == i2); | |||
| LOLUNIT_ASSERT(i6 == 3); | |||
| LOLUNIT_ASSERT(i7 == 0); | |||
| LOLUNIT_ASSERT(i8 == -1); | |||
| LOLUNIT_ASSERT(i9 == 9); | |||
| lolunit_assert(i1 == 0); | |||
| lolunit_assert(i2 == 6); | |||
| lolunit_assert(i3 == 10); | |||
| lolunit_assert(i4 == i1); | |||
| lolunit_assert(i5 == i2); | |||
| lolunit_assert(i6 == 3); | |||
| lolunit_assert(i7 == 0); | |||
| lolunit_assert(i8 == -1); | |||
| lolunit_assert(i9 == 9); | |||
| } | |||
| LOLUNIT_TEST(StartsEndsWith) | |||
| lolunit_declare_test(StartsEndsWith) | |||
| { | |||
| String s = "lolilol"; | |||
| LOLUNIT_ASSERT(s.StartsWith("loli")); | |||
| LOLUNIT_ASSERT(!s.StartsWith("lolo")); | |||
| LOLUNIT_ASSERT(!s.StartsWith("lolilolilol")); | |||
| LOLUNIT_ASSERT(s.EndsWith("ilol")); | |||
| LOLUNIT_ASSERT(!s.EndsWith("olol")); | |||
| LOLUNIT_ASSERT(!s.EndsWith("lolilolilol")); | |||
| lolunit_assert(s.StartsWith("loli")); | |||
| lolunit_assert(!s.StartsWith("lolo")); | |||
| lolunit_assert(!s.StartsWith("lolilolilol")); | |||
| lolunit_assert(s.EndsWith("ilol")); | |||
| lolunit_assert(!s.EndsWith("olol")); | |||
| lolunit_assert(!s.EndsWith("lolilolilol")); | |||
| } | |||
| }; | |||
| @@ -18,91 +18,91 @@ | |||
| namespace lol | |||
| { | |||
| LOLUNIT_FIXTURE(BuildTest) | |||
| lolunit_declare_fixture(BuildTest) | |||
| { | |||
| LOLUNIT_TEST(TypeSizeHalf) | |||
| lolunit_declare_test(TypeSizeHalf) | |||
| { | |||
| LOLUNIT_ASSERT_EQUAL(sizeof(half), 2); | |||
| lolunit_assert_equal(sizeof(half), 2); | |||
| #if LOL_FEATURE_CXX11_UNRESTRICTED_UNIONS | |||
| LOLUNIT_ASSERT_EQUAL(sizeof(f16vec2), 4); | |||
| LOLUNIT_ASSERT_EQUAL(sizeof(f16vec3), 6); | |||
| LOLUNIT_ASSERT_EQUAL(sizeof(f16vec4), 8); | |||
| lolunit_assert_equal(sizeof(f16vec2), 4); | |||
| lolunit_assert_equal(sizeof(f16vec3), 6); | |||
| lolunit_assert_equal(sizeof(f16vec4), 8); | |||
| LOLUNIT_ASSERT_EQUAL(sizeof(f16mat2), 8); | |||
| LOLUNIT_ASSERT_EQUAL(sizeof(f16mat3), 18); | |||
| LOLUNIT_ASSERT_EQUAL(sizeof(f16mat4), 32); | |||
| lolunit_assert_equal(sizeof(f16mat2), 8); | |||
| lolunit_assert_equal(sizeof(f16mat3), 18); | |||
| lolunit_assert_equal(sizeof(f16mat4), 32); | |||
| #endif | |||
| } | |||
| LOLUNIT_TEST(TypeSizeFloat) | |||
| lolunit_declare_test(TypeSizeFloat) | |||
| { | |||
| LOLUNIT_ASSERT_EQUAL(sizeof(float), 4); | |||
| lolunit_assert_equal(sizeof(float), 4); | |||
| LOLUNIT_ASSERT_EQUAL(sizeof(vec2), 8); | |||
| LOLUNIT_ASSERT_EQUAL(sizeof(vec3), 12); | |||
| LOLUNIT_ASSERT_EQUAL(sizeof(vec4), 16); | |||
| lolunit_assert_equal(sizeof(vec2), 8); | |||
| lolunit_assert_equal(sizeof(vec3), 12); | |||
| lolunit_assert_equal(sizeof(vec4), 16); | |||
| LOLUNIT_ASSERT_EQUAL(sizeof(mat2), 16); | |||
| LOLUNIT_ASSERT_EQUAL(sizeof(mat3), 36); | |||
| LOLUNIT_ASSERT_EQUAL(sizeof(mat4), 64); | |||
| lolunit_assert_equal(sizeof(mat2), 16); | |||
| lolunit_assert_equal(sizeof(mat3), 36); | |||
| lolunit_assert_equal(sizeof(mat4), 64); | |||
| } | |||
| LOLUNIT_TEST(TypeSizeDouble) | |||
| lolunit_declare_test(TypeSizeDouble) | |||
| { | |||
| LOLUNIT_ASSERT_EQUAL(sizeof(double), 8); | |||
| lolunit_assert_equal(sizeof(double), 8); | |||
| LOLUNIT_ASSERT_EQUAL(sizeof(dvec2), 16); | |||
| LOLUNIT_ASSERT_EQUAL(sizeof(dvec3), 24); | |||
| LOLUNIT_ASSERT_EQUAL(sizeof(dvec4), 32); | |||
| lolunit_assert_equal(sizeof(dvec2), 16); | |||
| lolunit_assert_equal(sizeof(dvec3), 24); | |||
| lolunit_assert_equal(sizeof(dvec4), 32); | |||
| LOLUNIT_ASSERT_EQUAL(sizeof(dmat2), 32); | |||
| LOLUNIT_ASSERT_EQUAL(sizeof(dmat3), 72); | |||
| LOLUNIT_ASSERT_EQUAL(sizeof(dmat4), 128); | |||
| lolunit_assert_equal(sizeof(dmat2), 32); | |||
| lolunit_assert_equal(sizeof(dmat3), 72); | |||
| lolunit_assert_equal(sizeof(dmat4), 128); | |||
| } | |||
| LOLUNIT_TEST(TypeSizeInt8) | |||
| lolunit_declare_test(TypeSizeInt8) | |||
| { | |||
| LOLUNIT_ASSERT_EQUAL(sizeof(i8vec2), 2); | |||
| LOLUNIT_ASSERT_EQUAL(sizeof(u8vec2), 2); | |||
| LOLUNIT_ASSERT_EQUAL(sizeof(i8vec3), 3); | |||
| LOLUNIT_ASSERT_EQUAL(sizeof(u8vec3), 3); | |||
| LOLUNIT_ASSERT_EQUAL(sizeof(i8vec4), 4); | |||
| LOLUNIT_ASSERT_EQUAL(sizeof(u8vec4), 4); | |||
| lolunit_assert_equal(sizeof(i8vec2), 2); | |||
| lolunit_assert_equal(sizeof(u8vec2), 2); | |||
| lolunit_assert_equal(sizeof(i8vec3), 3); | |||
| lolunit_assert_equal(sizeof(u8vec3), 3); | |||
| lolunit_assert_equal(sizeof(i8vec4), 4); | |||
| lolunit_assert_equal(sizeof(u8vec4), 4); | |||
| } | |||
| LOLUNIT_TEST(TypeSizeInt16) | |||
| lolunit_declare_test(TypeSizeInt16) | |||
| { | |||
| LOLUNIT_ASSERT_EQUAL(sizeof(i16vec2), 4); | |||
| LOLUNIT_ASSERT_EQUAL(sizeof(u16vec2), 4); | |||
| LOLUNIT_ASSERT_EQUAL(sizeof(i16vec3), 6); | |||
| LOLUNIT_ASSERT_EQUAL(sizeof(u16vec3), 6); | |||
| LOLUNIT_ASSERT_EQUAL(sizeof(i16vec4), 8); | |||
| LOLUNIT_ASSERT_EQUAL(sizeof(u16vec4), 8); | |||
| lolunit_assert_equal(sizeof(i16vec2), 4); | |||
| lolunit_assert_equal(sizeof(u16vec2), 4); | |||
| lolunit_assert_equal(sizeof(i16vec3), 6); | |||
| lolunit_assert_equal(sizeof(u16vec3), 6); | |||
| lolunit_assert_equal(sizeof(i16vec4), 8); | |||
| lolunit_assert_equal(sizeof(u16vec4), 8); | |||
| } | |||
| LOLUNIT_TEST(TypeSizeInt32) | |||
| lolunit_declare_test(TypeSizeInt32) | |||
| { | |||
| LOLUNIT_ASSERT_EQUAL(sizeof(ivec2), 8); | |||
| LOLUNIT_ASSERT_EQUAL(sizeof(uvec2), 8); | |||
| LOLUNIT_ASSERT_EQUAL(sizeof(ivec3), 12); | |||
| LOLUNIT_ASSERT_EQUAL(sizeof(uvec3), 12); | |||
| LOLUNIT_ASSERT_EQUAL(sizeof(ivec4), 16); | |||
| LOLUNIT_ASSERT_EQUAL(sizeof(uvec4), 16); | |||
| lolunit_assert_equal(sizeof(ivec2), 8); | |||
| lolunit_assert_equal(sizeof(uvec2), 8); | |||
| lolunit_assert_equal(sizeof(ivec3), 12); | |||
| lolunit_assert_equal(sizeof(uvec3), 12); | |||
| lolunit_assert_equal(sizeof(ivec4), 16); | |||
| lolunit_assert_equal(sizeof(uvec4), 16); | |||
| } | |||
| LOLUNIT_TEST(TypeSizeInt64) | |||
| lolunit_declare_test(TypeSizeInt64) | |||
| { | |||
| LOLUNIT_ASSERT_EQUAL(sizeof(i64vec2), 16); | |||
| LOLUNIT_ASSERT_EQUAL(sizeof(u64vec2), 16); | |||
| LOLUNIT_ASSERT_EQUAL(sizeof(i64vec3), 24); | |||
| LOLUNIT_ASSERT_EQUAL(sizeof(u64vec3), 24); | |||
| LOLUNIT_ASSERT_EQUAL(sizeof(i64vec4), 32); | |||
| LOLUNIT_ASSERT_EQUAL(sizeof(u64vec4), 32); | |||
| lolunit_assert_equal(sizeof(i64vec2), 16); | |||
| lolunit_assert_equal(sizeof(u64vec2), 16); | |||
| lolunit_assert_equal(sizeof(i64vec3), 24); | |||
| lolunit_assert_equal(sizeof(u64vec3), 24); | |||
| lolunit_assert_equal(sizeof(i64vec4), 32); | |||
| lolunit_assert_equal(sizeof(u64vec4), 32); | |||
| } | |||
| #if !defined LOL_BUILD_DEBUG | |||
| LOLUNIT_TEST(FastMath) | |||
| lolunit_declare_test(FastMath) | |||
| { | |||
| double x, y; | |||
| @@ -111,7 +111,7 @@ LOLUNIT_FIXTURE(BuildTest) | |||
| /* The compiler should optimise this away */ | |||
| y -= 4503599627370496.0; | |||
| LOLUNIT_ASSERT_EQUAL(x, y); | |||
| lolunit_assert_equal(x, y); | |||
| } | |||
| #endif | |||
| }; | |||
| @@ -19,7 +19,7 @@ | |||
| namespace lol | |||
| { | |||
| LOLUNIT_FIXTURE(CameraTest) | |||
| lolunit_declare_fixture(CameraTest) | |||
| { | |||
| Camera tc; | |||
| vec3 eye; | |||
| @@ -54,11 +54,11 @@ LOLUNIT_FIXTURE(CameraTest) | |||
| void TearDown() {} | |||
| #define TEST_VECTOR(v0, v1) \ | |||
| LOLUNIT_ASSERT_DOUBLES_EQUAL(v0.x, v1.x, 1.e-5f); \ | |||
| LOLUNIT_ASSERT_DOUBLES_EQUAL(v0.y, v1.y, 1.e-5f); \ | |||
| LOLUNIT_ASSERT_DOUBLES_EQUAL(v0.z, v1.z, 1.e-5f); | |||
| lolunit_assert_doubles_equal(v0.x, v1.x, 1.e-5f); \ | |||
| lolunit_assert_doubles_equal(v0.y, v1.y, 1.e-5f); \ | |||
| lolunit_assert_doubles_equal(v0.z, v1.z, 1.e-5f); | |||
| LOLUNIT_TEST(SetViewTest) | |||
| lolunit_declare_test(SetViewTest) | |||
| { | |||
| tc.SetView(eye, target, up); | |||
| TEST_VECTOR(eye, tc.GetPosition()); | |||
| @@ -85,108 +85,108 @@ LOLUNIT_FIXTURE(CameraTest) | |||
| } | |||
| #define TEST_MATRIX(m0, m1) \ | |||
| LOLUNIT_ASSERT_DOUBLES_EQUAL(m0[0][0], m1[0][0], 1.e-5f); \ | |||
| LOLUNIT_ASSERT_DOUBLES_EQUAL(m0[1][0], m1[1][0], 1.e-5f); \ | |||
| LOLUNIT_ASSERT_DOUBLES_EQUAL(m0[2][0], m1[2][0], 1.e-5f); \ | |||
| LOLUNIT_ASSERT_DOUBLES_EQUAL(m0[3][0], m1[3][0], 1.e-5f); \ | |||
| lolunit_assert_doubles_equal(m0[0][0], m1[0][0], 1.e-5f); \ | |||
| lolunit_assert_doubles_equal(m0[1][0], m1[1][0], 1.e-5f); \ | |||
| lolunit_assert_doubles_equal(m0[2][0], m1[2][0], 1.e-5f); \ | |||
| lolunit_assert_doubles_equal(m0[3][0], m1[3][0], 1.e-5f); \ | |||
| \ | |||
| LOLUNIT_ASSERT_DOUBLES_EQUAL(m0[0][1], m1[0][1], 1.e-5f); \ | |||
| LOLUNIT_ASSERT_DOUBLES_EQUAL(m0[1][1], m1[1][1], 1.e-5f); \ | |||
| LOLUNIT_ASSERT_DOUBLES_EQUAL(m0[2][1], m1[2][1], 1.e-5f); \ | |||
| LOLUNIT_ASSERT_DOUBLES_EQUAL(m0[3][1], m1[3][1], 1.e-5f); \ | |||
| lolunit_assert_doubles_equal(m0[0][1], m1[0][1], 1.e-5f); \ | |||
| lolunit_assert_doubles_equal(m0[1][1], m1[1][1], 1.e-5f); \ | |||
| lolunit_assert_doubles_equal(m0[2][1], m1[2][1], 1.e-5f); \ | |||
| lolunit_assert_doubles_equal(m0[3][1], m1[3][1], 1.e-5f); \ | |||
| \ | |||
| LOLUNIT_ASSERT_DOUBLES_EQUAL(m0[0][2], m1[0][2], 1.e-5f); \ | |||
| LOLUNIT_ASSERT_DOUBLES_EQUAL(m0[1][2], m1[1][2], 1.e-5f); \ | |||
| LOLUNIT_ASSERT_DOUBLES_EQUAL(m0[2][2], m1[2][2], 1.e-5f); \ | |||
| LOLUNIT_ASSERT_DOUBLES_EQUAL(m0[3][2], m1[3][2], 1.e-5f); \ | |||
| lolunit_assert_doubles_equal(m0[0][2], m1[0][2], 1.e-5f); \ | |||
| lolunit_assert_doubles_equal(m0[1][2], m1[1][2], 1.e-5f); \ | |||
| lolunit_assert_doubles_equal(m0[2][2], m1[2][2], 1.e-5f); \ | |||
| lolunit_assert_doubles_equal(m0[3][2], m1[3][2], 1.e-5f); \ | |||
| \ | |||
| LOLUNIT_ASSERT_DOUBLES_EQUAL(m0[0][3], m1[0][3], 1.e-5f); \ | |||
| LOLUNIT_ASSERT_DOUBLES_EQUAL(m0[1][3], m1[1][3], 1.e-5f); \ | |||
| LOLUNIT_ASSERT_DOUBLES_EQUAL(m0[2][3], m1[2][3], 1.e-5f); \ | |||
| LOLUNIT_ASSERT_DOUBLES_EQUAL(m0[3][3], m1[3][3], 1.e-5f); | |||
| lolunit_assert_doubles_equal(m0[0][3], m1[0][3], 1.e-5f); \ | |||
| lolunit_assert_doubles_equal(m0[1][3], m1[1][3], 1.e-5f); \ | |||
| lolunit_assert_doubles_equal(m0[2][3], m1[2][3], 1.e-5f); \ | |||
| lolunit_assert_doubles_equal(m0[3][3], m1[3][3], 1.e-5f); | |||
| LOLUNIT_TEST(SetProjectionTest) | |||
| lolunit_declare_test(SetProjectionTest) | |||
| { | |||
| mat4 refmx = mat4::perspective(fov, screen_size, screen_size * screen_ratio, near, far); | |||
| tc.SetProjection(fov, near, far, screen_size, screen_ratio); | |||
| TEST_MATRIX(refmx, tc.GetProjection()); | |||
| LOLUNIT_ASSERT_DOUBLES_EQUAL(fov, tc.GetFov(), 1.e-5f); | |||
| LOLUNIT_ASSERT_DOUBLES_EQUAL(screen_size, tc.GetScreenSize(), 1.e-5f); | |||
| LOLUNIT_ASSERT_DOUBLES_EQUAL(screen_ratio, tc.GetScreenRatio(), 1.e-5f); | |||
| LOLUNIT_ASSERT_DOUBLES_EQUAL(near, tc.GetNear(), 1.e-5f); | |||
| LOLUNIT_ASSERT_DOUBLES_EQUAL(far, tc.GetFar(), 1.e-5f); | |||
| LOLUNIT_ASSERT(is_shifted == tc.IsShifted()); | |||
| lolunit_assert_doubles_equal(fov, tc.GetFov(), 1.e-5f); | |||
| lolunit_assert_doubles_equal(screen_size, tc.GetScreenSize(), 1.e-5f); | |||
| lolunit_assert_doubles_equal(screen_ratio, tc.GetScreenRatio(), 1.e-5f); | |||
| lolunit_assert_doubles_equal(near, tc.GetNear(), 1.e-5f); | |||
| lolunit_assert_doubles_equal(far, tc.GetFar(), 1.e-5f); | |||
| lolunit_assert(is_shifted == tc.IsShifted()); | |||
| tc.SetProjection(fov, near, far); | |||
| TEST_MATRIX(refmx, tc.GetProjection()); | |||
| LOLUNIT_ASSERT_DOUBLES_EQUAL(fov, tc.GetFov(), 1.e-5f); | |||
| LOLUNIT_ASSERT_DOUBLES_EQUAL(screen_size, tc.GetScreenSize(), 1.e-5f); | |||
| LOLUNIT_ASSERT_DOUBLES_EQUAL(screen_ratio, tc.GetScreenRatio(), 1.e-5f); | |||
| LOLUNIT_ASSERT_DOUBLES_EQUAL(near, tc.GetNear(), 1.e-5f); | |||
| LOLUNIT_ASSERT_DOUBLES_EQUAL(far, tc.GetFar(), 1.e-5f); | |||
| LOLUNIT_ASSERT(is_shifted == tc.IsShifted()); | |||
| lolunit_assert_doubles_equal(fov, tc.GetFov(), 1.e-5f); | |||
| lolunit_assert_doubles_equal(screen_size, tc.GetScreenSize(), 1.e-5f); | |||
| lolunit_assert_doubles_equal(screen_ratio, tc.GetScreenRatio(), 1.e-5f); | |||
| lolunit_assert_doubles_equal(near, tc.GetNear(), 1.e-5f); | |||
| lolunit_assert_doubles_equal(far, tc.GetFar(), 1.e-5f); | |||
| lolunit_assert(is_shifted == tc.IsShifted()); | |||
| tc.SetProjection(refmx); | |||
| TEST_MATRIX(refmx, tc.GetProjection()); | |||
| tc.SetFov(fov); | |||
| TEST_MATRIX(refmx, tc.GetProjection()); | |||
| LOLUNIT_ASSERT_DOUBLES_EQUAL(fov, tc.GetFov(), 1.e-5f); | |||
| LOLUNIT_ASSERT_DOUBLES_EQUAL(screen_size, tc.GetScreenSize(), 1.e-5f); | |||
| LOLUNIT_ASSERT_DOUBLES_EQUAL(screen_ratio, tc.GetScreenRatio(), 1.e-5f); | |||
| LOLUNIT_ASSERT_DOUBLES_EQUAL(near, tc.GetNear(), 1.e-5f); | |||
| LOLUNIT_ASSERT_DOUBLES_EQUAL(far, tc.GetFar(), 1.e-5f); | |||
| LOLUNIT_ASSERT(is_shifted == tc.IsShifted()); | |||
| lolunit_assert_doubles_equal(fov, tc.GetFov(), 1.e-5f); | |||
| lolunit_assert_doubles_equal(screen_size, tc.GetScreenSize(), 1.e-5f); | |||
| lolunit_assert_doubles_equal(screen_ratio, tc.GetScreenRatio(), 1.e-5f); | |||
| lolunit_assert_doubles_equal(near, tc.GetNear(), 1.e-5f); | |||
| lolunit_assert_doubles_equal(far, tc.GetFar(), 1.e-5f); | |||
| lolunit_assert(is_shifted == tc.IsShifted()); | |||
| tc.SetScreenInfos(screen_size); | |||
| TEST_MATRIX(refmx, tc.GetProjection()); | |||
| LOLUNIT_ASSERT_DOUBLES_EQUAL(fov, tc.GetFov(), 1.e-5f); | |||
| LOLUNIT_ASSERT_DOUBLES_EQUAL(screen_size, tc.GetScreenSize(), 1.e-5f); | |||
| LOLUNIT_ASSERT_DOUBLES_EQUAL(screen_ratio, tc.GetScreenRatio(), 1.e-5f); | |||
| LOLUNIT_ASSERT_DOUBLES_EQUAL(near, tc.GetNear(), 1.e-5f); | |||
| LOLUNIT_ASSERT_DOUBLES_EQUAL(far, tc.GetFar(), 1.e-5f); | |||
| LOLUNIT_ASSERT(is_shifted == tc.IsShifted()); | |||
| lolunit_assert_doubles_equal(fov, tc.GetFov(), 1.e-5f); | |||
| lolunit_assert_doubles_equal(screen_size, tc.GetScreenSize(), 1.e-5f); | |||
| lolunit_assert_doubles_equal(screen_ratio, tc.GetScreenRatio(), 1.e-5f); | |||
| lolunit_assert_doubles_equal(near, tc.GetNear(), 1.e-5f); | |||
| lolunit_assert_doubles_equal(far, tc.GetFar(), 1.e-5f); | |||
| lolunit_assert(is_shifted == tc.IsShifted()); | |||
| tc.SetScreenInfos(screen_size, screen_ratio); | |||
| TEST_MATRIX(refmx, tc.GetProjection()); | |||
| LOLUNIT_ASSERT_DOUBLES_EQUAL(fov, tc.GetFov(), 1.e-5f); | |||
| LOLUNIT_ASSERT_DOUBLES_EQUAL(screen_size, tc.GetScreenSize(), 1.e-5f); | |||
| LOLUNIT_ASSERT_DOUBLES_EQUAL(screen_ratio, tc.GetScreenRatio(), 1.e-5f); | |||
| LOLUNIT_ASSERT_DOUBLES_EQUAL(near, tc.GetNear(), 1.e-5f); | |||
| LOLUNIT_ASSERT_DOUBLES_EQUAL(far, tc.GetFar(), 1.e-5f); | |||
| LOLUNIT_ASSERT(is_shifted == tc.IsShifted()); | |||
| lolunit_assert_doubles_equal(fov, tc.GetFov(), 1.e-5f); | |||
| lolunit_assert_doubles_equal(screen_size, tc.GetScreenSize(), 1.e-5f); | |||
| lolunit_assert_doubles_equal(screen_ratio, tc.GetScreenRatio(), 1.e-5f); | |||
| lolunit_assert_doubles_equal(near, tc.GetNear(), 1.e-5f); | |||
| lolunit_assert_doubles_equal(far, tc.GetFar(), 1.e-5f); | |||
| lolunit_assert(is_shifted == tc.IsShifted()); | |||
| tc.SetDrawInfos(far); | |||
| TEST_MATRIX(refmx, tc.GetProjection()); | |||
| LOLUNIT_ASSERT_DOUBLES_EQUAL(fov, tc.GetFov(), 1.e-5f); | |||
| LOLUNIT_ASSERT_DOUBLES_EQUAL(screen_size, tc.GetScreenSize(), 1.e-5f); | |||
| LOLUNIT_ASSERT_DOUBLES_EQUAL(screen_ratio, tc.GetScreenRatio(), 1.e-5f); | |||
| LOLUNIT_ASSERT_DOUBLES_EQUAL(near, tc.GetNear(), 1.e-5f); | |||
| LOLUNIT_ASSERT_DOUBLES_EQUAL(far, tc.GetFar(), 1.e-5f); | |||
| LOLUNIT_ASSERT(is_shifted == tc.IsShifted()); | |||
| lolunit_assert_doubles_equal(fov, tc.GetFov(), 1.e-5f); | |||
| lolunit_assert_doubles_equal(screen_size, tc.GetScreenSize(), 1.e-5f); | |||
| lolunit_assert_doubles_equal(screen_ratio, tc.GetScreenRatio(), 1.e-5f); | |||
| lolunit_assert_doubles_equal(near, tc.GetNear(), 1.e-5f); | |||
| lolunit_assert_doubles_equal(far, tc.GetFar(), 1.e-5f); | |||
| lolunit_assert(is_shifted == tc.IsShifted()); | |||
| tc.SetDrawInfos(near, far); | |||
| TEST_MATRIX(refmx, tc.GetProjection()); | |||
| LOLUNIT_ASSERT_DOUBLES_EQUAL(fov, tc.GetFov(), 1.e-5f); | |||
| LOLUNIT_ASSERT_DOUBLES_EQUAL(screen_size, tc.GetScreenSize(), 1.e-5f); | |||
| LOLUNIT_ASSERT_DOUBLES_EQUAL(screen_ratio, tc.GetScreenRatio(), 1.e-5f); | |||
| LOLUNIT_ASSERT_DOUBLES_EQUAL(near, tc.GetNear(), 1.e-5f); | |||
| LOLUNIT_ASSERT_DOUBLES_EQUAL(far, tc.GetFar(), 1.e-5f); | |||
| LOLUNIT_ASSERT(is_shifted == tc.IsShifted()); | |||
| lolunit_assert_doubles_equal(fov, tc.GetFov(), 1.e-5f); | |||
| lolunit_assert_doubles_equal(screen_size, tc.GetScreenSize(), 1.e-5f); | |||
| lolunit_assert_doubles_equal(screen_ratio, tc.GetScreenRatio(), 1.e-5f); | |||
| lolunit_assert_doubles_equal(near, tc.GetNear(), 1.e-5f); | |||
| lolunit_assert_doubles_equal(far, tc.GetFar(), 1.e-5f); | |||
| lolunit_assert(is_shifted == tc.IsShifted()); | |||
| is_shifted = true; | |||
| refmx = mat4::shifted_perspective(fov, screen_size, screen_ratio, near, far); | |||
| tc.UseShift(is_shifted); | |||
| TEST_MATRIX(refmx, tc.GetProjection()); | |||
| LOLUNIT_ASSERT_DOUBLES_EQUAL(fov, tc.GetFov(), 1.e-5f); | |||
| LOLUNIT_ASSERT_DOUBLES_EQUAL(screen_size, tc.GetScreenSize(), 1.e-5f); | |||
| LOLUNIT_ASSERT_DOUBLES_EQUAL(screen_ratio, tc.GetScreenRatio(), 1.e-5f); | |||
| LOLUNIT_ASSERT_DOUBLES_EQUAL(near, tc.GetNear(), 1.e-5f); | |||
| LOLUNIT_ASSERT_DOUBLES_EQUAL(far, tc.GetFar(), 1.e-5f); | |||
| LOLUNIT_ASSERT(is_shifted == tc.IsShifted()); | |||
| lolunit_assert_doubles_equal(fov, tc.GetFov(), 1.e-5f); | |||
| lolunit_assert_doubles_equal(screen_size, tc.GetScreenSize(), 1.e-5f); | |||
| lolunit_assert_doubles_equal(screen_ratio, tc.GetScreenRatio(), 1.e-5f); | |||
| lolunit_assert_doubles_equal(near, tc.GetNear(), 1.e-5f); | |||
| lolunit_assert_doubles_equal(far, tc.GetFar(), 1.e-5f); | |||
| lolunit_assert(is_shifted == tc.IsShifted()); | |||
| } | |||
| }; | |||
| @@ -60,13 +60,13 @@ static float const ciede2k[] = | |||
| 2.0776f, 0.0795f, -1.1350f, 0.9033f, -0.0636f, -0.5514f, 0.9082f, | |||
| }; | |||
| LOLUNIT_FIXTURE(ColorTest) | |||
| lolunit_declare_fixture(ColorTest) | |||
| { | |||
| void SetUp() {} | |||
| void TearDown() {} | |||
| LOLUNIT_TEST(CIEDE2000) | |||
| lolunit_declare_test(CIEDE2000) | |||
| { | |||
| size_t count = sizeof(ciede2k) / sizeof(*ciede2k); | |||
| @@ -81,14 +81,14 @@ LOLUNIT_FIXTURE(ColorTest) | |||
| /* Check that our function works, and check that | |||
| * it is symmetrical. */ | |||
| LOLUNIT_SET_CONTEXT(n / 7); | |||
| LOLUNIT_ASSERT_DOUBLES_EQUAL(d1, d2, 0.0001); | |||
| LOLUNIT_ASSERT_DOUBLES_EQUAL(d2, d3, 0.0001); | |||
| LOLUNIT_UNSET_CONTEXT(n / 7); | |||
| lolunit_set_context(n / 7); | |||
| lolunit_assert_doubles_equal(d1, d2, 0.0001); | |||
| lolunit_assert_doubles_equal(d2, d3, 0.0001); | |||
| lolunit_unset_context(n / 7); | |||
| } | |||
| } | |||
| LOLUNIT_TEST(RGBToHSV) | |||
| lolunit_declare_test(RGBToHSV) | |||
| { | |||
| for (int r = 0; r < 20; r++) | |||
| for (int g = 0; g < 20; g++) | |||
| @@ -99,18 +99,18 @@ LOLUNIT_FIXTURE(ColorTest) | |||
| vec3 v3 = Color::HSVToRGB(v2); | |||
| String rgb = String::Printf("[%f %f %f]", v1.r, v1.g, v1.b); | |||
| LOLUNIT_SET_CONTEXT(&rgb[0]); | |||
| lolunit_set_context(&rgb[0]); | |||
| if (r != g || g != b) | |||
| LOLUNIT_ASSERT_DOUBLES_EQUAL(v1.r, v3.r, 0.0001); | |||
| LOLUNIT_ASSERT_DOUBLES_EQUAL(v1.g, v3.g, 0.0001); | |||
| LOLUNIT_ASSERT_DOUBLES_EQUAL(v1.b, v3.b, 0.0001); | |||
| lolunit_assert_doubles_equal(v1.r, v3.r, 0.0001); | |||
| lolunit_assert_doubles_equal(v1.g, v3.g, 0.0001); | |||
| lolunit_assert_doubles_equal(v1.b, v3.b, 0.0001); | |||
| LOLUNIT_UNSET_CONTEXT(&rgb[0]); | |||
| lolunit_unset_context(&rgb[0]); | |||
| } | |||
| } | |||
| LOLUNIT_TEST(RGBToHSL) | |||
| lolunit_declare_test(RGBToHSL) | |||
| { | |||
| for (int r = 0; r < 20; r++) | |||
| for (int g = 0; g < 20; g++) | |||
| @@ -121,17 +121,17 @@ LOLUNIT_FIXTURE(ColorTest) | |||
| vec3 v3 = Color::HSVToHSL(Color::RGBToHSV(v1)); | |||
| String rgb = String::Printf("[%f %f %f]", v1.r, v1.g, v1.b); | |||
| LOLUNIT_SET_CONTEXT(&rgb[0]); | |||
| lolunit_set_context(&rgb[0]); | |||
| /* Don’t check hue if saturation is zero. */ | |||
| if (r != g || g != b) | |||
| LOLUNIT_ASSERT_DOUBLES_EQUAL(v2.x, v3.x, 0.0001); | |||
| lolunit_assert_doubles_equal(v2.x, v3.x, 0.0001); | |||
| /* Don’t check saturation if lightness is zero. */ | |||
| if (r || g || b) | |||
| LOLUNIT_ASSERT_DOUBLES_EQUAL(v2.y, v3.y, 0.0001); | |||
| LOLUNIT_ASSERT_DOUBLES_EQUAL(v2.z, v3.z, 0.0001); | |||
| lolunit_assert_doubles_equal(v2.y, v3.y, 0.0001); | |||
| lolunit_assert_doubles_equal(v2.z, v3.z, 0.0001); | |||
| LOLUNIT_UNSET_CONTEXT(&rgb[0]); | |||
| lolunit_unset_context(&rgb[0]); | |||
| } | |||
| } | |||
| }; | |||
| @@ -20,26 +20,26 @@ | |||
| namespace lol | |||
| { | |||
| LOLUNIT_FIXTURE(ImageTest) | |||
| lolunit_declare_fixture(ImageTest) | |||
| { | |||
| LOLUNIT_TEST(OpenImage) | |||
| lolunit_declare_test(OpenImage) | |||
| { | |||
| Image image("data/gradient.png"); | |||
| ivec2 size = image.GetSize(); | |||
| LOLUNIT_ASSERT_EQUAL(size.x, 256); | |||
| LOLUNIT_ASSERT_EQUAL(size.y, 16); | |||
| lolunit_assert_equal(size.x, 256); | |||
| lolunit_assert_equal(size.y, 16); | |||
| u8vec4 *data = image.Lock<PixelFormat::RGBA_8>(); | |||
| LOLUNIT_ASSERT(data); | |||
| lolunit_assert(data); | |||
| LOLUNIT_ASSERT_EQUAL((int)data[0].r, 0x00); | |||
| LOLUNIT_ASSERT_EQUAL((int)data[0].g, 0x00); | |||
| LOLUNIT_ASSERT_EQUAL((int)data[0].b, 0x00); | |||
| lolunit_assert_equal((int)data[0].r, 0x00); | |||
| lolunit_assert_equal((int)data[0].g, 0x00); | |||
| lolunit_assert_equal((int)data[0].b, 0x00); | |||
| LOLUNIT_ASSERT_EQUAL((int)data[255].r, 0xff); | |||
| LOLUNIT_ASSERT_EQUAL((int)data[255].g, 0xff); | |||
| LOLUNIT_ASSERT_EQUAL((int)data[255].b, 0xff); | |||
| lolunit_assert_equal((int)data[255].r, 0xff); | |||
| lolunit_assert_equal((int)data[255].g, 0xff); | |||
| lolunit_assert_equal((int)data[255].b, 0xff); | |||
| image.Unlock(data); | |||
| } | |||
| @@ -18,13 +18,13 @@ | |||
| namespace lol | |||
| { | |||
| LOLUNIT_FIXTURE(Array2DTest) | |||
| lolunit_declare_fixture(Array2DTest) | |||
| { | |||
| void SetUp() {} | |||
| void TearDown() {} | |||
| LOLUNIT_TEST(Array2DCreate) | |||
| lolunit_declare_test(Array2DCreate) | |||
| { | |||
| array2d<int> a(ivec2(10, 10)); | |||
| @@ -33,42 +33,42 @@ LOLUNIT_FIXTURE(Array2DTest) | |||
| a[0][9] = 6; | |||
| a[9][9] = 8; | |||
| LOLUNIT_ASSERT_EQUAL(a[0][0], 2); | |||
| LOLUNIT_ASSERT_EQUAL(a[9][0], 4); | |||
| LOLUNIT_ASSERT_EQUAL(a[0][9], 6); | |||
| LOLUNIT_ASSERT_EQUAL(a[9][9], 8); | |||
| lolunit_assert_equal(a[0][0], 2); | |||
| lolunit_assert_equal(a[9][0], 4); | |||
| lolunit_assert_equal(a[0][9], 6); | |||
| lolunit_assert_equal(a[9][9], 8); | |||
| array2d<int> const &b = a; | |||
| LOLUNIT_ASSERT_EQUAL(b[0][0], 2); | |||
| LOLUNIT_ASSERT_EQUAL(b[9][0], 4); | |||
| LOLUNIT_ASSERT_EQUAL(b[0][9], 6); | |||
| LOLUNIT_ASSERT_EQUAL(b[9][9], 8); | |||
| lolunit_assert_equal(b[0][0], 2); | |||
| lolunit_assert_equal(b[9][0], 4); | |||
| lolunit_assert_equal(b[0][9], 6); | |||
| lolunit_assert_equal(b[9][9], 8); | |||
| } | |||
| LOLUNIT_TEST(Array2DInit) | |||
| lolunit_declare_test(Array2DInit) | |||
| { | |||
| array2d<int> a = { { 1, 2, 3, 4 }, | |||
| { 5, 6, 7, 8 }, | |||
| { 9, 8, 7, 6 } }; | |||
| LOLUNIT_ASSERT_EQUAL(a.GetSize().x, 4); | |||
| LOLUNIT_ASSERT_EQUAL(a.GetSize().y, 3); | |||
| lolunit_assert_equal(a.GetSize().x, 4); | |||
| lolunit_assert_equal(a.GetSize().y, 3); | |||
| LOLUNIT_ASSERT_EQUAL(a[0][0], 1); | |||
| LOLUNIT_ASSERT_EQUAL(a[1][0], 2); | |||
| LOLUNIT_ASSERT_EQUAL(a[2][0], 3); | |||
| LOLUNIT_ASSERT_EQUAL(a[3][0], 4); | |||
| lolunit_assert_equal(a[0][0], 1); | |||
| lolunit_assert_equal(a[1][0], 2); | |||
| lolunit_assert_equal(a[2][0], 3); | |||
| lolunit_assert_equal(a[3][0], 4); | |||
| LOLUNIT_ASSERT_EQUAL(a[0][1], 5); | |||
| LOLUNIT_ASSERT_EQUAL(a[1][1], 6); | |||
| LOLUNIT_ASSERT_EQUAL(a[2][1], 7); | |||
| LOLUNIT_ASSERT_EQUAL(a[3][1], 8); | |||
| lolunit_assert_equal(a[0][1], 5); | |||
| lolunit_assert_equal(a[1][1], 6); | |||
| lolunit_assert_equal(a[2][1], 7); | |||
| lolunit_assert_equal(a[3][1], 8); | |||
| LOLUNIT_ASSERT_EQUAL(a[0][2], 9); | |||
| LOLUNIT_ASSERT_EQUAL(a[1][2], 8); | |||
| LOLUNIT_ASSERT_EQUAL(a[2][2], 7); | |||
| LOLUNIT_ASSERT_EQUAL(a[3][2], 6); | |||
| lolunit_assert_equal(a[0][2], 9); | |||
| lolunit_assert_equal(a[1][2], 8); | |||
| lolunit_assert_equal(a[2][2], 7); | |||
| lolunit_assert_equal(a[3][2], 6); | |||
| } | |||
| }; | |||
| @@ -18,13 +18,13 @@ | |||
| namespace lol | |||
| { | |||
| LOLUNIT_FIXTURE(Array3DTest) | |||
| lolunit_declare_fixture(Array3DTest) | |||
| { | |||
| void SetUp() {} | |||
| void TearDown() {} | |||
| LOLUNIT_TEST(Array3DCreate) | |||
| lolunit_declare_test(Array3DCreate) | |||
| { | |||
| array3d<int> a(ivec3(10, 10, 10)); | |||
| @@ -33,20 +33,20 @@ LOLUNIT_FIXTURE(Array3DTest) | |||
| a[0][9][9] = 6; | |||
| a[9][9][9] = 8; | |||
| LOLUNIT_ASSERT_EQUAL(a[0][0][0], 2); | |||
| LOLUNIT_ASSERT_EQUAL(a[9][0][0], 4); | |||
| LOLUNIT_ASSERT_EQUAL(a[0][9][9], 6); | |||
| LOLUNIT_ASSERT_EQUAL(a[9][9][9], 8); | |||
| lolunit_assert_equal(a[0][0][0], 2); | |||
| lolunit_assert_equal(a[9][0][0], 4); | |||
| lolunit_assert_equal(a[0][9][9], 6); | |||
| lolunit_assert_equal(a[9][9][9], 8); | |||
| array3d<int> const &b = a; | |||
| LOLUNIT_ASSERT_EQUAL(b[0][0][0], 2); | |||
| LOLUNIT_ASSERT_EQUAL(b[9][0][0], 4); | |||
| LOLUNIT_ASSERT_EQUAL(b[0][9][9], 6); | |||
| LOLUNIT_ASSERT_EQUAL(b[9][9][9], 8); | |||
| lolunit_assert_equal(b[0][0][0], 2); | |||
| lolunit_assert_equal(b[9][0][0], 4); | |||
| lolunit_assert_equal(b[0][9][9], 6); | |||
| lolunit_assert_equal(b[9][9][9], 8); | |||
| } | |||
| LOLUNIT_TEST(Array3DInit) | |||
| lolunit_declare_test(Array3DInit) | |||
| { | |||
| array3d<int> a = { { { 1, 2, 3, 4 }, | |||
| { 5, 6, 7, 8 }, | |||
| @@ -55,39 +55,39 @@ LOLUNIT_FIXTURE(Array3DTest) | |||
| { -5, -6, -7, -8 }, | |||
| { -9, -8, -7, -6 } } }; | |||
| LOLUNIT_ASSERT_EQUAL(a.GetSize().x, 4); | |||
| LOLUNIT_ASSERT_EQUAL(a.GetSize().y, 3); | |||
| LOLUNIT_ASSERT_EQUAL(a.GetSize().z, 2); | |||
| LOLUNIT_ASSERT_EQUAL(a[0][0][0], 1); | |||
| LOLUNIT_ASSERT_EQUAL(a[1][0][0], 2); | |||
| LOLUNIT_ASSERT_EQUAL(a[2][0][0], 3); | |||
| LOLUNIT_ASSERT_EQUAL(a[3][0][0], 4); | |||
| LOLUNIT_ASSERT_EQUAL(a[0][1][0], 5); | |||
| LOLUNIT_ASSERT_EQUAL(a[1][1][0], 6); | |||
| LOLUNIT_ASSERT_EQUAL(a[2][1][0], 7); | |||
| LOLUNIT_ASSERT_EQUAL(a[3][1][0], 8); | |||
| LOLUNIT_ASSERT_EQUAL(a[0][2][0], 9); | |||
| LOLUNIT_ASSERT_EQUAL(a[1][2][0], 8); | |||
| LOLUNIT_ASSERT_EQUAL(a[2][2][0], 7); | |||
| LOLUNIT_ASSERT_EQUAL(a[3][2][0], 6); | |||
| LOLUNIT_ASSERT_EQUAL(a[0][0][1], -1); | |||
| LOLUNIT_ASSERT_EQUAL(a[1][0][1], -2); | |||
| LOLUNIT_ASSERT_EQUAL(a[2][0][1], -3); | |||
| LOLUNIT_ASSERT_EQUAL(a[3][0][1], -4); | |||
| LOLUNIT_ASSERT_EQUAL(a[0][1][1], -5); | |||
| LOLUNIT_ASSERT_EQUAL(a[1][1][1], -6); | |||
| LOLUNIT_ASSERT_EQUAL(a[2][1][1], -7); | |||
| LOLUNIT_ASSERT_EQUAL(a[3][1][1], -8); | |||
| LOLUNIT_ASSERT_EQUAL(a[0][2][1], -9); | |||
| LOLUNIT_ASSERT_EQUAL(a[1][2][1], -8); | |||
| LOLUNIT_ASSERT_EQUAL(a[2][2][1], -7); | |||
| LOLUNIT_ASSERT_EQUAL(a[3][2][1], -6); | |||
| lolunit_assert_equal(a.GetSize().x, 4); | |||
| lolunit_assert_equal(a.GetSize().y, 3); | |||
| lolunit_assert_equal(a.GetSize().z, 2); | |||
| lolunit_assert_equal(a[0][0][0], 1); | |||
| lolunit_assert_equal(a[1][0][0], 2); | |||
| lolunit_assert_equal(a[2][0][0], 3); | |||
| lolunit_assert_equal(a[3][0][0], 4); | |||
| lolunit_assert_equal(a[0][1][0], 5); | |||
| lolunit_assert_equal(a[1][1][0], 6); | |||
| lolunit_assert_equal(a[2][1][0], 7); | |||
| lolunit_assert_equal(a[3][1][0], 8); | |||
| lolunit_assert_equal(a[0][2][0], 9); | |||
| lolunit_assert_equal(a[1][2][0], 8); | |||
| lolunit_assert_equal(a[2][2][0], 7); | |||
| lolunit_assert_equal(a[3][2][0], 6); | |||
| lolunit_assert_equal(a[0][0][1], -1); | |||
| lolunit_assert_equal(a[1][0][1], -2); | |||
| lolunit_assert_equal(a[2][0][1], -3); | |||
| lolunit_assert_equal(a[3][0][1], -4); | |||
| lolunit_assert_equal(a[0][1][1], -5); | |||
| lolunit_assert_equal(a[1][1][1], -6); | |||
| lolunit_assert_equal(a[2][1][1], -7); | |||
| lolunit_assert_equal(a[3][1][1], -8); | |||
| lolunit_assert_equal(a[0][2][1], -9); | |||
| lolunit_assert_equal(a[1][2][1], -8); | |||
| lolunit_assert_equal(a[2][2][1], -7); | |||
| lolunit_assert_equal(a[3][2][1], -6); | |||
| } | |||
| }; | |||
| @@ -20,13 +20,13 @@ | |||
| namespace lol | |||
| { | |||
| LOLUNIT_FIXTURE(ArrayNDTest) | |||
| lolunit_declare_fixture(ArrayNDTest) | |||
| { | |||
| void SetUp() {} | |||
| void TearDown() {} | |||
| LOLUNIT_TEST(Array2D) | |||
| lolunit_declare_test(Array2D) | |||
| { | |||
| arraynd<2, int> a; | |||
| a.SetSize(vec_t<int, 2>(2, 2)); | |||
| @@ -36,20 +36,20 @@ LOLUNIT_FIXTURE(ArrayNDTest) | |||
| a[0][1] = 2; | |||
| a[1][0] = 3; | |||
| a[1][1] = 4; | |||
| LOLUNIT_ASSERT_EQUAL(a[0][0], 1); | |||
| LOLUNIT_ASSERT_EQUAL(a[0][1], 2); | |||
| LOLUNIT_ASSERT_EQUAL(a[1][0], 3); | |||
| LOLUNIT_ASSERT_EQUAL(a[1][1], 4); | |||
| lolunit_assert_equal(a[0][0], 1); | |||
| lolunit_assert_equal(a[0][1], 2); | |||
| lolunit_assert_equal(a[1][0], 3); | |||
| lolunit_assert_equal(a[1][1], 4); | |||
| /* Const accessors */ | |||
| arraynd<2, int> const &b = a; | |||
| LOLUNIT_ASSERT_EQUAL(b[0][0], 1); | |||
| LOLUNIT_ASSERT_EQUAL(b[0][1], 2); | |||
| LOLUNIT_ASSERT_EQUAL(b[1][0], 3); | |||
| LOLUNIT_ASSERT_EQUAL(b[1][1], 4); | |||
| lolunit_assert_equal(b[0][0], 1); | |||
| lolunit_assert_equal(b[0][1], 2); | |||
| lolunit_assert_equal(b[1][0], 3); | |||
| lolunit_assert_equal(b[1][1], 4); | |||
| } | |||
| LOLUNIT_TEST(ArrayNDCreate) | |||
| lolunit_declare_test(ArrayNDCreate) | |||
| { | |||
| arraynd<10, int> a; | |||
| arraynd<20, float> b; | |||
| @@ -58,44 +58,44 @@ LOLUNIT_FIXTURE(ArrayNDTest) | |||
| arraynd<3, int> e = { { {1, 2}, {3, 4} }, { {5, 6}, {7, 8} } }; | |||
| LOLUNIT_ASSERT_EQUAL(e.GetSize()[0], 2); | |||
| LOLUNIT_ASSERT_EQUAL(e.GetSize()[1], 2); | |||
| LOLUNIT_ASSERT_EQUAL(e.GetSize()[2], 2); | |||
| lolunit_assert_equal(e.GetSize()[0], 2); | |||
| lolunit_assert_equal(e.GetSize()[1], 2); | |||
| lolunit_assert_equal(e.GetSize()[2], 2); | |||
| LOLUNIT_ASSERT_EQUAL(e[0][0][0], 1); | |||
| LOLUNIT_ASSERT_EQUAL(e[1][0][0], 2); | |||
| LOLUNIT_ASSERT_EQUAL(e[0][1][0], 3); | |||
| LOLUNIT_ASSERT_EQUAL(e[1][1][0], 4); | |||
| LOLUNIT_ASSERT_EQUAL(e[0][0][1], 5); | |||
| LOLUNIT_ASSERT_EQUAL(e[1][0][1], 6); | |||
| LOLUNIT_ASSERT_EQUAL(e[0][1][1], 7); | |||
| LOLUNIT_ASSERT_EQUAL(e[1][1][1], 8); | |||
| lolunit_assert_equal(e[0][0][0], 1); | |||
| lolunit_assert_equal(e[1][0][0], 2); | |||
| lolunit_assert_equal(e[0][1][0], 3); | |||
| lolunit_assert_equal(e[1][1][0], 4); | |||
| lolunit_assert_equal(e[0][0][1], 5); | |||
| lolunit_assert_equal(e[1][0][1], 6); | |||
| lolunit_assert_equal(e[0][1][1], 7); | |||
| lolunit_assert_equal(e[1][1][1], 8); | |||
| arraynd<3, int> f = { { {1, 2, 3, 4}, {5, 6, 7} }, { {8, 9}, {10} } }; | |||
| LOLUNIT_ASSERT_EQUAL(f.GetSize()[0], 4); | |||
| LOLUNIT_ASSERT_EQUAL(f.GetSize()[1], 2); | |||
| LOLUNIT_ASSERT_EQUAL(f.GetSize()[2], 2); | |||
| LOLUNIT_ASSERT_EQUAL(f[0][0][0], 1); | |||
| LOLUNIT_ASSERT_EQUAL(f[1][0][0], 2); | |||
| LOLUNIT_ASSERT_EQUAL(f[2][0][0], 3); | |||
| LOLUNIT_ASSERT_EQUAL(f[3][0][0], 4); | |||
| LOLUNIT_ASSERT_EQUAL(f[0][1][0], 5); | |||
| LOLUNIT_ASSERT_EQUAL(f[1][1][0], 6); | |||
| LOLUNIT_ASSERT_EQUAL(f[2][1][0], 7); | |||
| LOLUNIT_ASSERT_EQUAL(f[3][1][0], 0); | |||
| LOLUNIT_ASSERT_EQUAL(f[0][0][1], 8); | |||
| LOLUNIT_ASSERT_EQUAL(f[1][0][1], 9); | |||
| LOLUNIT_ASSERT_EQUAL(f[2][0][1], 0); | |||
| LOLUNIT_ASSERT_EQUAL(f[3][0][1], 0); | |||
| LOLUNIT_ASSERT_EQUAL(f[0][1][1], 10); | |||
| LOLUNIT_ASSERT_EQUAL(f[1][1][1], 0); | |||
| LOLUNIT_ASSERT_EQUAL(f[2][1][1], 0); | |||
| LOLUNIT_ASSERT_EQUAL(f[3][1][1], 0); | |||
| lolunit_assert_equal(f.GetSize()[0], 4); | |||
| lolunit_assert_equal(f.GetSize()[1], 2); | |||
| lolunit_assert_equal(f.GetSize()[2], 2); | |||
| lolunit_assert_equal(f[0][0][0], 1); | |||
| lolunit_assert_equal(f[1][0][0], 2); | |||
| lolunit_assert_equal(f[2][0][0], 3); | |||
| lolunit_assert_equal(f[3][0][0], 4); | |||
| lolunit_assert_equal(f[0][1][0], 5); | |||
| lolunit_assert_equal(f[1][1][0], 6); | |||
| lolunit_assert_equal(f[2][1][0], 7); | |||
| lolunit_assert_equal(f[3][1][0], 0); | |||
| lolunit_assert_equal(f[0][0][1], 8); | |||
| lolunit_assert_equal(f[1][0][1], 9); | |||
| lolunit_assert_equal(f[2][0][1], 0); | |||
| lolunit_assert_equal(f[3][0][1], 0); | |||
| lolunit_assert_equal(f[0][1][1], 10); | |||
| lolunit_assert_equal(f[1][1][1], 0); | |||
| lolunit_assert_equal(f[2][1][1], 0); | |||
| lolunit_assert_equal(f[3][1][1], 0); | |||
| } | |||
| LOLUNIT_TEST(ArrayNDInit) | |||
| lolunit_declare_test(ArrayNDInit) | |||
| { | |||
| int const NDIM = 8; | |||
| vec_t<int, NDIM> size; | |||
| @@ -104,18 +104,18 @@ LOLUNIT_FIXTURE(ArrayNDTest) | |||
| arraynd<NDIM, uint8_t> a(size); | |||
| memset(a.Data(), 0, a.Bytes()); | |||
| LOLUNIT_ASSERT_EQUAL(a[2][3][2][0][1][4][0][1], 0x00); | |||
| lolunit_assert_equal(a[2][3][2][0][1][4][0][1], 0x00); | |||
| vec_t<int, NDIM> v = { 2, 3, 2, 0, 1, 4, 0, 1 }; | |||
| LOLUNIT_ASSERT_EQUAL(a[v], 0x00); | |||
| lolunit_assert_equal(a[v], 0x00); | |||
| a[2][3][2][0][1][4][0][1] = 0xcd; | |||
| LOLUNIT_ASSERT_EQUAL(a[2][3][2][0][1][4][0][1], 0xcd); | |||
| LOLUNIT_ASSERT_EQUAL(a[v], 0xcd); | |||
| lolunit_assert_equal(a[2][3][2][0][1][4][0][1], 0xcd); | |||
| lolunit_assert_equal(a[v], 0xcd); | |||
| arraynd<NDIM, uint8_t> const &b = a; | |||
| LOLUNIT_ASSERT_EQUAL(b[2][3][2][0][1][4][0][1], 0xcd); | |||
| LOLUNIT_ASSERT_EQUAL(b[v], 0xcd); | |||
| lolunit_assert_equal(b[2][3][2][0][1][4][0][1], 0xcd); | |||
| lolunit_assert_equal(b[v], 0xcd); | |||
| } | |||
| }; | |||
| @@ -18,40 +18,40 @@ | |||
| namespace lol | |||
| { | |||
| LOLUNIT_FIXTURE(BoxTest) | |||
| lolunit_declare_fixture(BoxTest) | |||
| { | |||
| void SetUp() {} | |||
| void TearDown() {} | |||
| LOLUNIT_TEST(Box2DIsect) | |||
| lolunit_declare_test(Box2DIsect) | |||
| { | |||
| box2 b1(vec2(0.f, 0.f), vec2(10.f, 10.f)); | |||
| box2 b2(vec2(5.f, 8.f), vec2(8.f, 12.f)); | |||
| box2 b3(vec2(5.f, 11.f), vec2(8.f, 13.f)); | |||
| LOLUNIT_ASSERT_EQUAL(true, TestAABBVsAABB(b1, b2)); | |||
| LOLUNIT_ASSERT_EQUAL(false, TestAABBVsAABB(b1, b3)); | |||
| lolunit_assert_equal(true, TestAABBVsAABB(b1, b2)); | |||
| lolunit_assert_equal(false, TestAABBVsAABB(b1, b3)); | |||
| box2 b4(vec2(96.f, 33.f), vec2(144.f, 129.f)); | |||
| box2 b5(vec2(264.f, 91.f), vec2(244.f, 71.f)); | |||
| LOLUNIT_ASSERT_EQUAL(false, TestAABBVsAABB(b4, b5)); | |||
| lolunit_assert_equal(false, TestAABBVsAABB(b4, b5)); | |||
| } | |||
| LOLUNIT_TEST(Box2DMove) | |||
| lolunit_declare_test(Box2DMove) | |||
| { | |||
| box2 b1(vec2(0.f, 0.f), vec2(1.f, 1.f)); | |||
| box2 b2(vec2(2.f, 2.f), vec2(3.f, 3.f)); | |||
| b1 += vec2(0.6f, 0.6f); | |||
| LOLUNIT_ASSERT_EQUAL(false, TestAABBVsAABB(b1, b2)); | |||
| lolunit_assert_equal(false, TestAABBVsAABB(b1, b2)); | |||
| b1 += vec2(0.6f, 0.6f); | |||
| LOLUNIT_ASSERT_EQUAL(true, TestAABBVsAABB(b1, b2)); | |||
| lolunit_assert_equal(true, TestAABBVsAABB(b1, b2)); | |||
| b1 -= vec2(0.0f, 0.6f); | |||
| LOLUNIT_ASSERT_EQUAL(false, TestAABBVsAABB(b1, b2)); | |||
| lolunit_assert_equal(false, TestAABBVsAABB(b1, b2)); | |||
| } | |||
| }; | |||
| @@ -18,91 +18,91 @@ | |||
| namespace lol | |||
| { | |||
| LOLUNIT_FIXTURE(ComplexTest) | |||
| lolunit_declare_fixture(ComplexTest) | |||
| { | |||
| void SetUp() {} | |||
| void TearDown() {} | |||
| LOLUNIT_TEST(Equality) | |||
| lolunit_declare_test(Equality) | |||
| { | |||
| cmplx a2(1.0f, 2.0f); | |||
| cmplx b2(0.0f, 2.0f); | |||
| cmplx c2(1.0f, 0.0f); | |||
| LOLUNIT_ASSERT_EQUAL(a2, a2); | |||
| LOLUNIT_ASSERT_NOT_DIFFERENT(a2, a2); | |||
| lolunit_assert_equal(a2, a2); | |||
| lolunit_assert_not_different(a2, a2); | |||
| LOLUNIT_ASSERT_DIFFERENT(a2, b2); | |||
| LOLUNIT_ASSERT_NOT_EQUAL(a2, b2); | |||
| LOLUNIT_ASSERT_DIFFERENT(a2, c2); | |||
| LOLUNIT_ASSERT_NOT_EQUAL(a2, c2); | |||
| lolunit_assert_different(a2, b2); | |||
| lolunit_assert_not_equal(a2, b2); | |||
| lolunit_assert_different(a2, c2); | |||
| lolunit_assert_not_equal(a2, c2); | |||
| } | |||
| LOLUNIT_TEST(UnaryMinus) | |||
| lolunit_declare_test(UnaryMinus) | |||
| { | |||
| cmplx a(1.0f, 3.0f); | |||
| cmplx b(-1.0f, -3.0f); | |||
| LOLUNIT_ASSERT_EQUAL(a, -b); | |||
| LOLUNIT_ASSERT_EQUAL(-a, b); | |||
| lolunit_assert_equal(a, -b); | |||
| lolunit_assert_equal(-a, b); | |||
| } | |||
| LOLUNIT_TEST(Conjugate) | |||
| lolunit_declare_test(Conjugate) | |||
| { | |||
| cmplx a(1.0f, 3.0f); | |||
| cmplx b(1.0f, -3.0f); | |||
| LOLUNIT_ASSERT_EQUAL(a, ~b); | |||
| LOLUNIT_ASSERT_EQUAL(~a, b); | |||
| lolunit_assert_equal(a, ~b); | |||
| lolunit_assert_equal(~a, b); | |||
| } | |||
| LOLUNIT_TEST(Norm) | |||
| lolunit_declare_test(Norm) | |||
| { | |||
| cmplx a(3.0f, -4.0f); | |||
| LOLUNIT_ASSERT_EQUAL(norm(a), 5.0f); | |||
| lolunit_assert_equal(norm(a), 5.0f); | |||
| cmplx b = a * ~a; | |||
| cmplx c = norm(a) * norm(a); | |||
| LOLUNIT_ASSERT_EQUAL(b, c); | |||
| lolunit_assert_equal(b, c); | |||
| cmplx d(5.0f, 12.0f); | |||
| LOLUNIT_ASSERT_EQUAL(norm(d), 13.0f); | |||
| LOLUNIT_ASSERT_EQUAL(norm(a * d), norm(a) * norm(d)); | |||
| lolunit_assert_equal(norm(d), 13.0f); | |||
| lolunit_assert_equal(norm(a * d), norm(a) * norm(d)); | |||
| } | |||
| LOLUNIT_TEST(Base) | |||
| lolunit_declare_test(Base) | |||
| { | |||
| cmplx one(1.0f, 0.0f); | |||
| cmplx i(0.0f, 1.0f); | |||
| LOLUNIT_ASSERT_EQUAL(norm(one), 1.0f); | |||
| LOLUNIT_ASSERT_EQUAL(norm(i), 1.0f); | |||
| lolunit_assert_equal(norm(one), 1.0f); | |||
| lolunit_assert_equal(norm(i), 1.0f); | |||
| LOLUNIT_ASSERT_EQUAL(i * i, -one); | |||
| lolunit_assert_equal(i * i, -one); | |||
| } | |||
| LOLUNIT_TEST(Normalize) | |||
| lolunit_declare_test(Normalize) | |||
| { | |||
| cmplx a(3.0f, -4.0f); | |||
| cmplx b = normalize(a); | |||
| LOLUNIT_ASSERT_DOUBLES_EQUAL(norm(b), 1.0, 1e-8); | |||
| lolunit_assert_doubles_equal(norm(b), 1.0, 1e-8); | |||
| } | |||
| LOLUNIT_TEST(Reciprocal) | |||
| lolunit_declare_test(Reciprocal) | |||
| { | |||
| cmplx a(3.0f, -4.0f); | |||
| cmplx b = re(a); | |||
| LOLUNIT_ASSERT_EQUAL(a * b, b * a); | |||
| lolunit_assert_equal(a * b, b * a); | |||
| cmplx c = 1.0f; | |||
| LOLUNIT_ASSERT_EQUAL(a * b, c); | |||
| lolunit_assert_equal(a * b, c); | |||
| } | |||
| }; | |||
| @@ -20,140 +20,140 @@ | |||
| namespace lol | |||
| { | |||
| LOLUNIT_FIXTURE(HalfTest) | |||
| lolunit_declare_fixture(HalfTest) | |||
| { | |||
| LOLUNIT_TEST(FloatToHalf) | |||
| lolunit_declare_test(FloatToHalf) | |||
| { | |||
| for (size_t i = 0; i < sizeof(pairs) / sizeof(*pairs); i++) | |||
| { | |||
| half a = (half)pairs[i].f; | |||
| uint16_t b = pairs[i].x; | |||
| LOLUNIT_SET_CONTEXT(i); | |||
| LOLUNIT_ASSERT_EQUAL(a.bits, b); | |||
| lolunit_set_context(i); | |||
| lolunit_assert_equal(a.bits, b); | |||
| } | |||
| } | |||
| LOLUNIT_TEST(FloatToHalfAccurate) | |||
| lolunit_declare_test(FloatToHalfAccurate) | |||
| { | |||
| for (size_t i = 0; i < sizeof(pairs) / sizeof(*pairs); i++) | |||
| { | |||
| half a = half::makeaccurate(pairs[i].f); | |||
| uint16_t b = pairs[i].x; | |||
| LOLUNIT_SET_CONTEXT(i); | |||
| LOLUNIT_ASSERT_EQUAL(a.bits, b); | |||
| lolunit_set_context(i); | |||
| lolunit_assert_equal(a.bits, b); | |||
| } | |||
| } | |||
| LOLUNIT_TEST(BitsToHalf) | |||
| lolunit_declare_test(BitsToHalf) | |||
| { | |||
| for (unsigned int i = 0; i < 0x10000; i++) | |||
| { | |||
| half a = half::makebits(i); | |||
| uint16_t b = i; | |||
| LOLUNIT_SET_CONTEXT(i); | |||
| LOLUNIT_ASSERT_EQUAL(a.bits, b); | |||
| lolunit_set_context(i); | |||
| lolunit_assert_equal(a.bits, b); | |||
| } | |||
| } | |||
| LOLUNIT_TEST(HalfIsNaN) | |||
| lolunit_declare_test(HalfIsNaN) | |||
| { | |||
| 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()); | |||
| 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()); | |||
| } | |||
| LOLUNIT_TEST(HalfIsInf) | |||
| lolunit_declare_test(HalfIsInf) | |||
| { | |||
| LOLUNIT_ASSERT(half(65536.0f).is_inf()); | |||
| LOLUNIT_ASSERT(half(-65536.0f).is_inf()); | |||
| lolunit_assert(half(65536.0f).is_inf()); | |||
| lolunit_assert(half(-65536.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()); | |||
| 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()); | |||
| LOLUNIT_ASSERT(half::makebits(0x7c00).is_inf()); | |||
| LOLUNIT_ASSERT(half::makebits(0xfc00).is_inf()); | |||
| lolunit_assert(half::makebits(0x7c00).is_inf()); | |||
| lolunit_assert(half::makebits(0xfc00).is_inf()); | |||
| LOLUNIT_ASSERT(!half::makebits(0x7e00).is_inf()); | |||
| LOLUNIT_ASSERT(!half::makebits(0xfe00).is_inf()); | |||
| lolunit_assert(!half::makebits(0x7e00).is_inf()); | |||
| lolunit_assert(!half::makebits(0xfe00).is_inf()); | |||
| } | |||
| LOLUNIT_TEST(HalfIsFinite) | |||
| lolunit_declare_test(HalfIsFinite) | |||
| { | |||
| 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()); | |||
| 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()); | |||
| LOLUNIT_ASSERT(!half(65536.0f).is_finite()); | |||
| LOLUNIT_ASSERT(!half(-65536.0f).is_finite()); | |||
| lolunit_assert(!half(65536.0f).is_finite()); | |||
| lolunit_assert(!half(-65536.0f).is_finite()); | |||
| LOLUNIT_ASSERT(!half::makebits(0x7c00).is_finite()); | |||
| LOLUNIT_ASSERT(!half::makebits(0xfc00).is_finite()); | |||
| lolunit_assert(!half::makebits(0x7c00).is_finite()); | |||
| lolunit_assert(!half::makebits(0xfc00).is_finite()); | |||
| LOLUNIT_ASSERT(!half::makebits(0x7e00).is_finite()); | |||
| LOLUNIT_ASSERT(!half::makebits(0xfe00).is_finite()); | |||
| lolunit_assert(!half::makebits(0x7e00).is_finite()); | |||
| lolunit_assert(!half::makebits(0xfe00).is_finite()); | |||
| } | |||
| LOLUNIT_TEST(HalfIsNormal) | |||
| lolunit_declare_test(HalfIsNormal) | |||
| { | |||
| 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()); | |||
| 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()); | |||
| LOLUNIT_ASSERT(!half(65536.0f).is_normal()); | |||
| LOLUNIT_ASSERT(!half(-65536.0f).is_normal()); | |||
| lolunit_assert(!half(65536.0f).is_normal()); | |||
| lolunit_assert(!half(-65536.0f).is_normal()); | |||
| LOLUNIT_ASSERT(!half::makebits(0x7c00).is_normal()); | |||
| LOLUNIT_ASSERT(!half::makebits(0xfc00).is_normal()); | |||
| lolunit_assert(!half::makebits(0x7c00).is_normal()); | |||
| lolunit_assert(!half::makebits(0xfc00).is_normal()); | |||
| LOLUNIT_ASSERT(!half::makebits(0x7e00).is_normal()); | |||
| LOLUNIT_ASSERT(!half::makebits(0xfe00).is_normal()); | |||
| lolunit_assert(!half::makebits(0x7e00).is_normal()); | |||
| lolunit_assert(!half::makebits(0xfe00).is_normal()); | |||
| } | |||
| LOLUNIT_TEST(HalfClassify) | |||
| lolunit_declare_test(HalfClassify) | |||
| { | |||
| for (uint32_t i = 0; i < 0x10000; i++) | |||
| { | |||
| LOLUNIT_SET_CONTEXT(i); | |||
| lolunit_set_context(i); | |||
| half h = half::makebits(i); | |||
| if (h.is_nan()) | |||
| { | |||
| LOLUNIT_ASSERT(!h.is_inf()); | |||
| LOLUNIT_ASSERT(!h.is_normal()); | |||
| LOLUNIT_ASSERT(!h.is_finite()); | |||
| lolunit_assert(!h.is_inf()); | |||
| lolunit_assert(!h.is_normal()); | |||
| lolunit_assert(!h.is_finite()); | |||
| } | |||
| else if (h.is_inf()) | |||
| { | |||
| LOLUNIT_ASSERT(!h.is_normal()); | |||
| LOLUNIT_ASSERT(!h.is_finite()); | |||
| lolunit_assert(!h.is_normal()); | |||
| lolunit_assert(!h.is_finite()); | |||
| } | |||
| else | |||
| { | |||
| LOLUNIT_ASSERT(h.is_finite()); | |||
| lolunit_assert(h.is_finite()); | |||
| } | |||
| } | |||
| } | |||
| LOLUNIT_TEST(HalfToFloat) | |||
| lolunit_declare_test(HalfToFloat) | |||
| { | |||
| for (size_t i = 0; i < sizeof(pairs) / sizeof(*pairs); i++) | |||
| { | |||
| float a = (float)half::makebits(pairs[i].x); | |||
| float b = pairs[i].f; | |||
| LOLUNIT_SET_CONTEXT(i); | |||
| LOLUNIT_ASSERT_EQUAL(a, b); | |||
| lolunit_set_context(i); | |||
| lolunit_assert_equal(a, b); | |||
| } | |||
| for (uint32_t i = 0; i < 0x10000; i++) | |||
| @@ -164,67 +164,67 @@ LOLUNIT_FIXTURE(HalfTest) | |||
| float f = (float)h; | |||
| half g = (half)f; | |||
| LOLUNIT_SET_CONTEXT(i); | |||
| LOLUNIT_ASSERT_EQUAL(g.bits, h.bits); | |||
| lolunit_set_context(i); | |||
| lolunit_assert_equal(g.bits, h.bits); | |||
| } | |||
| } | |||
| LOLUNIT_TEST(HalfToInt) | |||
| lolunit_declare_test(HalfToInt) | |||
| { | |||
| 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); | |||
| 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); | |||
| } | |||
| LOLUNIT_TEST(FloatOpHalf) | |||
| lolunit_declare_test(FloatOpHalf) | |||
| { | |||
| half zero = 0; | |||
| half one = 1; | |||
| half two = 2; | |||
| float a = zero + one; | |||
| LOLUNIT_ASSERT_EQUAL(1.0f, a); | |||
| lolunit_assert_equal(1.0f, a); | |||
| a += zero; | |||
| LOLUNIT_ASSERT_EQUAL(1.0f, a); | |||
| lolunit_assert_equal(1.0f, a); | |||
| a -= zero; | |||
| LOLUNIT_ASSERT_EQUAL(1.0f, a); | |||
| lolunit_assert_equal(1.0f, a); | |||
| a *= one; | |||
| LOLUNIT_ASSERT_EQUAL(1.0f, a); | |||
| lolunit_assert_equal(1.0f, a); | |||
| a /= one; | |||
| LOLUNIT_ASSERT_EQUAL(1.0f, a); | |||
| lolunit_assert_equal(1.0f, a); | |||
| float b = one + zero; | |||
| LOLUNIT_ASSERT_EQUAL(1.0f, b); | |||
| lolunit_assert_equal(1.0f, b); | |||
| b += one; | |||
| LOLUNIT_ASSERT_EQUAL(2.0f, b); | |||
| lolunit_assert_equal(2.0f, b); | |||
| b *= two; | |||
| LOLUNIT_ASSERT_EQUAL(4.0f, b); | |||
| lolunit_assert_equal(4.0f, b); | |||
| b -= two; | |||
| LOLUNIT_ASSERT_EQUAL(2.0f, b); | |||
| lolunit_assert_equal(2.0f, b); | |||
| b /= two; | |||
| LOLUNIT_ASSERT_EQUAL(1.0f, b); | |||
| lolunit_assert_equal(1.0f, b); | |||
| float c = one - zero; | |||
| LOLUNIT_ASSERT_EQUAL(1.0f, c); | |||
| lolunit_assert_equal(1.0f, c); | |||
| float d = two - one; | |||
| LOLUNIT_ASSERT_EQUAL(1.0f, d); | |||
| lolunit_assert_equal(1.0f, d); | |||
| float e = two + (-one); | |||
| LOLUNIT_ASSERT_EQUAL(1.0f, e); | |||
| lolunit_assert_equal(1.0f, e); | |||
| float f = (two * two) / (one + one); | |||
| LOLUNIT_ASSERT_EQUAL(2.0f, f); | |||
| lolunit_assert_equal(2.0f, f); | |||
| } | |||
| LOLUNIT_TEST(HalfOpFloat) | |||
| lolunit_declare_test(HalfOpFloat) | |||
| { | |||
| half zero = 0; | |||
| half one = 1; | |||
| @@ -232,38 +232,38 @@ LOLUNIT_FIXTURE(HalfTest) | |||
| half four = 4; | |||
| half a = one + 0.0f; | |||
| LOLUNIT_ASSERT_EQUAL(one.bits, a.bits); | |||
| lolunit_assert_equal(one.bits, a.bits); | |||
| a += 0.0f; | |||
| LOLUNIT_ASSERT_EQUAL(one.bits, a.bits); | |||
| lolunit_assert_equal(one.bits, a.bits); | |||
| a -= 0.0f; | |||
| LOLUNIT_ASSERT_EQUAL(one.bits, a.bits); | |||
| lolunit_assert_equal(one.bits, a.bits); | |||
| a *= 1.0f; | |||
| LOLUNIT_ASSERT_EQUAL(one.bits, a.bits); | |||
| lolunit_assert_equal(one.bits, a.bits); | |||
| a /= 1.0f; | |||
| LOLUNIT_ASSERT_EQUAL(one.bits, a.bits); | |||
| lolunit_assert_equal(one.bits, a.bits); | |||
| half b = one + 0.0f; | |||
| LOLUNIT_ASSERT_EQUAL(one.bits, b.bits); | |||
| lolunit_assert_equal(one.bits, b.bits); | |||
| b += 1.0f; | |||
| LOLUNIT_ASSERT_EQUAL(two.bits, b.bits); | |||
| lolunit_assert_equal(two.bits, b.bits); | |||
| b *= 2.0f; | |||
| LOLUNIT_ASSERT_EQUAL(four.bits, b.bits); | |||
| lolunit_assert_equal(four.bits, b.bits); | |||
| b -= 2.0f; | |||
| LOLUNIT_ASSERT_EQUAL(two.bits, b.bits); | |||
| lolunit_assert_equal(two.bits, b.bits); | |||
| b /= 2.0f; | |||
| LOLUNIT_ASSERT_EQUAL(one.bits, b.bits); | |||
| lolunit_assert_equal(one.bits, b.bits); | |||
| half c = 1.0f - zero; | |||
| LOLUNIT_ASSERT_EQUAL(one.bits, c.bits); | |||
| lolunit_assert_equal(one.bits, c.bits); | |||
| half d = 2.0f - one; | |||
| LOLUNIT_ASSERT_EQUAL(one.bits, d.bits); | |||
| lolunit_assert_equal(one.bits, d.bits); | |||
| half e = 2.0f + (-one); | |||
| LOLUNIT_ASSERT_EQUAL(one.bits, e.bits); | |||
| lolunit_assert_equal(one.bits, e.bits); | |||
| half f = (2.0f * two) / (1.0f + one); | |||
| LOLUNIT_ASSERT_EQUAL(two.bits, f.bits); | |||
| lolunit_assert_equal(two.bits, f.bits); | |||
| } | |||
| struct TestPair { float f; uint16_t x; }; | |||
| @@ -18,13 +18,13 @@ | |||
| namespace lol | |||
| { | |||
| LOLUNIT_FIXTURE(InterpTest) | |||
| lolunit_declare_fixture(InterpTest) | |||
| { | |||
| void SetUp() {} | |||
| void TearDown() {} | |||
| LOLUNIT_TEST(TimeInterpTest) | |||
| lolunit_declare_test(TimeInterpTest) | |||
| { | |||
| TimeInterp<float> ti; | |||
| @@ -32,11 +32,11 @@ LOLUNIT_FIXTURE(InterpTest) | |||
| ti.Set(1.f, 20.f); | |||
| ti.Set(1.f, 30.f); | |||
| LOLUNIT_ASSERT_DOUBLES_EQUAL(0.f, ti.Get(-3.0f), 1.e-5f); | |||
| LOLUNIT_ASSERT_DOUBLES_EQUAL(10.f, ti.Get(-2.0f), 1.e-5f); | |||
| LOLUNIT_ASSERT_DOUBLES_EQUAL(20.f, ti.Get(-1.0f), 1.e-5f); | |||
| LOLUNIT_ASSERT_DOUBLES_EQUAL(30.f, ti.Get(0.0f), 1.e-5f); | |||
| LOLUNIT_ASSERT_DOUBLES_EQUAL(40.f, ti.Get(1.0f), 1.e-5f); | |||
| lolunit_assert_doubles_equal(0.f, ti.Get(-3.0f), 1.e-5f); | |||
| lolunit_assert_doubles_equal(10.f, ti.Get(-2.0f), 1.e-5f); | |||
| lolunit_assert_doubles_equal(20.f, ti.Get(-1.0f), 1.e-5f); | |||
| lolunit_assert_doubles_equal(30.f, ti.Get(0.0f), 1.e-5f); | |||
| lolunit_assert_doubles_equal(40.f, ti.Get(1.0f), 1.e-5f); | |||
| } | |||
| }; | |||
| @@ -18,7 +18,7 @@ | |||
| namespace lol | |||
| { | |||
| LOLUNIT_FIXTURE(MatrixTest) | |||
| lolunit_declare_fixture(MatrixTest) | |||
| { | |||
| void SetUp() | |||
| { | |||
| @@ -49,116 +49,116 @@ LOLUNIT_FIXTURE(MatrixTest) | |||
| void TearDown() {} | |||
| LOLUNIT_TEST(Determinant) | |||
| lolunit_declare_test(Determinant) | |||
| { | |||
| float d1, d2; | |||
| d1 = determinant(tri2); | |||
| LOLUNIT_ASSERT_EQUAL(d1, 2.0f); | |||
| lolunit_assert_equal(d1, 2.0f); | |||
| d2 = determinant(inv2); | |||
| LOLUNIT_ASSERT_EQUAL(d2, -1.0f); | |||
| lolunit_assert_equal(d2, -1.0f); | |||
| d1 = determinant(tri3); | |||
| LOLUNIT_ASSERT_EQUAL(d1, 6.0f); | |||
| lolunit_assert_equal(d1, 6.0f); | |||
| d2 = determinant(inv3); | |||
| LOLUNIT_ASSERT_EQUAL(d2, 1.0f); | |||
| lolunit_assert_equal(d2, 1.0f); | |||
| d1 = determinant(tri4); | |||
| LOLUNIT_ASSERT_EQUAL(d1, 24.0f); | |||
| lolunit_assert_equal(d1, 24.0f); | |||
| d2 = determinant(inv4); | |||
| LOLUNIT_ASSERT_EQUAL(d2, -1.0f); | |||
| lolunit_assert_equal(d2, -1.0f); | |||
| } | |||
| LOLUNIT_TEST(Multiplication) | |||
| lolunit_declare_test(Multiplication) | |||
| { | |||
| mat4 m0 = id4; | |||
| mat4 m1 = id4; | |||
| mat4 m2 = m0 * m1; | |||
| 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); | |||
| 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); | |||
| } | |||
| LOLUNIT_TEST(Inverse2x2) | |||
| lolunit_declare_test(Inverse2x2) | |||
| { | |||
| mat2 m0 = inv2; | |||
| mat2 m1 = inverse(m0); | |||
| mat2 m2 = m0 * m1; | |||
| LOLUNIT_ASSERT_EQUAL(m2[0][0], 1.0f); | |||
| LOLUNIT_ASSERT_EQUAL(m2[1][0], 0.0f); | |||
| lolunit_assert_equal(m2[0][0], 1.0f); | |||
| lolunit_assert_equal(m2[1][0], 0.0f); | |||
| LOLUNIT_ASSERT_EQUAL(m2[0][1], 0.0f); | |||
| LOLUNIT_ASSERT_EQUAL(m2[1][1], 1.0f); | |||
| lolunit_assert_equal(m2[0][1], 0.0f); | |||
| lolunit_assert_equal(m2[1][1], 1.0f); | |||
| } | |||
| LOLUNIT_TEST(Inverse3x3) | |||
| lolunit_declare_test(Inverse3x3) | |||
| { | |||
| mat3 m0 = inv3; | |||
| mat3 m1 = inverse(m0); | |||
| mat3 m2 = m0 * m1; | |||
| 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[0][0], 1.0f); | |||
| lolunit_assert_equal(m2[1][0], 0.0f); | |||
| lolunit_assert_equal(m2[2][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[0][1], 0.0f); | |||
| lolunit_assert_equal(m2[1][1], 1.0f); | |||
| lolunit_assert_equal(m2[2][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[0][2], 0.0f); | |||
| lolunit_assert_equal(m2[1][2], 0.0f); | |||
| lolunit_assert_equal(m2[2][2], 1.0f); | |||
| } | |||
| LOLUNIT_TEST(Inverse4x4) | |||
| lolunit_declare_test(Inverse4x4) | |||
| { | |||
| mat4 m0 = inv4; | |||
| mat4 m1 = inverse(m0); | |||
| mat4 m2 = m0 * m1; | |||
| 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); | |||
| 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); | |||
| } | |||
| LOLUNIT_TEST(Kronecker) | |||
| lolunit_declare_test(Kronecker) | |||
| { | |||
| int const COLS1 = 2, ROWS1 = 3; | |||
| int const COLS2 = 5, ROWS2 = 7; | |||
| @@ -184,7 +184,7 @@ LOLUNIT_FIXTURE(MatrixTest) | |||
| int expected = a[i1][j1] * b[i2][j2]; | |||
| int actual = m[i1 * COLS2 + i2][j1 * ROWS2 + j2]; | |||
| LOLUNIT_ASSERT_EQUAL(actual, expected); | |||
| lolunit_assert_equal(actual, expected); | |||
| } | |||
| } | |||
| @@ -18,7 +18,7 @@ | |||
| namespace lol | |||
| { | |||
| LOLUNIT_FIXTURE(QuaternionTest) | |||
| lolunit_declare_fixture(QuaternionTest) | |||
| { | |||
| void SetUp() | |||
| { | |||
| @@ -47,7 +47,7 @@ LOLUNIT_FIXTURE(QuaternionTest) | |||
| void TearDown() {} | |||
| LOLUNIT_TEST(Equality) | |||
| lolunit_declare_test(Equality) | |||
| { | |||
| quat a4(1.f, 2.f, 3.f, 4.f); | |||
| quat b4(0.f, 2.f, 3.f, 4.f); | |||
| @@ -55,154 +55,154 @@ LOLUNIT_FIXTURE(QuaternionTest) | |||
| quat d4(1.f, 2.f, 0.f, 4.f); | |||
| quat e4(1.f, 2.f, 3.f, 0.f); | |||
| LOLUNIT_ASSERT_EQUAL(a4, a4); | |||
| LOLUNIT_ASSERT_NOT_DIFFERENT(a4, a4); | |||
| LOLUNIT_ASSERT_DIFFERENT(a4, b4); | |||
| LOLUNIT_ASSERT_NOT_EQUAL(a4, b4); | |||
| LOLUNIT_ASSERT_DIFFERENT(a4, c4); | |||
| LOLUNIT_ASSERT_NOT_EQUAL(a4, c4); | |||
| LOLUNIT_ASSERT_DIFFERENT(a4, d4); | |||
| LOLUNIT_ASSERT_NOT_EQUAL(a4, d4); | |||
| LOLUNIT_ASSERT_DIFFERENT(a4, e4); | |||
| LOLUNIT_ASSERT_NOT_EQUAL(a4, e4); | |||
| lolunit_assert_equal(a4, a4); | |||
| lolunit_assert_not_different(a4, a4); | |||
| lolunit_assert_different(a4, b4); | |||
| lolunit_assert_not_equal(a4, b4); | |||
| lolunit_assert_different(a4, c4); | |||
| lolunit_assert_not_equal(a4, c4); | |||
| lolunit_assert_different(a4, d4); | |||
| lolunit_assert_not_equal(a4, d4); | |||
| lolunit_assert_different(a4, e4); | |||
| lolunit_assert_not_equal(a4, e4); | |||
| } | |||
| LOLUNIT_TEST(UnaryMinus) | |||
| lolunit_declare_test(UnaryMinus) | |||
| { | |||
| quat a(1.f, 3.f, 2.f, 4.f); | |||
| quat b(-1.f, -3.f, -2.f, -4.f); | |||
| LOLUNIT_ASSERT_EQUAL(a, -b); | |||
| LOLUNIT_ASSERT_EQUAL(-a, b); | |||
| lolunit_assert_equal(a, -b); | |||
| lolunit_assert_equal(-a, b); | |||
| } | |||
| LOLUNIT_TEST(Conjugate) | |||
| lolunit_declare_test(Conjugate) | |||
| { | |||
| quat a(1.f, 3.f, 2.f, 4.f); | |||
| quat b(1.f, -3.f, -2.f, -4.f); | |||
| LOLUNIT_ASSERT_EQUAL(a, ~b); | |||
| LOLUNIT_ASSERT_EQUAL(~a, b); | |||
| lolunit_assert_equal(a, ~b); | |||
| lolunit_assert_equal(~a, b); | |||
| } | |||
| LOLUNIT_TEST(Norm) | |||
| lolunit_declare_test(Norm) | |||
| { | |||
| quat a(2.f, -2.f, -8.f, 3.f); | |||
| LOLUNIT_ASSERT_EQUAL(norm(a), 9.f); | |||
| lolunit_assert_equal(norm(a), 9.f); | |||
| quat b = a * ~a; | |||
| quat c(norm(a) * norm(a), 0.f, 0.f, 0.f); | |||
| LOLUNIT_ASSERT_EQUAL(b, c); | |||
| lolunit_assert_equal(b, c); | |||
| quat d(2.f, 5.f, -4.f, -2.f); | |||
| LOLUNIT_ASSERT_EQUAL(norm(a * d), norm(a) * norm(d)); | |||
| lolunit_assert_equal(norm(a * d), norm(a) * norm(d)); | |||
| } | |||
| LOLUNIT_TEST(Dot) | |||
| lolunit_declare_test(Dot) | |||
| { | |||
| quat a(-1.f, 2.f, -3.f, 4.f); | |||
| quat b(8.f, 7.f, 6.f, 5.f); | |||
| LOLUNIT_ASSERT_EQUAL(dot(a, b), 8.f); | |||
| lolunit_assert_equal(dot(a, b), 8.f); | |||
| } | |||
| LOLUNIT_TEST(Base) | |||
| lolunit_declare_test(Base) | |||
| { | |||
| quat one(1.f, 0.f, 0.f, 0.f); | |||
| quat i(0.f, 1.f, 0.f, 0.f); | |||
| quat j(0.f, 0.f, 1.f, 0.f); | |||
| quat k(0.f, 0.f, 0.f, 1.f); | |||
| LOLUNIT_ASSERT_EQUAL(norm(one), 1.f); | |||
| LOLUNIT_ASSERT_EQUAL(norm(i), 1.f); | |||
| LOLUNIT_ASSERT_EQUAL(norm(j), 1.f); | |||
| LOLUNIT_ASSERT_EQUAL(norm(k), 1.f); | |||
| LOLUNIT_ASSERT_EQUAL(i * i, -one); | |||
| LOLUNIT_ASSERT_EQUAL(j * j, -one); | |||
| LOLUNIT_ASSERT_EQUAL(k * k, -one); | |||
| LOLUNIT_ASSERT_EQUAL(i * j * k, -one); | |||
| LOLUNIT_ASSERT_EQUAL(i * j, k); | |||
| LOLUNIT_ASSERT_EQUAL(j * i, -k); | |||
| LOLUNIT_ASSERT_EQUAL(j * k, i); | |||
| LOLUNIT_ASSERT_EQUAL(k * j, -i); | |||
| LOLUNIT_ASSERT_EQUAL(k * i, j); | |||
| LOLUNIT_ASSERT_EQUAL(i * k, -j); | |||
| lolunit_assert_equal(norm(one), 1.f); | |||
| lolunit_assert_equal(norm(i), 1.f); | |||
| lolunit_assert_equal(norm(j), 1.f); | |||
| lolunit_assert_equal(norm(k), 1.f); | |||
| lolunit_assert_equal(i * i, -one); | |||
| lolunit_assert_equal(j * j, -one); | |||
| lolunit_assert_equal(k * k, -one); | |||
| lolunit_assert_equal(i * j * k, -one); | |||
| lolunit_assert_equal(i * j, k); | |||
| lolunit_assert_equal(j * i, -k); | |||
| lolunit_assert_equal(j * k, i); | |||
| lolunit_assert_equal(k * j, -i); | |||
| lolunit_assert_equal(k * i, j); | |||
| lolunit_assert_equal(i * k, -j); | |||
| } | |||
| LOLUNIT_TEST(Normalize) | |||
| lolunit_declare_test(Normalize) | |||
| { | |||
| quat a(2.f, -2.f, -8.f, 3.f); | |||
| quat b = normalize(a); | |||
| LOLUNIT_ASSERT_DOUBLES_EQUAL(norm(b), 1.0, 1e-5); | |||
| lolunit_assert_doubles_equal(norm(b), 1.0, 1e-5); | |||
| } | |||
| LOLUNIT_TEST(Reciprocal) | |||
| lolunit_declare_test(Reciprocal) | |||
| { | |||
| quat a(2.f, -2.f, -8.f, 3.f); | |||
| quat b = re(a); | |||
| quat c = 1.f / a; | |||
| LOLUNIT_ASSERT_DOUBLES_EQUAL(b.w, c.w, 1e-5); | |||
| LOLUNIT_ASSERT_DOUBLES_EQUAL(b.x, c.x, 1e-5); | |||
| LOLUNIT_ASSERT_DOUBLES_EQUAL(b.y, c.y, 1e-5); | |||
| LOLUNIT_ASSERT_DOUBLES_EQUAL(b.z, c.z, 1e-5); | |||
| lolunit_assert_doubles_equal(b.w, c.w, 1e-5); | |||
| lolunit_assert_doubles_equal(b.x, c.x, 1e-5); | |||
| lolunit_assert_doubles_equal(b.y, c.y, 1e-5); | |||
| lolunit_assert_doubles_equal(b.z, c.z, 1e-5); | |||
| quat m1 = a * b; | |||
| quat m2 = b * a; | |||
| LOLUNIT_ASSERT_DOUBLES_EQUAL(m1.w, m2.w, 1e-5); | |||
| LOLUNIT_ASSERT_DOUBLES_EQUAL(m1.x, m2.x, 1e-5); | |||
| LOLUNIT_ASSERT_DOUBLES_EQUAL(m1.y, m2.y, 1e-5); | |||
| LOLUNIT_ASSERT_DOUBLES_EQUAL(m1.z, m2.z, 1e-5); | |||
| LOLUNIT_ASSERT_DOUBLES_EQUAL(m1.w, 1.0, 1e-5); | |||
| LOLUNIT_ASSERT_DOUBLES_EQUAL(m1.x, 0.0, 1e-5); | |||
| LOLUNIT_ASSERT_DOUBLES_EQUAL(m1.y, 0.0, 1e-5); | |||
| LOLUNIT_ASSERT_DOUBLES_EQUAL(m1.z, 0.0, 1e-5); | |||
| lolunit_assert_doubles_equal(m1.w, m2.w, 1e-5); | |||
| lolunit_assert_doubles_equal(m1.x, m2.x, 1e-5); | |||
| lolunit_assert_doubles_equal(m1.y, m2.y, 1e-5); | |||
| lolunit_assert_doubles_equal(m1.z, m2.z, 1e-5); | |||
| lolunit_assert_doubles_equal(m1.w, 1.0, 1e-5); | |||
| lolunit_assert_doubles_equal(m1.x, 0.0, 1e-5); | |||
| lolunit_assert_doubles_equal(m1.y, 0.0, 1e-5); | |||
| lolunit_assert_doubles_equal(m1.z, 0.0, 1e-5); | |||
| } | |||
| LOLUNIT_TEST(Rotation) | |||
| lolunit_declare_test(Rotation) | |||
| { | |||
| /* Check that rotating 10 degrees twice means rotating 20 degrees */ | |||
| quat a = quat::rotate(10.f, vec3::axis_x); | |||
| quat b = quat::rotate(20.f, vec3::axis_x); | |||
| quat c = a * a; | |||
| LOLUNIT_ASSERT_DOUBLES_EQUAL(c.w, b.w, 1e-5); | |||
| LOLUNIT_ASSERT_DOUBLES_EQUAL(c.x, b.x, 1e-5); | |||
| LOLUNIT_ASSERT_DOUBLES_EQUAL(c.y, b.y, 1e-5); | |||
| LOLUNIT_ASSERT_DOUBLES_EQUAL(c.z, b.z, 1e-5); | |||
| lolunit_assert_doubles_equal(c.w, b.w, 1e-5); | |||
| lolunit_assert_doubles_equal(c.x, b.x, 1e-5); | |||
| lolunit_assert_doubles_equal(c.y, b.y, 1e-5); | |||
| lolunit_assert_doubles_equal(c.z, b.z, 1e-5); | |||
| /* Check that rotating 10 degrees then 20 is the same as 20 then 10 */ | |||
| quat d = a * b; | |||
| quat e = b * a; | |||
| LOLUNIT_ASSERT_DOUBLES_EQUAL(e.w, d.w, 1e-5); | |||
| LOLUNIT_ASSERT_DOUBLES_EQUAL(e.x, d.x, 1e-5); | |||
| LOLUNIT_ASSERT_DOUBLES_EQUAL(e.y, d.y, 1e-5); | |||
| LOLUNIT_ASSERT_DOUBLES_EQUAL(e.z, d.z, 1e-5); | |||
| lolunit_assert_doubles_equal(e.w, d.w, 1e-5); | |||
| lolunit_assert_doubles_equal(e.x, d.x, 1e-5); | |||
| lolunit_assert_doubles_equal(e.y, d.y, 1e-5); | |||
| lolunit_assert_doubles_equal(e.z, d.z, 1e-5); | |||
| } | |||
| LOLUNIT_TEST(ToAxisAngle) | |||
| lolunit_declare_test(ToAxisAngle) | |||
| { | |||
| quat q = quat::rotate(10.f, vec3::axis_x); | |||
| vec3 axis = q.axis(); | |||
| float angle = q.angle(); | |||
| LOLUNIT_ASSERT_DOUBLES_EQUAL(1.0, axis.x, 1e-6); | |||
| LOLUNIT_ASSERT_DOUBLES_EQUAL(0.0, axis.y, 1e-6); | |||
| LOLUNIT_ASSERT_DOUBLES_EQUAL(0.0, axis.z, 1e-6); | |||
| lolunit_assert_doubles_equal(1.0, axis.x, 1e-6); | |||
| lolunit_assert_doubles_equal(0.0, axis.y, 1e-6); | |||
| lolunit_assert_doubles_equal(0.0, axis.z, 1e-6); | |||
| LOLUNIT_ASSERT_DOUBLES_EQUAL(10.0, (double)degrees(angle), 1e-6); | |||
| lolunit_assert_doubles_equal(10.0, (double)degrees(angle), 1e-6); | |||
| } | |||
| LOLUNIT_TEST(FromTwoVectors) | |||
| lolunit_declare_test(FromTwoVectors) | |||
| { | |||
| for (auto pair : m_vectorpairs) | |||
| { | |||
| @@ -214,40 +214,40 @@ LOLUNIT_FIXTURE(QuaternionTest) | |||
| quat q = quat::rotate(a, b); | |||
| /* Check that q is a unit quaternion */ | |||
| LOLUNIT_ASSERT_DOUBLES_EQUAL(1.0, (double)norm(q), 1e-5); | |||
| lolunit_assert_doubles_equal(1.0, (double)norm(q), 1e-5); | |||
| /* Check that q transforms da into db */ | |||
| vec3 c = q.transform(da); | |||
| LOLUNIT_ASSERT_DOUBLES_EQUAL(c.x, db.x, 1e-5); | |||
| LOLUNIT_ASSERT_DOUBLES_EQUAL(c.y, db.y, 1e-5); | |||
| LOLUNIT_ASSERT_DOUBLES_EQUAL(c.z, db.z, 1e-5); | |||
| lolunit_assert_doubles_equal(c.x, db.x, 1e-5); | |||
| lolunit_assert_doubles_equal(c.y, db.y, 1e-5); | |||
| lolunit_assert_doubles_equal(c.z, db.z, 1e-5); | |||
| /* Check that ~q transforms db into da */ | |||
| vec3 d = (~q).transform(db); | |||
| LOLUNIT_ASSERT_DOUBLES_EQUAL(d.x, da.x, 1e-5); | |||
| LOLUNIT_ASSERT_DOUBLES_EQUAL(d.y, da.y, 1e-5); | |||
| LOLUNIT_ASSERT_DOUBLES_EQUAL(d.z, da.z, 1e-5); | |||
| lolunit_assert_doubles_equal(d.x, da.x, 1e-5); | |||
| lolunit_assert_doubles_equal(d.y, da.y, 1e-5); | |||
| lolunit_assert_doubles_equal(d.z, da.z, 1e-5); | |||
| if (distance(da, db) > 1e-6f) | |||
| { | |||
| /* If da and db differ, check that the rotation axis is normal to both | |||
| * vectors, which is only true if the rotation uses the shortest path. */ | |||
| vec3 axis = q.axis(); | |||
| LOLUNIT_ASSERT_DOUBLES_EQUAL(0.0, (double)dot(axis, da), 1e-5); | |||
| LOLUNIT_ASSERT_DOUBLES_EQUAL(0.0, (double)dot(axis, db), 1e-5); | |||
| lolunit_assert_doubles_equal(0.0, (double)dot(axis, da), 1e-5); | |||
| lolunit_assert_doubles_equal(0.0, (double)dot(axis, db), 1e-5); | |||
| } | |||
| else | |||
| { | |||
| /* If da and db are roughly the same, check that the rotation angle | |||
| * is zero. */ | |||
| LOLUNIT_ASSERT_DOUBLES_EQUAL(0.0, (double)q.angle(), 1e-5); | |||
| lolunit_assert_doubles_equal(0.0, (double)q.angle(), 1e-5); | |||
| } | |||
| } | |||
| } | |||
| LOLUNIT_TEST(FromEulerNorm) | |||
| lolunit_declare_test(FromEulerNorm) | |||
| { | |||
| for (int i = 0; i < 100; ++i) | |||
| { | |||
| @@ -255,45 +255,45 @@ LOLUNIT_FIXTURE(QuaternionTest) | |||
| /* Tait-Bryan */ | |||
| quat q1 = quat::fromeuler_xyz(angles); | |||
| LOLUNIT_ASSERT_DOUBLES_EQUAL(norm(q1), 1.f, 1e-5); | |||
| lolunit_assert_doubles_equal(norm(q1), 1.f, 1e-5); | |||
| quat q2 = quat::fromeuler_yzx(angles); | |||
| LOLUNIT_ASSERT_DOUBLES_EQUAL(norm(q2), 1.f, 1e-5); | |||
| lolunit_assert_doubles_equal(norm(q2), 1.f, 1e-5); | |||
| quat q3 = quat::fromeuler_zxy(angles); | |||
| LOLUNIT_ASSERT_DOUBLES_EQUAL(norm(q3), 1.f, 1e-5); | |||
| lolunit_assert_doubles_equal(norm(q3), 1.f, 1e-5); | |||
| quat q4 = quat::fromeuler_xzy(angles); | |||
| LOLUNIT_ASSERT_DOUBLES_EQUAL(norm(q4), 1.f, 1e-5); | |||
| lolunit_assert_doubles_equal(norm(q4), 1.f, 1e-5); | |||
| quat q5 = quat::fromeuler_zyx(angles); | |||
| LOLUNIT_ASSERT_DOUBLES_EQUAL(norm(q5), 1.f, 1e-5); | |||
| lolunit_assert_doubles_equal(norm(q5), 1.f, 1e-5); | |||
| quat q6 = quat::fromeuler_yxz(angles); | |||
| LOLUNIT_ASSERT_DOUBLES_EQUAL(norm(q6), 1.f, 1e-5); | |||
| lolunit_assert_doubles_equal(norm(q6), 1.f, 1e-5); | |||
| /* Euler */ | |||
| quat q7 = quat::fromeuler_xyx(angles); | |||
| LOLUNIT_ASSERT_DOUBLES_EQUAL(norm(q7), 1.f, 1e-5); | |||
| lolunit_assert_doubles_equal(norm(q7), 1.f, 1e-5); | |||
| quat q8 = quat::fromeuler_yzy(angles); | |||
| LOLUNIT_ASSERT_DOUBLES_EQUAL(norm(q8), 1.f, 1e-5); | |||
| lolunit_assert_doubles_equal(norm(q8), 1.f, 1e-5); | |||
| quat q9 = quat::fromeuler_zxz(angles); | |||
| LOLUNIT_ASSERT_DOUBLES_EQUAL(norm(q9), 1.f, 1e-5); | |||
| lolunit_assert_doubles_equal(norm(q9), 1.f, 1e-5); | |||
| quat q10 = quat::fromeuler_xzx(angles); | |||
| LOLUNIT_ASSERT_DOUBLES_EQUAL(norm(q10), 1.f, 1e-5); | |||
| lolunit_assert_doubles_equal(norm(q10), 1.f, 1e-5); | |||
| quat q11 = quat::fromeuler_zyz(angles); | |||
| LOLUNIT_ASSERT_DOUBLES_EQUAL(norm(q11), 1.f, 1e-5); | |||
| lolunit_assert_doubles_equal(norm(q11), 1.f, 1e-5); | |||
| quat q12 = quat::fromeuler_yxy(angles); | |||
| LOLUNIT_ASSERT_DOUBLES_EQUAL(norm(q12), 1.f, 1e-5); | |||
| lolunit_assert_doubles_equal(norm(q12), 1.f, 1e-5); | |||
| } | |||
| } | |||
| LOLUNIT_TEST(FirstTwoEulerAngles) | |||
| lolunit_declare_test(FirstTwoEulerAngles) | |||
| { | |||
| for (int i = 0; i < 100; ++i) | |||
| { | |||
| @@ -305,54 +305,54 @@ LOLUNIT_FIXTURE(QuaternionTest) | |||
| q1 = quat::fromeuler_xyz(angles); | |||
| q2 = quat::fromeuler_xyx(angles); | |||
| LOLUNIT_ASSERT_DOUBLES_EQUAL(q1.w, q2.w, 1e-5); | |||
| LOLUNIT_ASSERT_DOUBLES_EQUAL(q1.x, q2.x, 1e-5); | |||
| LOLUNIT_ASSERT_DOUBLES_EQUAL(q1.y, q2.y, 1e-5); | |||
| LOLUNIT_ASSERT_DOUBLES_EQUAL(q1.z, q2.z, 1e-5); | |||
| lolunit_assert_doubles_equal(q1.w, q2.w, 1e-5); | |||
| lolunit_assert_doubles_equal(q1.x, q2.x, 1e-5); | |||
| lolunit_assert_doubles_equal(q1.y, q2.y, 1e-5); | |||
| lolunit_assert_doubles_equal(q1.z, q2.z, 1e-5); | |||
| q1 = quat::fromeuler_yzx(angles); | |||
| q2 = quat::fromeuler_yzy(angles); | |||
| LOLUNIT_ASSERT_DOUBLES_EQUAL(q1.w, q2.w, 1e-5); | |||
| LOLUNIT_ASSERT_DOUBLES_EQUAL(q1.x, q2.x, 1e-5); | |||
| LOLUNIT_ASSERT_DOUBLES_EQUAL(q1.y, q2.y, 1e-5); | |||
| LOLUNIT_ASSERT_DOUBLES_EQUAL(q1.z, q2.z, 1e-5); | |||
| lolunit_assert_doubles_equal(q1.w, q2.w, 1e-5); | |||
| lolunit_assert_doubles_equal(q1.x, q2.x, 1e-5); | |||
| lolunit_assert_doubles_equal(q1.y, q2.y, 1e-5); | |||
| lolunit_assert_doubles_equal(q1.z, q2.z, 1e-5); | |||
| q1 = quat::fromeuler_zxy(angles); | |||
| q2 = quat::fromeuler_zxz(angles); | |||
| LOLUNIT_ASSERT_DOUBLES_EQUAL(q1.w, q2.w, 1e-5); | |||
| LOLUNIT_ASSERT_DOUBLES_EQUAL(q1.x, q2.x, 1e-5); | |||
| LOLUNIT_ASSERT_DOUBLES_EQUAL(q1.y, q2.y, 1e-5); | |||
| LOLUNIT_ASSERT_DOUBLES_EQUAL(q1.z, q2.z, 1e-5); | |||
| lolunit_assert_doubles_equal(q1.w, q2.w, 1e-5); | |||
| lolunit_assert_doubles_equal(q1.x, q2.x, 1e-5); | |||
| lolunit_assert_doubles_equal(q1.y, q2.y, 1e-5); | |||
| lolunit_assert_doubles_equal(q1.z, q2.z, 1e-5); | |||
| q1 = quat::fromeuler_xzy(angles); | |||
| q2 = quat::fromeuler_xzx(angles); | |||
| LOLUNIT_ASSERT_DOUBLES_EQUAL(q1.w, q2.w, 1e-5); | |||
| LOLUNIT_ASSERT_DOUBLES_EQUAL(q1.x, q2.x, 1e-5); | |||
| LOLUNIT_ASSERT_DOUBLES_EQUAL(q1.y, q2.y, 1e-5); | |||
| LOLUNIT_ASSERT_DOUBLES_EQUAL(q1.z, q2.z, 1e-5); | |||
| lolunit_assert_doubles_equal(q1.w, q2.w, 1e-5); | |||
| lolunit_assert_doubles_equal(q1.x, q2.x, 1e-5); | |||
| lolunit_assert_doubles_equal(q1.y, q2.y, 1e-5); | |||
| lolunit_assert_doubles_equal(q1.z, q2.z, 1e-5); | |||
| q1 = quat::fromeuler_zyx(angles); | |||
| q2 = quat::fromeuler_zyz(angles); | |||
| LOLUNIT_ASSERT_DOUBLES_EQUAL(q1.w, q2.w, 1e-5); | |||
| LOLUNIT_ASSERT_DOUBLES_EQUAL(q1.x, q2.x, 1e-5); | |||
| LOLUNIT_ASSERT_DOUBLES_EQUAL(q1.y, q2.y, 1e-5); | |||
| LOLUNIT_ASSERT_DOUBLES_EQUAL(q1.z, q2.z, 1e-5); | |||
| lolunit_assert_doubles_equal(q1.w, q2.w, 1e-5); | |||
| lolunit_assert_doubles_equal(q1.x, q2.x, 1e-5); | |||
| lolunit_assert_doubles_equal(q1.y, q2.y, 1e-5); | |||
| lolunit_assert_doubles_equal(q1.z, q2.z, 1e-5); | |||
| q1 = quat::fromeuler_yxz(angles); | |||
| q2 = quat::fromeuler_yxy(angles); | |||
| LOLUNIT_ASSERT_DOUBLES_EQUAL(q1.w, q2.w, 1e-5); | |||
| LOLUNIT_ASSERT_DOUBLES_EQUAL(q1.x, q2.x, 1e-5); | |||
| LOLUNIT_ASSERT_DOUBLES_EQUAL(q1.y, q2.y, 1e-5); | |||
| LOLUNIT_ASSERT_DOUBLES_EQUAL(q1.z, q2.z, 1e-5); | |||
| lolunit_assert_doubles_equal(q1.w, q2.w, 1e-5); | |||
| lolunit_assert_doubles_equal(q1.x, q2.x, 1e-5); | |||
| lolunit_assert_doubles_equal(q1.y, q2.y, 1e-5); | |||
| lolunit_assert_doubles_equal(q1.z, q2.z, 1e-5); | |||
| } | |||
| } | |||
| LOLUNIT_TEST(LastTwoEulerAngles) | |||
| lolunit_declare_test(LastTwoEulerAngles) | |||
| { | |||
| for (int i = 0; i < 100; ++i) | |||
| { | |||
| @@ -364,54 +364,54 @@ LOLUNIT_FIXTURE(QuaternionTest) | |||
| q1 = quat::fromeuler_xyz(angles); | |||
| q2 = quat::fromeuler_zyz(angles); | |||
| LOLUNIT_ASSERT_DOUBLES_EQUAL(q1.w, q2.w, 1e-5); | |||
| LOLUNIT_ASSERT_DOUBLES_EQUAL(q1.x, q2.x, 1e-5); | |||
| LOLUNIT_ASSERT_DOUBLES_EQUAL(q1.y, q2.y, 1e-5); | |||
| LOLUNIT_ASSERT_DOUBLES_EQUAL(q1.z, q2.z, 1e-5); | |||
| lolunit_assert_doubles_equal(q1.w, q2.w, 1e-5); | |||
| lolunit_assert_doubles_equal(q1.x, q2.x, 1e-5); | |||
| lolunit_assert_doubles_equal(q1.y, q2.y, 1e-5); | |||
| lolunit_assert_doubles_equal(q1.z, q2.z, 1e-5); | |||
| q1 = quat::fromeuler_yzx(angles); | |||
| q2 = quat::fromeuler_xzx(angles); | |||
| LOLUNIT_ASSERT_DOUBLES_EQUAL(q1.w, q2.w, 1e-5); | |||
| LOLUNIT_ASSERT_DOUBLES_EQUAL(q1.x, q2.x, 1e-5); | |||
| LOLUNIT_ASSERT_DOUBLES_EQUAL(q1.y, q2.y, 1e-5); | |||
| LOLUNIT_ASSERT_DOUBLES_EQUAL(q1.z, q2.z, 1e-5); | |||
| lolunit_assert_doubles_equal(q1.w, q2.w, 1e-5); | |||
| lolunit_assert_doubles_equal(q1.x, q2.x, 1e-5); | |||
| lolunit_assert_doubles_equal(q1.y, q2.y, 1e-5); | |||
| lolunit_assert_doubles_equal(q1.z, q2.z, 1e-5); | |||
| q1 = quat::fromeuler_zxy(angles); | |||
| q2 = quat::fromeuler_yxy(angles); | |||
| LOLUNIT_ASSERT_DOUBLES_EQUAL(q1.w, q2.w, 1e-5); | |||
| LOLUNIT_ASSERT_DOUBLES_EQUAL(q1.x, q2.x, 1e-5); | |||
| LOLUNIT_ASSERT_DOUBLES_EQUAL(q1.y, q2.y, 1e-5); | |||
| LOLUNIT_ASSERT_DOUBLES_EQUAL(q1.z, q2.z, 1e-5); | |||
| lolunit_assert_doubles_equal(q1.w, q2.w, 1e-5); | |||
| lolunit_assert_doubles_equal(q1.x, q2.x, 1e-5); | |||
| lolunit_assert_doubles_equal(q1.y, q2.y, 1e-5); | |||
| lolunit_assert_doubles_equal(q1.z, q2.z, 1e-5); | |||
| q1 = quat::fromeuler_xzy(angles); | |||
| q2 = quat::fromeuler_yzy(angles); | |||
| LOLUNIT_ASSERT_DOUBLES_EQUAL(q1.w, q2.w, 1e-5); | |||
| LOLUNIT_ASSERT_DOUBLES_EQUAL(q1.x, q2.x, 1e-5); | |||
| LOLUNIT_ASSERT_DOUBLES_EQUAL(q1.y, q2.y, 1e-5); | |||
| LOLUNIT_ASSERT_DOUBLES_EQUAL(q1.z, q2.z, 1e-5); | |||
| lolunit_assert_doubles_equal(q1.w, q2.w, 1e-5); | |||
| lolunit_assert_doubles_equal(q1.x, q2.x, 1e-5); | |||
| lolunit_assert_doubles_equal(q1.y, q2.y, 1e-5); | |||
| lolunit_assert_doubles_equal(q1.z, q2.z, 1e-5); | |||
| q1 = quat::fromeuler_zyx(angles); | |||
| q2 = quat::fromeuler_xyx(angles); | |||
| LOLUNIT_ASSERT_DOUBLES_EQUAL(q1.w, q2.w, 1e-5); | |||
| LOLUNIT_ASSERT_DOUBLES_EQUAL(q1.x, q2.x, 1e-5); | |||
| LOLUNIT_ASSERT_DOUBLES_EQUAL(q1.y, q2.y, 1e-5); | |||
| LOLUNIT_ASSERT_DOUBLES_EQUAL(q1.z, q2.z, 1e-5); | |||
| lolunit_assert_doubles_equal(q1.w, q2.w, 1e-5); | |||
| lolunit_assert_doubles_equal(q1.x, q2.x, 1e-5); | |||
| lolunit_assert_doubles_equal(q1.y, q2.y, 1e-5); | |||
| lolunit_assert_doubles_equal(q1.z, q2.z, 1e-5); | |||
| q1 = quat::fromeuler_yxz(angles); | |||
| q2 = quat::fromeuler_zxz(angles); | |||
| LOLUNIT_ASSERT_DOUBLES_EQUAL(q1.w, q2.w, 1e-5); | |||
| LOLUNIT_ASSERT_DOUBLES_EQUAL(q1.x, q2.x, 1e-5); | |||
| LOLUNIT_ASSERT_DOUBLES_EQUAL(q1.y, q2.y, 1e-5); | |||
| LOLUNIT_ASSERT_DOUBLES_EQUAL(q1.z, q2.z, 1e-5); | |||
| lolunit_assert_doubles_equal(q1.w, q2.w, 1e-5); | |||
| lolunit_assert_doubles_equal(q1.x, q2.x, 1e-5); | |||
| lolunit_assert_doubles_equal(q1.y, q2.y, 1e-5); | |||
| lolunit_assert_doubles_equal(q1.z, q2.z, 1e-5); | |||
| } | |||
| } | |||
| LOLUNIT_TEST(TaitBryanAngles) | |||
| lolunit_declare_test(TaitBryanAngles) | |||
| { | |||
| for (int i = 0; i < 100; ++i) | |||
| { | |||
| @@ -427,53 +427,53 @@ LOLUNIT_FIXTURE(QuaternionTest) | |||
| quat q1 = quat::fromeuler_xyz(vec3::toeuler_xyz(q0)); | |||
| vec3 p1 = q1.transform(p); | |||
| LOLUNIT_ASSERT_DOUBLES_EQUAL(p1.x, p0.x, 1e-4); | |||
| LOLUNIT_ASSERT_DOUBLES_EQUAL(p1.y, p0.y, 1e-4); | |||
| LOLUNIT_ASSERT_DOUBLES_EQUAL(p1.z, p0.z, 1e-4); | |||
| lolunit_assert_doubles_equal(p1.x, p0.x, 1e-4); | |||
| lolunit_assert_doubles_equal(p1.y, p0.y, 1e-4); | |||
| lolunit_assert_doubles_equal(p1.z, p0.z, 1e-4); | |||
| /* y-z-x */ | |||
| q1 = quat::fromeuler_yzx(vec3::toeuler_yzx(q0)); | |||
| p1 = q1.transform(p); | |||
| LOLUNIT_ASSERT_DOUBLES_EQUAL(p1.x, p0.x, 1e-4); | |||
| LOLUNIT_ASSERT_DOUBLES_EQUAL(p1.y, p0.y, 1e-4); | |||
| LOLUNIT_ASSERT_DOUBLES_EQUAL(p1.z, p0.z, 1e-4); | |||
| lolunit_assert_doubles_equal(p1.x, p0.x, 1e-4); | |||
| lolunit_assert_doubles_equal(p1.y, p0.y, 1e-4); | |||
| lolunit_assert_doubles_equal(p1.z, p0.z, 1e-4); | |||
| /* z-x-y */ | |||
| q1 = quat::fromeuler_zxy(vec3::toeuler_zxy(q0)); | |||
| p1 = q1.transform(p); | |||
| LOLUNIT_ASSERT_DOUBLES_EQUAL(p1.x, p0.x, 1e-4); | |||
| LOLUNIT_ASSERT_DOUBLES_EQUAL(p1.y, p0.y, 1e-4); | |||
| LOLUNIT_ASSERT_DOUBLES_EQUAL(p1.z, p0.z, 1e-4); | |||
| lolunit_assert_doubles_equal(p1.x, p0.x, 1e-4); | |||
| lolunit_assert_doubles_equal(p1.y, p0.y, 1e-4); | |||
| lolunit_assert_doubles_equal(p1.z, p0.z, 1e-4); | |||
| /* x-z-y */ | |||
| q1 = quat::fromeuler_xzy(vec3::toeuler_xzy(q0)); | |||
| p1 = q1.transform(p); | |||
| LOLUNIT_ASSERT_DOUBLES_EQUAL(p1.x, p0.x, 1e-4); | |||
| LOLUNIT_ASSERT_DOUBLES_EQUAL(p1.y, p0.y, 1e-4); | |||
| LOLUNIT_ASSERT_DOUBLES_EQUAL(p1.z, p0.z, 1e-4); | |||
| lolunit_assert_doubles_equal(p1.x, p0.x, 1e-4); | |||
| lolunit_assert_doubles_equal(p1.y, p0.y, 1e-4); | |||
| lolunit_assert_doubles_equal(p1.z, p0.z, 1e-4); | |||
| /* z-y-x */ | |||
| q1 = quat::fromeuler_zyx(vec3::toeuler_zyx(q0)); | |||
| p1 = q1.transform(p); | |||
| LOLUNIT_ASSERT_DOUBLES_EQUAL(p1.x, p0.x, 1e-4); | |||
| LOLUNIT_ASSERT_DOUBLES_EQUAL(p1.y, p0.y, 1e-4); | |||
| LOLUNIT_ASSERT_DOUBLES_EQUAL(p1.z, p0.z, 1e-4); | |||
| lolunit_assert_doubles_equal(p1.x, p0.x, 1e-4); | |||
| lolunit_assert_doubles_equal(p1.y, p0.y, 1e-4); | |||
| lolunit_assert_doubles_equal(p1.z, p0.z, 1e-4); | |||
| /* y-x-z */ | |||
| q1 = quat::fromeuler_yxz(vec3::toeuler_yxz(q0)); | |||
| p1 = q1.transform(p); | |||
| LOLUNIT_ASSERT_DOUBLES_EQUAL(p1.x, p0.x, 1e-4); | |||
| LOLUNIT_ASSERT_DOUBLES_EQUAL(p1.y, p0.y, 1e-4); | |||
| LOLUNIT_ASSERT_DOUBLES_EQUAL(p1.z, p0.z, 1e-4); | |||
| lolunit_assert_doubles_equal(p1.x, p0.x, 1e-4); | |||
| lolunit_assert_doubles_equal(p1.y, p0.y, 1e-4); | |||
| lolunit_assert_doubles_equal(p1.z, p0.z, 1e-4); | |||
| } | |||
| } | |||
| LOLUNIT_TEST(EulerAngles) | |||
| lolunit_declare_test(EulerAngles) | |||
| { | |||
| for (int i = 0; i < 100; ++i) | |||
| { | |||
| @@ -489,49 +489,49 @@ LOLUNIT_FIXTURE(QuaternionTest) | |||
| quat q1 = quat::fromeuler_xyx(vec3::toeuler_xyx(q0)); | |||
| vec3 p1 = q1.transform(p); | |||
| LOLUNIT_ASSERT_DOUBLES_EQUAL(p1.x, p0.x, 1e-4); | |||
| LOLUNIT_ASSERT_DOUBLES_EQUAL(p1.y, p0.y, 1e-4); | |||
| LOLUNIT_ASSERT_DOUBLES_EQUAL(p1.z, p0.z, 1e-4); | |||
| lolunit_assert_doubles_equal(p1.x, p0.x, 1e-4); | |||
| lolunit_assert_doubles_equal(p1.y, p0.y, 1e-4); | |||
| lolunit_assert_doubles_equal(p1.z, p0.z, 1e-4); | |||
| /* y-z-y */ | |||
| q1 = quat::fromeuler_yzy(vec3::toeuler_yzy(q0)); | |||
| p1 = q1.transform(p); | |||
| LOLUNIT_ASSERT_DOUBLES_EQUAL(p1.x, p0.x, 1e-4); | |||
| LOLUNIT_ASSERT_DOUBLES_EQUAL(p1.y, p0.y, 1e-4); | |||
| LOLUNIT_ASSERT_DOUBLES_EQUAL(p1.z, p0.z, 1e-4); | |||
| lolunit_assert_doubles_equal(p1.x, p0.x, 1e-4); | |||
| lolunit_assert_doubles_equal(p1.y, p0.y, 1e-4); | |||
| lolunit_assert_doubles_equal(p1.z, p0.z, 1e-4); | |||
| /* z-x-z */ | |||
| q1 = quat::fromeuler_zxz(vec3::toeuler_zxz(q0)); | |||
| p1 = q1.transform(p); | |||
| LOLUNIT_ASSERT_DOUBLES_EQUAL(p1.x, p0.x, 1e-4); | |||
| LOLUNIT_ASSERT_DOUBLES_EQUAL(p1.y, p0.y, 1e-4); | |||
| LOLUNIT_ASSERT_DOUBLES_EQUAL(p1.z, p0.z, 1e-4); | |||
| lolunit_assert_doubles_equal(p1.x, p0.x, 1e-4); | |||
| lolunit_assert_doubles_equal(p1.y, p0.y, 1e-4); | |||
| lolunit_assert_doubles_equal(p1.z, p0.z, 1e-4); | |||
| /* x-z-x */ | |||
| q1 = quat::fromeuler_xzx(vec3::toeuler_xzx(q0)); | |||
| p1 = q1.transform(p); | |||
| LOLUNIT_ASSERT_DOUBLES_EQUAL(p1.x, p0.x, 1e-4); | |||
| LOLUNIT_ASSERT_DOUBLES_EQUAL(p1.y, p0.y, 1e-4); | |||
| LOLUNIT_ASSERT_DOUBLES_EQUAL(p1.z, p0.z, 1e-4); | |||
| lolunit_assert_doubles_equal(p1.x, p0.x, 1e-4); | |||
| lolunit_assert_doubles_equal(p1.y, p0.y, 1e-4); | |||
| lolunit_assert_doubles_equal(p1.z, p0.z, 1e-4); | |||
| /* z-y-z */ | |||
| q1 = quat::fromeuler_zyz(vec3::toeuler_zyz(q0)); | |||
| p1 = q1.transform(p); | |||
| LOLUNIT_ASSERT_DOUBLES_EQUAL(p1.x, p0.x, 1e-4); | |||
| LOLUNIT_ASSERT_DOUBLES_EQUAL(p1.y, p0.y, 1e-4); | |||
| LOLUNIT_ASSERT_DOUBLES_EQUAL(p1.z, p0.z, 1e-4); | |||
| lolunit_assert_doubles_equal(p1.x, p0.x, 1e-4); | |||
| lolunit_assert_doubles_equal(p1.y, p0.y, 1e-4); | |||
| lolunit_assert_doubles_equal(p1.z, p0.z, 1e-4); | |||
| /* y-x-y */ | |||
| q1 = quat::fromeuler_yxy(vec3::toeuler_yxy(q0)); | |||
| p1 = q1.transform(p); | |||
| LOLUNIT_ASSERT_DOUBLES_EQUAL(p1.x, p0.x, 1e-4); | |||
| LOLUNIT_ASSERT_DOUBLES_EQUAL(p1.y, p0.y, 1e-4); | |||
| LOLUNIT_ASSERT_DOUBLES_EQUAL(p1.z, p0.z, 1e-4); | |||
| lolunit_assert_doubles_equal(p1.x, p0.x, 1e-4); | |||
| lolunit_assert_doubles_equal(p1.y, p0.y, 1e-4); | |||
| lolunit_assert_doubles_equal(p1.z, p0.z, 1e-4); | |||
| } | |||
| } | |||
| @@ -18,13 +18,13 @@ | |||
| namespace lol | |||
| { | |||
| LOLUNIT_FIXTURE(RandTest) | |||
| lolunit_declare_fixture(RandTest) | |||
| { | |||
| void SetUp() {} | |||
| void TearDown() {} | |||
| LOLUNIT_TEST(Int32Bits) | |||
| lolunit_declare_test(Int32Bits) | |||
| { | |||
| int const rolls = 2000; | |||
| @@ -35,7 +35,7 @@ LOLUNIT_FIXTURE(RandTest) | |||
| { | |||
| int32_t r = rand<int32_t>(); | |||
| LOLUNIT_ASSERT_GEQUAL(r, 0); | |||
| lolunit_assert_gequal(r, 0); | |||
| for (int k = 0; k < 31; k++) | |||
| { | |||
| @@ -46,14 +46,14 @@ LOLUNIT_FIXTURE(RandTest) | |||
| for (int k = 0; k < 31; k++) | |||
| { | |||
| LOLUNIT_SET_CONTEXT(k); | |||
| LOLUNIT_ASSERT_GEQUAL(bits[k], rolls / 3); | |||
| LOLUNIT_ASSERT_LEQUAL(bits[k], rolls * 2 / 3); | |||
| LOLUNIT_UNSET_CONTEXT(k); | |||
| lolunit_set_context(k); | |||
| lolunit_assert_gequal(bits[k], rolls / 3); | |||
| lolunit_assert_lequal(bits[k], rolls * 2 / 3); | |||
| lolunit_unset_context(k); | |||
| } | |||
| } | |||
| LOLUNIT_TEST(Int16Bits) | |||
| lolunit_declare_test(Int16Bits) | |||
| { | |||
| int const rolls = 2000; | |||
| @@ -64,7 +64,7 @@ LOLUNIT_FIXTURE(RandTest) | |||
| { | |||
| int16_t r = rand<int16_t>(); | |||
| LOLUNIT_ASSERT_GEQUAL(r, 0); | |||
| lolunit_assert_gequal(r, 0); | |||
| for (int k = 0; k < 15; k++) | |||
| { | |||
| @@ -75,14 +75,14 @@ LOLUNIT_FIXTURE(RandTest) | |||
| for (int k = 0; k < 15; k++) | |||
| { | |||
| LOLUNIT_SET_CONTEXT(k); | |||
| LOLUNIT_ASSERT_GEQUAL(bits[k], rolls / 3); | |||
| LOLUNIT_ASSERT_LEQUAL(bits[k], rolls * 2 / 3); | |||
| LOLUNIT_UNSET_CONTEXT(k); | |||
| lolunit_set_context(k); | |||
| lolunit_assert_gequal(bits[k], rolls / 3); | |||
| lolunit_assert_lequal(bits[k], rolls * 2 / 3); | |||
| lolunit_unset_context(k); | |||
| } | |||
| } | |||
| LOLUNIT_TEST(Int8Bits) | |||
| lolunit_declare_test(Int8Bits) | |||
| { | |||
| int const rolls = 2000; | |||
| @@ -93,7 +93,7 @@ LOLUNIT_FIXTURE(RandTest) | |||
| { | |||
| int8_t r = rand<int8_t>(); | |||
| LOLUNIT_ASSERT_GEQUAL(r, 0); | |||
| lolunit_assert_gequal(r, 0); | |||
| for (int k = 0; k < 7; k++) | |||
| { | |||
| @@ -104,10 +104,10 @@ LOLUNIT_FIXTURE(RandTest) | |||
| for (int k = 0; k < 7; k++) | |||
| { | |||
| LOLUNIT_SET_CONTEXT(k); | |||
| LOLUNIT_ASSERT_GEQUAL(bits[k], rolls / 3); | |||
| LOLUNIT_ASSERT_LEQUAL(bits[k], rolls * 2 / 3); | |||
| LOLUNIT_UNSET_CONTEXT(k); | |||
| lolunit_set_context(k); | |||
| lolunit_assert_gequal(bits[k], rolls / 3); | |||
| lolunit_assert_lequal(bits[k], rolls * 2 / 3); | |||
| lolunit_unset_context(k); | |||
| } | |||
| } | |||
| }; | |||
| @@ -20,56 +20,56 @@ | |||
| namespace lol | |||
| { | |||
| LOLUNIT_FIXTURE(RealTest) | |||
| lolunit_declare_fixture(RealTest) | |||
| { | |||
| LOLUNIT_TEST(Constants) | |||
| lolunit_declare_test(Constants) | |||
| { | |||
| double a0 = real::R_0(); | |||
| double a1 = real::R_1(); | |||
| double a2 = real::R_2(); | |||
| double a10 = real::R_10(); | |||
| LOLUNIT_ASSERT_EQUAL(a0, 0.0); | |||
| LOLUNIT_ASSERT_EQUAL(a1, 1.0); | |||
| LOLUNIT_ASSERT_EQUAL(a2, 2.0); | |||
| LOLUNIT_ASSERT_EQUAL(a10, 10.0); | |||
| lolunit_assert_equal(a0, 0.0); | |||
| lolunit_assert_equal(a1, 1.0); | |||
| lolunit_assert_equal(a2, 2.0); | |||
| lolunit_assert_equal(a10, 10.0); | |||
| double b1 = log(real::R_E()); | |||
| double b2 = log2(real::R_2()); | |||
| LOLUNIT_ASSERT_EQUAL(b1, 1.0); | |||
| LOLUNIT_ASSERT_EQUAL(b2, 1.0); | |||
| lolunit_assert_equal(b1, 1.0); | |||
| lolunit_assert_equal(b2, 1.0); | |||
| double c1 = exp(re(real::R_LOG2E())); | |||
| double c2 = log(exp2(real::R_LOG2E())); | |||
| LOLUNIT_ASSERT_EQUAL(c1, 2.0); | |||
| LOLUNIT_ASSERT_EQUAL(c2, 1.0); | |||
| lolunit_assert_equal(c1, 2.0); | |||
| lolunit_assert_equal(c2, 1.0); | |||
| double d1 = exp(re(real::R_LOG10E())); | |||
| LOLUNIT_ASSERT_EQUAL(d1, 10.0); | |||
| lolunit_assert_equal(d1, 10.0); | |||
| double e1 = exp(real::R_LN2()); | |||
| LOLUNIT_ASSERT_EQUAL(e1, 2.0); | |||
| lolunit_assert_equal(e1, 2.0); | |||
| double f1 = exp(real::R_LN10()); | |||
| LOLUNIT_ASSERT_EQUAL(f1, 10.0); | |||
| lolunit_assert_equal(f1, 10.0); | |||
| double g1 = sin(real::R_PI()); | |||
| double g2 = cos(real::R_PI()); | |||
| LOLUNIT_ASSERT_DOUBLES_EQUAL(g1, 0.0, 1e-100); | |||
| LOLUNIT_ASSERT_EQUAL(g2, -1.0); | |||
| lolunit_assert_doubles_equal(g1, 0.0, 1e-100); | |||
| lolunit_assert_equal(g2, -1.0); | |||
| double h1 = sin(real::R_PI_2()); | |||
| double h2 = cos(real::R_PI_2()); | |||
| LOLUNIT_ASSERT_EQUAL(h1, 1.0); | |||
| LOLUNIT_ASSERT_DOUBLES_EQUAL(h2, 0.0, 1e-100); | |||
| lolunit_assert_equal(h1, 1.0); | |||
| lolunit_assert_doubles_equal(h2, 0.0, 1e-100); | |||
| double i1 = sin(real::R_PI_4()) * sin(real::R_PI_4()); | |||
| double i2 = cos(real::R_PI_4()) * cos(real::R_PI_4()); | |||
| LOLUNIT_ASSERT_EQUAL(i1, 0.5); | |||
| LOLUNIT_ASSERT_EQUAL(i2, 0.5); | |||
| lolunit_assert_equal(i1, 0.5); | |||
| lolunit_assert_equal(i2, 0.5); | |||
| } | |||
| LOLUNIT_TEST(FloatToReal) | |||
| lolunit_declare_test(FloatToReal) | |||
| { | |||
| float a1 = real(0.0f); | |||
| float a2 = real(-0.0f); | |||
| @@ -78,15 +78,15 @@ LOLUNIT_FIXTURE(RealTest) | |||
| float a5 = real(1.5f); | |||
| float a6 = real(12345678.0f); | |||
| LOLUNIT_ASSERT_EQUAL(a1, 0.0f); | |||
| LOLUNIT_ASSERT_EQUAL(a2, -0.0f); | |||
| LOLUNIT_ASSERT_EQUAL(a3, 1.0f); | |||
| LOLUNIT_ASSERT_EQUAL(a4, -1.0f); | |||
| LOLUNIT_ASSERT_EQUAL(a5, 1.5f); | |||
| LOLUNIT_ASSERT_EQUAL(a6, 12345678.0f); | |||
| lolunit_assert_equal(a1, 0.0f); | |||
| lolunit_assert_equal(a2, -0.0f); | |||
| lolunit_assert_equal(a3, 1.0f); | |||
| lolunit_assert_equal(a4, -1.0f); | |||
| lolunit_assert_equal(a5, 1.5f); | |||
| lolunit_assert_equal(a6, 12345678.0f); | |||
| } | |||
| LOLUNIT_TEST(DoubleToReal) | |||
| lolunit_declare_test(DoubleToReal) | |||
| { | |||
| double a1 = real(0.0); | |||
| double a2 = real(-0.0); | |||
| @@ -95,30 +95,30 @@ LOLUNIT_FIXTURE(RealTest) | |||
| double a5 = real(1.5); | |||
| double a6 = real(1234567876543210.0); | |||
| LOLUNIT_ASSERT_DOUBLES_EQUAL(a1, 0.0, 0.0); | |||
| LOLUNIT_ASSERT_DOUBLES_EQUAL(a2, -0.0, 0.0); | |||
| LOLUNIT_ASSERT_DOUBLES_EQUAL(a3, 1.0, 0.0); | |||
| LOLUNIT_ASSERT_DOUBLES_EQUAL(a4, -1.0, 0.0); | |||
| LOLUNIT_ASSERT_DOUBLES_EQUAL(a5, 1.5, 0.0); | |||
| LOLUNIT_ASSERT_DOUBLES_EQUAL(a6, 1234567876543210.0, 0.0); | |||
| lolunit_assert_doubles_equal(a1, 0.0, 0.0); | |||
| lolunit_assert_doubles_equal(a2, -0.0, 0.0); | |||
| lolunit_assert_doubles_equal(a3, 1.0, 0.0); | |||
| lolunit_assert_doubles_equal(a4, -1.0, 0.0); | |||
| lolunit_assert_doubles_equal(a5, 1.5, 0.0); | |||
| lolunit_assert_doubles_equal(a6, 1234567876543210.0, 0.0); | |||
| } | |||
| LOLUNIT_TEST(Init) | |||
| lolunit_declare_test(Init) | |||
| { | |||
| real r; | |||
| float f1 = (float)r; | |||
| LOLUNIT_ASSERT_EQUAL(f1, 0.0f); | |||
| lolunit_assert_equal(f1, 0.0f); | |||
| rcmplx q; | |||
| float f2 = (float)q.x; | |||
| float f3 = (float)q.y; | |||
| LOLUNIT_ASSERT_EQUAL(f2, 0.0f); | |||
| LOLUNIT_ASSERT_EQUAL(f3, 0.0f); | |||
| lolunit_assert_equal(f2, 0.0f); | |||
| lolunit_assert_equal(f3, 0.0f); | |||
| } | |||
| LOLUNIT_TEST(StringToReal) | |||
| lolunit_declare_test(StringToReal) | |||
| { | |||
| float a1 = real("0"); | |||
| float a2 = real("1"); | |||
| @@ -129,47 +129,47 @@ LOLUNIT_FIXTURE(RealTest) | |||
| "6569604314863681793212890625") | |||
| * real("340282366920938463463374607431768211456"); | |||
| LOLUNIT_ASSERT_EQUAL(a1, 0.0f); | |||
| LOLUNIT_ASSERT_EQUAL(a2, 1.0f); | |||
| LOLUNIT_ASSERT_EQUAL(a3, -1.0f); | |||
| LOLUNIT_ASSERT_EQUAL(a4, 1.0f); | |||
| lolunit_assert_equal(a1, 0.0f); | |||
| lolunit_assert_equal(a2, 1.0f); | |||
| lolunit_assert_equal(a3, -1.0f); | |||
| lolunit_assert_equal(a4, 1.0f); | |||
| } | |||
| LOLUNIT_TEST(UnaryMinus) | |||
| lolunit_declare_test(UnaryMinus) | |||
| { | |||
| float a1 = - real(1.0f); | |||
| float a2 = - real(-1.0f); | |||
| float a3 = - real(0.0f); | |||
| float a4 = - real(-0.0f); | |||
| LOLUNIT_ASSERT_EQUAL(a1, -1.0f); | |||
| LOLUNIT_ASSERT_EQUAL(a2, 1.0f); | |||
| LOLUNIT_ASSERT_EQUAL(a3, -0.0f); | |||
| LOLUNIT_ASSERT_EQUAL(a4, 0.0f); | |||
| lolunit_assert_equal(a1, -1.0f); | |||
| lolunit_assert_equal(a2, 1.0f); | |||
| lolunit_assert_equal(a3, -0.0f); | |||
| lolunit_assert_equal(a4, 0.0f); | |||
| } | |||
| LOLUNIT_TEST(Comparison) | |||
| lolunit_declare_test(Comparison) | |||
| { | |||
| LOLUNIT_ASSERT(real(1.0f) > real(0.5f)); | |||
| LOLUNIT_ASSERT(real(1.0f) >= real(0.5f)); | |||
| LOLUNIT_ASSERT(real(1.0f) >= real(1.0f)); | |||
| LOLUNIT_ASSERT(real(-1.0f) < real(-0.5f)); | |||
| LOLUNIT_ASSERT(real(-1.0f) <= real(-0.5f)); | |||
| LOLUNIT_ASSERT(real(-1.0f) <= real(-1.0f)); | |||
| LOLUNIT_ASSERT(real(-1.0f) < real(0.5f)); | |||
| LOLUNIT_ASSERT(real(-0.5f) < real(1.0f)); | |||
| LOLUNIT_ASSERT(real(-1.0f) <= real(0.5f)); | |||
| LOLUNIT_ASSERT(real(-0.5f) <= real(1.0f)); | |||
| LOLUNIT_ASSERT(real(1.0f) > real(-0.5f)); | |||
| LOLUNIT_ASSERT(real(0.5f) > real(-1.0f)); | |||
| LOLUNIT_ASSERT(real(1.0f) >= real(-0.5f)); | |||
| LOLUNIT_ASSERT(real(0.5f) >= real(-1.0f)); | |||
| lolunit_assert(real(1.0f) > real(0.5f)); | |||
| lolunit_assert(real(1.0f) >= real(0.5f)); | |||
| lolunit_assert(real(1.0f) >= real(1.0f)); | |||
| lolunit_assert(real(-1.0f) < real(-0.5f)); | |||
| lolunit_assert(real(-1.0f) <= real(-0.5f)); | |||
| lolunit_assert(real(-1.0f) <= real(-1.0f)); | |||
| lolunit_assert(real(-1.0f) < real(0.5f)); | |||
| lolunit_assert(real(-0.5f) < real(1.0f)); | |||
| lolunit_assert(real(-1.0f) <= real(0.5f)); | |||
| lolunit_assert(real(-0.5f) <= real(1.0f)); | |||
| lolunit_assert(real(1.0f) > real(-0.5f)); | |||
| lolunit_assert(real(0.5f) > real(-1.0f)); | |||
| lolunit_assert(real(1.0f) >= real(-0.5f)); | |||
| lolunit_assert(real(0.5f) >= real(-1.0f)); | |||
| } | |||
| LOLUNIT_TEST(Addition) | |||
| lolunit_declare_test(Addition) | |||
| { | |||
| float a1 = real(1.0f) + real(0.0f); | |||
| float a2 = real(0.0f) + real(1.0f); | |||
| @@ -181,24 +181,24 @@ LOLUNIT_FIXTURE(RealTest) | |||
| float a7 = real(1.0f) + real(-0.125f); | |||
| double a8 = real(0.10000000002) + real(-2.0e-11); | |||
| LOLUNIT_ASSERT_EQUAL(a1, 1.0f); | |||
| LOLUNIT_ASSERT_EQUAL(a2, 1.0f); | |||
| LOLUNIT_ASSERT_EQUAL(a3, 2.0f); | |||
| LOLUNIT_ASSERT_EQUAL(a4, -2.0f); | |||
| LOLUNIT_ASSERT_EQUAL(a5, 1.125f); | |||
| LOLUNIT_ASSERT_DOUBLES_EQUAL(a6, 3.1361579, 0.000001); | |||
| LOLUNIT_ASSERT_EQUAL(a7, 0.875f); | |||
| LOLUNIT_ASSERT_DOUBLES_EQUAL(a8, 0.1, 1.0e-13); | |||
| lolunit_assert_equal(a1, 1.0f); | |||
| lolunit_assert_equal(a2, 1.0f); | |||
| lolunit_assert_equal(a3, 2.0f); | |||
| lolunit_assert_equal(a4, -2.0f); | |||
| lolunit_assert_equal(a5, 1.125f); | |||
| lolunit_assert_doubles_equal(a6, 3.1361579, 0.000001); | |||
| lolunit_assert_equal(a7, 0.875f); | |||
| lolunit_assert_doubles_equal(a8, 0.1, 1.0e-13); | |||
| } | |||
| LOLUNIT_TEST(Subtraction) | |||
| lolunit_declare_test(Subtraction) | |||
| { | |||
| float a1 = real(1.0f) + real(1e20f) - real(1e20f); | |||
| LOLUNIT_ASSERT_EQUAL(a1, 1.0f); | |||
| lolunit_assert_equal(a1, 1.0f); | |||
| } | |||
| LOLUNIT_TEST(Multiplication) | |||
| lolunit_declare_test(Multiplication) | |||
| { | |||
| real x(1.25f); | |||
| real y(1.5f); | |||
| @@ -210,13 +210,13 @@ LOLUNIT_FIXTURE(RealTest) | |||
| float m3 = z * z; | |||
| float m4 = w * w; | |||
| LOLUNIT_ASSERT_EQUAL(m1, 1.25f * 1.25f); | |||
| LOLUNIT_ASSERT_EQUAL(m2, 1.5f * 1.5f); | |||
| LOLUNIT_ASSERT_EQUAL(m3, 1.99999f * 1.99999f); | |||
| LOLUNIT_ASSERT_EQUAL(m4, -1.5f * -1.5f); | |||
| lolunit_assert_equal(m1, 1.25f * 1.25f); | |||
| lolunit_assert_equal(m2, 1.5f * 1.5f); | |||
| lolunit_assert_equal(m3, 1.99999f * 1.99999f); | |||
| lolunit_assert_equal(m4, -1.5f * -1.5f); | |||
| } | |||
| LOLUNIT_TEST(ExactDivision) | |||
| lolunit_declare_test(ExactDivision) | |||
| { | |||
| float m1 = real::R_1() / real::R_1(); | |||
| float m2 = real::R_2() / real::R_1(); | |||
| @@ -224,65 +224,65 @@ LOLUNIT_FIXTURE(RealTest) | |||
| float m4 = real::R_2() / real::R_2(); | |||
| float m5 = real::R_1() / -real::R_2(); | |||
| LOLUNIT_ASSERT_EQUAL(m1, 1.0f); | |||
| LOLUNIT_ASSERT_EQUAL(m2, 2.0f); | |||
| LOLUNIT_ASSERT_EQUAL(m3, 0.5f); | |||
| LOLUNIT_ASSERT_EQUAL(m4, 1.0f); | |||
| LOLUNIT_ASSERT_EQUAL(m5, -0.5f); | |||
| lolunit_assert_equal(m1, 1.0f); | |||
| lolunit_assert_equal(m2, 2.0f); | |||
| lolunit_assert_equal(m3, 0.5f); | |||
| lolunit_assert_equal(m4, 1.0f); | |||
| lolunit_assert_equal(m5, -0.5f); | |||
| } | |||
| LOLUNIT_TEST(InexactDivision) | |||
| lolunit_declare_test(InexactDivision) | |||
| { | |||
| /* 1 / 3 * 3 should be close to 1... check that it does not differ | |||
| * by more than 2^-k where k is the number of bits in the mantissa. */ | |||
| real a = real::R_1() / real::R_3() * real::R_3(); | |||
| real b = ldexp(real::R_1() - a, real::BIGITS * real::BIGIT_BITS); | |||
| LOLUNIT_ASSERT_LEQUAL((double)fabs(b), 1.0); | |||
| lolunit_assert_lequal((double)fabs(b), 1.0); | |||
| } | |||
| LOLUNIT_TEST(LoadExp) | |||
| lolunit_declare_test(LoadExp) | |||
| { | |||
| real a1(1.5); | |||
| real a2(-1.5); | |||
| real a3(0.0); | |||
| LOLUNIT_ASSERT_EQUAL((double)ldexp(a1, 7), 192.0); | |||
| LOLUNIT_ASSERT_EQUAL((double)ldexp(a1, -7), 0.01171875); | |||
| lolunit_assert_equal((double)ldexp(a1, 7), 192.0); | |||
| lolunit_assert_equal((double)ldexp(a1, -7), 0.01171875); | |||
| LOLUNIT_ASSERT_EQUAL((double)ldexp(a2, 7), -192.0); | |||
| LOLUNIT_ASSERT_EQUAL((double)ldexp(a2, -7), -0.01171875); | |||
| lolunit_assert_equal((double)ldexp(a2, 7), -192.0); | |||
| lolunit_assert_equal((double)ldexp(a2, -7), -0.01171875); | |||
| LOLUNIT_ASSERT_EQUAL((double)ldexp(a3, 7), 0.0); | |||
| LOLUNIT_ASSERT_EQUAL((double)ldexp(a3, -7), 0.0); | |||
| lolunit_assert_equal((double)ldexp(a3, 7), 0.0); | |||
| lolunit_assert_equal((double)ldexp(a3, -7), 0.0); | |||
| } | |||
| LOLUNIT_TEST(Ulp) | |||
| lolunit_declare_test(Ulp) | |||
| { | |||
| real a1 = real::R_PI(); | |||
| LOLUNIT_ASSERT_NOT_EQUAL((double)(a1 + ulp(a1) - a1), 0.0); | |||
| LOLUNIT_ASSERT_EQUAL((double)(a1 + ulp(a1) / 2 - a1), 0.0); | |||
| lolunit_assert_not_equal((double)(a1 + ulp(a1) - a1), 0.0); | |||
| lolunit_assert_equal((double)(a1 + ulp(a1) / 2 - a1), 0.0); | |||
| } | |||
| LOLUNIT_TEST(Bool) | |||
| lolunit_declare_test(Bool) | |||
| { | |||
| real a = 0.0; | |||
| LOLUNIT_ASSERT(!a); | |||
| lolunit_assert(!a); | |||
| a = -0.0; | |||
| LOLUNIT_ASSERT(!a); | |||
| lolunit_assert(!a); | |||
| a = 1234.0; | |||
| LOLUNIT_ASSERT(a); | |||
| LOLUNIT_ASSERT(!!a); | |||
| lolunit_assert(a); | |||
| lolunit_assert(!!a); | |||
| a = -1234.0; | |||
| LOLUNIT_ASSERT(a); | |||
| LOLUNIT_ASSERT(!!a); | |||
| lolunit_assert(a); | |||
| lolunit_assert(!!a); | |||
| } | |||
| LOLUNIT_TEST(AsinAcos) | |||
| lolunit_declare_test(AsinAcos) | |||
| { | |||
| double tests[] = | |||
| { | |||
| @@ -296,13 +296,13 @@ LOLUNIT_FIXTURE(RealTest) | |||
| double b = sin(asin((real)a)); | |||
| double c = cos(acos((real)a)); | |||
| LOLUNIT_SET_CONTEXT(a); | |||
| LOLUNIT_ASSERT_DOUBLES_EQUAL(b, a, 1e-100); | |||
| LOLUNIT_ASSERT_DOUBLES_EQUAL(c, a, 1e-100); | |||
| lolunit_set_context(a); | |||
| lolunit_assert_doubles_equal(b, a, 1e-100); | |||
| lolunit_assert_doubles_equal(c, a, 1e-100); | |||
| } | |||
| } | |||
| LOLUNIT_TEST(FloorCeilEtc) | |||
| lolunit_declare_test(FloorCeilEtc) | |||
| { | |||
| double tests[] = | |||
| { | |||
| @@ -338,21 +338,21 @@ LOLUNIT_FIXTURE(RealTest) | |||
| double a2 = round((real)tests[n]); | |||
| double b2 = tests[n + 3]; | |||
| LOLUNIT_ASSERT_EQUAL(b0, a0); | |||
| LOLUNIT_ASSERT_EQUAL(b1, a1); | |||
| LOLUNIT_ASSERT_EQUAL(b2, a2); | |||
| lolunit_assert_equal(b0, a0); | |||
| lolunit_assert_equal(b1, a1); | |||
| lolunit_assert_equal(b2, a2); | |||
| } | |||
| } | |||
| LOLUNIT_TEST(Pow) | |||
| lolunit_declare_test(Pow) | |||
| { | |||
| double a1 = pow(-real::R_2(), real::R_2()); | |||
| double b1 = 4.0; | |||
| LOLUNIT_ASSERT_DOUBLES_EQUAL(a1, b1, 1.0e-13); | |||
| lolunit_assert_doubles_equal(a1, b1, 1.0e-13); | |||
| double a2 = pow(-real::R_2(), real::R_3()); | |||
| double b2 = -8.0; | |||
| LOLUNIT_ASSERT_DOUBLES_EQUAL(a2, b2, 1.0e-13); | |||
| lolunit_assert_doubles_equal(a2, b2, 1.0e-13); | |||
| } | |||
| }; | |||
| @@ -18,13 +18,13 @@ | |||
| namespace lol | |||
| { | |||
| LOLUNIT_FIXTURE(RotationTest) | |||
| lolunit_declare_fixture(RotationTest) | |||
| { | |||
| void SetUp() {} | |||
| void TearDown() {} | |||
| LOLUNIT_TEST(Rotate2D) | |||
| lolunit_declare_test(Rotate2D) | |||
| { | |||
| /* Rotations must be CCW */ | |||
| mat2 m90 = mat2::rotate(90.f); | |||
| @@ -32,29 +32,29 @@ LOLUNIT_FIXTURE(RotationTest) | |||
| vec2 a(2.f, 3.f); | |||
| vec2 b = m90 * a; | |||
| LOLUNIT_ASSERT_DOUBLES_EQUAL(b.x, -a.y, 1e-5); | |||
| LOLUNIT_ASSERT_DOUBLES_EQUAL(b.y, a.x, 1e-5); | |||
| lolunit_assert_doubles_equal(b.x, -a.y, 1e-5); | |||
| lolunit_assert_doubles_equal(b.y, a.x, 1e-5); | |||
| float d = determinant(m90); | |||
| LOLUNIT_ASSERT_DOUBLES_EQUAL(d, 1.0, 1e-5); | |||
| lolunit_assert_doubles_equal(d, 1.0, 1e-5); | |||
| } | |||
| LOLUNIT_TEST(Compose2D) | |||
| lolunit_declare_test(Compose2D) | |||
| { | |||
| /* Rotating 20 degrees twice must equal rotating 40 degrees */ | |||
| mat2 m20 = mat2::rotate(20.f); | |||
| mat2 m40 = mat2::rotate(40.f); | |||
| mat2 m20x20 = m20 * m20; | |||
| LOLUNIT_ASSERT_DOUBLES_EQUAL(m20x20[0][0], m40[0][0], 1e-5); | |||
| LOLUNIT_ASSERT_DOUBLES_EQUAL(m20x20[1][0], m40[1][0], 1e-5); | |||
| lolunit_assert_doubles_equal(m20x20[0][0], m40[0][0], 1e-5); | |||
| lolunit_assert_doubles_equal(m20x20[1][0], m40[1][0], 1e-5); | |||
| LOLUNIT_ASSERT_DOUBLES_EQUAL(m20x20[0][1], m40[0][1], 1e-5); | |||
| LOLUNIT_ASSERT_DOUBLES_EQUAL(m20x20[1][1], m40[1][1], 1e-5); | |||
| lolunit_assert_doubles_equal(m20x20[0][1], m40[0][1], 1e-5); | |||
| lolunit_assert_doubles_equal(m20x20[1][1], m40[1][1], 1e-5); | |||
| } | |||
| LOLUNIT_TEST(Rotate3D) | |||
| lolunit_declare_test(Rotate3D) | |||
| { | |||
| /* Rotations must be CCW along each axis */ | |||
| mat3 m90x = mat3::rotate(90.f, 1.f, 0.f, 0.f); | |||
| @@ -66,48 +66,48 @@ LOLUNIT_FIXTURE(RotationTest) | |||
| vec3 c = m90y * a; | |||
| vec3 d = m90z * a; | |||
| LOLUNIT_ASSERT_DOUBLES_EQUAL(b.x, a.x, 1e-5); | |||
| LOLUNIT_ASSERT_DOUBLES_EQUAL(b.y, -a.z, 1e-5); | |||
| LOLUNIT_ASSERT_DOUBLES_EQUAL(b.z, a.y, 1e-5); | |||
| lolunit_assert_doubles_equal(b.x, a.x, 1e-5); | |||
| lolunit_assert_doubles_equal(b.y, -a.z, 1e-5); | |||
| lolunit_assert_doubles_equal(b.z, a.y, 1e-5); | |||
| LOLUNIT_ASSERT_DOUBLES_EQUAL(c.x, a.z, 1e-5); | |||
| LOLUNIT_ASSERT_DOUBLES_EQUAL(c.y, a.y, 1e-5); | |||
| LOLUNIT_ASSERT_DOUBLES_EQUAL(c.z, -a.x, 1e-5); | |||
| lolunit_assert_doubles_equal(c.x, a.z, 1e-5); | |||
| lolunit_assert_doubles_equal(c.y, a.y, 1e-5); | |||
| lolunit_assert_doubles_equal(c.z, -a.x, 1e-5); | |||
| LOLUNIT_ASSERT_DOUBLES_EQUAL(d.x, -a.y, 1e-5); | |||
| LOLUNIT_ASSERT_DOUBLES_EQUAL(d.y, a.x, 1e-5); | |||
| LOLUNIT_ASSERT_DOUBLES_EQUAL(d.z, a.z, 1e-5); | |||
| lolunit_assert_doubles_equal(d.x, -a.y, 1e-5); | |||
| lolunit_assert_doubles_equal(d.y, a.x, 1e-5); | |||
| lolunit_assert_doubles_equal(d.z, a.z, 1e-5); | |||
| float dx = determinant(m90x); | |||
| float dy = determinant(m90y); | |||
| float dz = determinant(m90z); | |||
| LOLUNIT_ASSERT_DOUBLES_EQUAL(dx, 1.0, 1e-5); | |||
| LOLUNIT_ASSERT_DOUBLES_EQUAL(dy, 1.0, 1e-5); | |||
| LOLUNIT_ASSERT_DOUBLES_EQUAL(dz, 1.0, 1e-5); | |||
| lolunit_assert_doubles_equal(dx, 1.0, 1e-5); | |||
| lolunit_assert_doubles_equal(dy, 1.0, 1e-5); | |||
| lolunit_assert_doubles_equal(dz, 1.0, 1e-5); | |||
| } | |||
| LOLUNIT_TEST(Compose3D) | |||
| lolunit_declare_test(Compose3D) | |||
| { | |||
| /* Rotating 20 degrees twice must equal rotating 40 degrees */ | |||
| mat3 m20 = mat3::rotate(20.f, 1.f, 2.f, 3.f); | |||
| mat3 m40 = mat3::rotate(40.f, 1.f, 2.f, 3.f); | |||
| mat3 m20x20 = m20 * m20; | |||
| LOLUNIT_ASSERT_DOUBLES_EQUAL(m20x20[0][0], m40[0][0], 1e-5); | |||
| LOLUNIT_ASSERT_DOUBLES_EQUAL(m20x20[1][0], m40[1][0], 1e-5); | |||
| LOLUNIT_ASSERT_DOUBLES_EQUAL(m20x20[2][0], m40[2][0], 1e-5); | |||
| lolunit_assert_doubles_equal(m20x20[0][0], m40[0][0], 1e-5); | |||
| lolunit_assert_doubles_equal(m20x20[1][0], m40[1][0], 1e-5); | |||
| lolunit_assert_doubles_equal(m20x20[2][0], m40[2][0], 1e-5); | |||
| LOLUNIT_ASSERT_DOUBLES_EQUAL(m20x20[0][1], m40[0][1], 1e-5); | |||
| LOLUNIT_ASSERT_DOUBLES_EQUAL(m20x20[1][1], m40[1][1], 1e-5); | |||
| LOLUNIT_ASSERT_DOUBLES_EQUAL(m20x20[2][1], m40[2][1], 1e-5); | |||
| lolunit_assert_doubles_equal(m20x20[0][1], m40[0][1], 1e-5); | |||
| lolunit_assert_doubles_equal(m20x20[1][1], m40[1][1], 1e-5); | |||
| lolunit_assert_doubles_equal(m20x20[2][1], m40[2][1], 1e-5); | |||
| LOLUNIT_ASSERT_DOUBLES_EQUAL(m20x20[0][2], m40[0][2], 1e-5); | |||
| LOLUNIT_ASSERT_DOUBLES_EQUAL(m20x20[1][2], m40[1][2], 1e-5); | |||
| LOLUNIT_ASSERT_DOUBLES_EQUAL(m20x20[2][2], m40[2][2], 1e-5); | |||
| lolunit_assert_doubles_equal(m20x20[0][2], m40[0][2], 1e-5); | |||
| lolunit_assert_doubles_equal(m20x20[1][2], m40[1][2], 1e-5); | |||
| lolunit_assert_doubles_equal(m20x20[2][2], m40[2][2], 1e-5); | |||
| } | |||
| LOLUNIT_TEST(QuaternionTransform) | |||
| lolunit_declare_test(QuaternionTransform) | |||
| { | |||
| /* Rotating using a quaternion must equal rotating using a matrix */ | |||
| mat3 m20 = mat3::rotate(20.f, 1.f, 2.f, 3.f); | |||
| @@ -117,61 +117,61 @@ LOLUNIT_FIXTURE(RotationTest) | |||
| vec3 b = m20 * a; | |||
| vec3 c = q20.transform(a); | |||
| LOLUNIT_ASSERT_DOUBLES_EQUAL(c.x, b.x, 1e-5); | |||
| LOLUNIT_ASSERT_DOUBLES_EQUAL(c.y, b.y, 1e-5); | |||
| LOLUNIT_ASSERT_DOUBLES_EQUAL(c.z, b.z, 1e-5); | |||
| lolunit_assert_doubles_equal(c.x, b.x, 1e-5); | |||
| lolunit_assert_doubles_equal(c.y, b.y, 1e-5); | |||
| lolunit_assert_doubles_equal(c.z, b.z, 1e-5); | |||
| float n = norm(q20); | |||
| LOLUNIT_ASSERT_DOUBLES_EQUAL(n, 1.0, 1e-5); | |||
| lolunit_assert_doubles_equal(n, 1.0, 1e-5); | |||
| } | |||
| LOLUNIT_TEST(QuaternionFromMatrix) | |||
| lolunit_declare_test(QuaternionFromMatrix) | |||
| { | |||
| /* A rotation matrix converted to a quaternion should match the | |||
| * quaternion built with the same parameters */ | |||
| quat q1 = quat::rotate(20.f, 1.f, 2.f, 3.f); | |||
| quat q2 = quat(mat3::rotate(20.f, 1.f, 2.f, 3.f)); | |||
| LOLUNIT_ASSERT_DOUBLES_EQUAL(q2.w, q1.w, 1e-5); | |||
| LOLUNIT_ASSERT_DOUBLES_EQUAL(q2.x, q1.x, 1e-5); | |||
| LOLUNIT_ASSERT_DOUBLES_EQUAL(q2.y, q1.y, 1e-5); | |||
| LOLUNIT_ASSERT_DOUBLES_EQUAL(q2.z, q1.z, 1e-5); | |||
| lolunit_assert_doubles_equal(q2.w, q1.w, 1e-5); | |||
| lolunit_assert_doubles_equal(q2.x, q1.x, 1e-5); | |||
| lolunit_assert_doubles_equal(q2.y, q1.y, 1e-5); | |||
| lolunit_assert_doubles_equal(q2.z, q1.z, 1e-5); | |||
| float n1 = norm(q1); | |||
| float n2 = norm(q2); | |||
| LOLUNIT_ASSERT_DOUBLES_EQUAL(n1, 1.0, 1e-5); | |||
| LOLUNIT_ASSERT_DOUBLES_EQUAL(n2, 1.0, 1e-5); | |||
| lolunit_assert_doubles_equal(n1, 1.0, 1e-5); | |||
| lolunit_assert_doubles_equal(n2, 1.0, 1e-5); | |||
| } | |||
| LOLUNIT_TEST(MatrixFromQuaternion) | |||
| lolunit_declare_test(MatrixFromQuaternion) | |||
| { | |||
| /* A quaternion converted to a rotation matrix should match the | |||
| * rotation matrix built with the same parameters */ | |||
| mat3 m1 = mat3::rotate(60.f, 1.f, -2.f, 3.f); | |||
| mat3 m2 = mat3(quat::rotate(60.f, 1.f, -2.f, 3.f)); | |||
| LOLUNIT_ASSERT_DOUBLES_EQUAL(m2[0][0], m1[0][0], 1e-5); | |||
| LOLUNIT_ASSERT_DOUBLES_EQUAL(m2[1][0], m1[1][0], 1e-5); | |||
| LOLUNIT_ASSERT_DOUBLES_EQUAL(m2[2][0], m1[2][0], 1e-5); | |||
| lolunit_assert_doubles_equal(m2[0][0], m1[0][0], 1e-5); | |||
| lolunit_assert_doubles_equal(m2[1][0], m1[1][0], 1e-5); | |||
| lolunit_assert_doubles_equal(m2[2][0], m1[2][0], 1e-5); | |||
| LOLUNIT_ASSERT_DOUBLES_EQUAL(m2[0][1], m1[0][1], 1e-5); | |||
| LOLUNIT_ASSERT_DOUBLES_EQUAL(m2[1][1], m1[1][1], 1e-5); | |||
| LOLUNIT_ASSERT_DOUBLES_EQUAL(m2[2][1], m1[2][1], 1e-5); | |||
| lolunit_assert_doubles_equal(m2[0][1], m1[0][1], 1e-5); | |||
| lolunit_assert_doubles_equal(m2[1][1], m1[1][1], 1e-5); | |||
| lolunit_assert_doubles_equal(m2[2][1], m1[2][1], 1e-5); | |||
| LOLUNIT_ASSERT_DOUBLES_EQUAL(m2[0][2], m1[0][2], 1e-5); | |||
| LOLUNIT_ASSERT_DOUBLES_EQUAL(m2[1][2], m1[1][2], 1e-5); | |||
| LOLUNIT_ASSERT_DOUBLES_EQUAL(m2[2][2], m1[2][2], 1e-5); | |||
| lolunit_assert_doubles_equal(m2[0][2], m1[0][2], 1e-5); | |||
| lolunit_assert_doubles_equal(m2[1][2], m1[1][2], 1e-5); | |||
| lolunit_assert_doubles_equal(m2[2][2], m1[2][2], 1e-5); | |||
| float d1 = determinant(m1); | |||
| float d2 = determinant(m2); | |||
| LOLUNIT_ASSERT_DOUBLES_EQUAL(d1, 1.0, 1e-5); | |||
| LOLUNIT_ASSERT_DOUBLES_EQUAL(d2, 1.0, 1e-5); | |||
| lolunit_assert_doubles_equal(d1, 1.0, 1e-5); | |||
| lolunit_assert_doubles_equal(d2, 1.0, 1e-5); | |||
| } | |||
| LOLUNIT_TEST(MatrixCompositionThroughQuaternions) | |||
| lolunit_declare_test(MatrixCompositionThroughQuaternions) | |||
| { | |||
| /* Combining two rotation matrices should match the matrix created | |||
| * from the combination of the two equivalent quaternions */ | |||
| @@ -181,20 +181,20 @@ LOLUNIT_FIXTURE(RotationTest) | |||
| mat3 m3 = m2 * m1; | |||
| mat3 m4(quat(m2) * quat(m1)); | |||
| LOLUNIT_ASSERT_DOUBLES_EQUAL(m4[0][0], m3[0][0], 1e-5); | |||
| LOLUNIT_ASSERT_DOUBLES_EQUAL(m4[1][0], m3[1][0], 1e-5); | |||
| LOLUNIT_ASSERT_DOUBLES_EQUAL(m4[2][0], m3[2][0], 1e-5); | |||
| lolunit_assert_doubles_equal(m4[0][0], m3[0][0], 1e-5); | |||
| lolunit_assert_doubles_equal(m4[1][0], m3[1][0], 1e-5); | |||
| lolunit_assert_doubles_equal(m4[2][0], m3[2][0], 1e-5); | |||
| LOLUNIT_ASSERT_DOUBLES_EQUAL(m4[0][1], m3[0][1], 1e-5); | |||
| LOLUNIT_ASSERT_DOUBLES_EQUAL(m4[1][1], m3[1][1], 1e-5); | |||
| LOLUNIT_ASSERT_DOUBLES_EQUAL(m4[2][1], m3[2][1], 1e-5); | |||
| lolunit_assert_doubles_equal(m4[0][1], m3[0][1], 1e-5); | |||
| lolunit_assert_doubles_equal(m4[1][1], m3[1][1], 1e-5); | |||
| lolunit_assert_doubles_equal(m4[2][1], m3[2][1], 1e-5); | |||
| LOLUNIT_ASSERT_DOUBLES_EQUAL(m4[0][2], m3[0][2], 1e-5); | |||
| LOLUNIT_ASSERT_DOUBLES_EQUAL(m4[1][2], m3[1][2], 1e-5); | |||
| LOLUNIT_ASSERT_DOUBLES_EQUAL(m4[2][2], m3[2][2], 1e-5); | |||
| lolunit_assert_doubles_equal(m4[0][2], m3[0][2], 1e-5); | |||
| lolunit_assert_doubles_equal(m4[1][2], m3[1][2], 1e-5); | |||
| lolunit_assert_doubles_equal(m4[2][2], m3[2][2], 1e-5); | |||
| } | |||
| LOLUNIT_TEST(QuaternionCompositionThroughMatrices) | |||
| lolunit_declare_test(QuaternionCompositionThroughMatrices) | |||
| { | |||
| /* Combining two quaternions should match the quaternion created | |||
| * from the combination of the two equivalent rotation matrices */ | |||
| @@ -204,10 +204,10 @@ LOLUNIT_FIXTURE(RotationTest) | |||
| quat q3 = q2 * q1; | |||
| quat q4(mat3(q2) * mat3(q1)); | |||
| LOLUNIT_ASSERT_DOUBLES_EQUAL(q4.w, q3.w, 1e-5); | |||
| LOLUNIT_ASSERT_DOUBLES_EQUAL(q4.x, q3.x, 1e-5); | |||
| LOLUNIT_ASSERT_DOUBLES_EQUAL(q4.y, q3.y, 1e-5); | |||
| LOLUNIT_ASSERT_DOUBLES_EQUAL(q4.z, q3.z, 1e-5); | |||
| lolunit_assert_doubles_equal(q4.w, q3.w, 1e-5); | |||
| lolunit_assert_doubles_equal(q4.x, q3.x, 1e-5); | |||
| lolunit_assert_doubles_equal(q4.y, q3.y, 1e-5); | |||
| lolunit_assert_doubles_equal(q4.z, q3.z, 1e-5); | |||
| } | |||
| }; | |||
| @@ -20,24 +20,24 @@ | |||
| namespace lol | |||
| { | |||
| LOLUNIT_FIXTURE(TrigTest) | |||
| lolunit_declare_fixture(TrigTest) | |||
| { | |||
| LOLUNIT_TEST(AngleConversions) | |||
| lolunit_declare_test(AngleConversions) | |||
| { | |||
| LOLUNIT_ASSERT_DOUBLES_EQUAL(D_PI, radians(180.0), 1e-5); | |||
| LOLUNIT_ASSERT_DOUBLES_EQUAL(D_PI_2, radians(90.0), 1e-5); | |||
| lolunit_assert_doubles_equal(D_PI, radians(180.0), 1e-5); | |||
| lolunit_assert_doubles_equal(D_PI_2, radians(90.0), 1e-5); | |||
| LOLUNIT_ASSERT_DOUBLES_EQUAL(F_PI, radians(180.0f), 1e-5f); | |||
| LOLUNIT_ASSERT_DOUBLES_EQUAL(F_PI_2, radians(90.0f), 1e-5f); | |||
| lolunit_assert_doubles_equal(F_PI, radians(180.0f), 1e-5f); | |||
| lolunit_assert_doubles_equal(F_PI_2, radians(90.0f), 1e-5f); | |||
| LOLUNIT_ASSERT_DOUBLES_EQUAL(180.0, degrees(D_PI), 1e-5); | |||
| LOLUNIT_ASSERT_DOUBLES_EQUAL(90.0, degrees(D_PI_2), 1e-5); | |||
| lolunit_assert_doubles_equal(180.0, degrees(D_PI), 1e-5); | |||
| lolunit_assert_doubles_equal(90.0, degrees(D_PI_2), 1e-5); | |||
| LOLUNIT_ASSERT_DOUBLES_EQUAL(180.0f, degrees(F_PI), 1e-5f); | |||
| LOLUNIT_ASSERT_DOUBLES_EQUAL(90.0f, degrees(F_PI_2), 1e-5f); | |||
| lolunit_assert_doubles_equal(180.0f, degrees(F_PI), 1e-5f); | |||
| lolunit_assert_doubles_equal(90.0f, degrees(F_PI_2), 1e-5f); | |||
| } | |||
| LOLUNIT_TEST(Sin) | |||
| lolunit_declare_test(Sin) | |||
| { | |||
| using std::fabs; | |||
| @@ -50,8 +50,8 @@ LOLUNIT_FIXTURE(TrigTest) | |||
| double a = std::sin(f); | |||
| #endif | |||
| double b = lol_sin(f); | |||
| LOLUNIT_SET_CONTEXT(f); | |||
| LOLUNIT_ASSERT_DOUBLES_EQUAL(a, b, fabs(f) * 1e-11); | |||
| lolunit_set_context(f); | |||
| lolunit_assert_doubles_equal(a, b, fabs(f) * 1e-11); | |||
| } | |||
| for (int i = -10000; i < 10000; i++) | |||
| @@ -63,12 +63,12 @@ LOLUNIT_FIXTURE(TrigTest) | |||
| double a = std::sin(f); | |||
| #endif | |||
| double b = lol_sin(f); | |||
| LOLUNIT_SET_CONTEXT(f); | |||
| LOLUNIT_ASSERT_DOUBLES_EQUAL(a, b, fabs(f) * 1e-11); | |||
| lolunit_set_context(f); | |||
| lolunit_assert_doubles_equal(a, b, fabs(f) * 1e-11); | |||
| } | |||
| } | |||
| LOLUNIT_TEST(Cos) | |||
| lolunit_declare_test(Cos) | |||
| { | |||
| using std::fabs; | |||
| @@ -81,8 +81,8 @@ LOLUNIT_FIXTURE(TrigTest) | |||
| double a = std::cos(f); | |||
| #endif | |||
| double b = lol_cos(f); | |||
| LOLUNIT_SET_CONTEXT(f); | |||
| LOLUNIT_ASSERT_DOUBLES_EQUAL(a, b, fabs(f) * 1e-11); | |||
| lolunit_set_context(f); | |||
| lolunit_assert_doubles_equal(a, b, fabs(f) * 1e-11); | |||
| } | |||
| for (int i = -10000; i < 10000; i++) | |||
| @@ -94,12 +94,12 @@ LOLUNIT_FIXTURE(TrigTest) | |||
| double a = std::cos(f); | |||
| #endif | |||
| double b = lol_cos(f); | |||
| LOLUNIT_SET_CONTEXT(f); | |||
| LOLUNIT_ASSERT_DOUBLES_EQUAL(a, b, fabs(f) * 1e-11); | |||
| lolunit_set_context(f); | |||
| lolunit_assert_doubles_equal(a, b, fabs(f) * 1e-11); | |||
| } | |||
| } | |||
| LOLUNIT_TEST(SinCos) | |||
| lolunit_declare_test(SinCos) | |||
| { | |||
| using std::fabs; | |||
| @@ -115,9 +115,9 @@ LOLUNIT_FIXTURE(TrigTest) | |||
| #endif | |||
| double b1, b2; | |||
| lol_sincos(f, &b1, &b2); | |||
| LOLUNIT_SET_CONTEXT(f); | |||
| LOLUNIT_ASSERT_DOUBLES_EQUAL(a1, b1, fabs(f) * 1e-11); | |||
| LOLUNIT_ASSERT_DOUBLES_EQUAL(a2, b2, fabs(f) * 1e-11); | |||
| lolunit_set_context(f); | |||
| 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++) | |||
| @@ -132,13 +132,13 @@ LOLUNIT_FIXTURE(TrigTest) | |||
| #endif | |||
| double b1, b2; | |||
| lol_sincos(f, &b1, &b2); | |||
| LOLUNIT_SET_CONTEXT(f); | |||
| LOLUNIT_ASSERT_DOUBLES_EQUAL(a1, b1, fabs(f) * 1e-11); | |||
| LOLUNIT_ASSERT_DOUBLES_EQUAL(a2, b2, fabs(f) * 1e-11); | |||
| lolunit_set_context(f); | |||
| lolunit_assert_doubles_equal(a1, b1, fabs(f) * 1e-11); | |||
| lolunit_assert_doubles_equal(a2, b2, fabs(f) * 1e-11); | |||
| } | |||
| } | |||
| LOLUNIT_TEST(Tan) | |||
| lolunit_declare_test(Tan) | |||
| { | |||
| using std::fabs; | |||
| @@ -151,13 +151,13 @@ LOLUNIT_FIXTURE(TrigTest) | |||
| double a = std::tan(f); | |||
| #endif | |||
| double b = lol_tan(f); | |||
| LOLUNIT_SET_CONTEXT(f); | |||
| lolunit_set_context(f); | |||
| if (fabs(a) > 1e4) | |||
| LOLUNIT_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) | |||
| LOLUNIT_ASSERT_DOUBLES_EQUAL(a, b, fabs(a) * 1e-11); | |||
| lolunit_assert_doubles_equal(a, b, fabs(a) * 1e-11); | |||
| else | |||
| LOLUNIT_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++) | |||
| @@ -169,13 +169,13 @@ LOLUNIT_FIXTURE(TrigTest) | |||
| double a = std::tan(f); | |||
| #endif | |||
| double b = lol_tan(f); | |||
| LOLUNIT_SET_CONTEXT(f); | |||
| lolunit_set_context(f); | |||
| if (fabs(a) > 1e4) | |||
| LOLUNIT_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) | |||
| LOLUNIT_ASSERT_DOUBLES_EQUAL(a, b, fabs(a) * 1e-11); | |||
| lolunit_assert_doubles_equal(a, b, fabs(a) * 1e-11); | |||
| else | |||
| LOLUNIT_ASSERT_DOUBLES_EQUAL(a, b, fabs(f) * 1e-11); | |||
| lolunit_assert_doubles_equal(a, b, fabs(f) * 1e-11); | |||
| } | |||
| } | |||
| }; | |||
| @@ -18,40 +18,40 @@ | |||
| namespace lol | |||
| { | |||
| LOLUNIT_FIXTURE(VectorTest) | |||
| lolunit_declare_fixture(VectorTest) | |||
| { | |||
| void SetUp() {} | |||
| void TearDown() {} | |||
| LOLUNIT_TEST(VectorEquality) | |||
| lolunit_declare_test(VectorEquality) | |||
| { | |||
| vec2 a2(1.0f, 2.0f); | |||
| vec2 b2(0.0f, 2.0f); | |||
| vec2 c2(1.0f, 0.0f); | |||
| LOLUNIT_ASSERT_EQUAL(a2, a2); | |||
| LOLUNIT_ASSERT_NOT_DIFFERENT(a2, a2); | |||
| lolunit_assert_equal(a2, a2); | |||
| lolunit_assert_not_different(a2, a2); | |||
| LOLUNIT_ASSERT_DIFFERENT(a2, b2); | |||
| LOLUNIT_ASSERT_NOT_EQUAL(a2, b2); | |||
| LOLUNIT_ASSERT_DIFFERENT(a2, c2); | |||
| LOLUNIT_ASSERT_NOT_EQUAL(a2, c2); | |||
| lolunit_assert_different(a2, b2); | |||
| lolunit_assert_not_equal(a2, b2); | |||
| lolunit_assert_different(a2, c2); | |||
| lolunit_assert_not_equal(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); | |||
| LOLUNIT_ASSERT_EQUAL(a3, a3); | |||
| LOLUNIT_ASSERT_NOT_DIFFERENT(a3, a3); | |||
| lolunit_assert_equal(a3, a3); | |||
| lolunit_assert_not_different(a3, a3); | |||
| LOLUNIT_ASSERT_DIFFERENT(a3, b3); | |||
| LOLUNIT_ASSERT_NOT_EQUAL(a3, b3); | |||
| LOLUNIT_ASSERT_DIFFERENT(a3, c3); | |||
| LOLUNIT_ASSERT_NOT_EQUAL(a3, c3); | |||
| LOLUNIT_ASSERT_DIFFERENT(a3, d3); | |||
| LOLUNIT_ASSERT_NOT_EQUAL(a3, d3); | |||
| lolunit_assert_different(a3, b3); | |||
| lolunit_assert_not_equal(a3, b3); | |||
| lolunit_assert_different(a3, c3); | |||
| lolunit_assert_not_equal(a3, c3); | |||
| lolunit_assert_different(a3, d3); | |||
| lolunit_assert_not_equal(a3, d3); | |||
| vec4 a4(1.0f, 2.0f, 3.0f, 4.0f); | |||
| vec4 b4(0.0f, 2.0f, 3.0f, 4.0f); | |||
| @@ -59,20 +59,20 @@ LOLUNIT_FIXTURE(VectorTest) | |||
| vec4 d4(1.0f, 2.0f, 0.0f, 4.0f); | |||
| vec4 e4(1.0f, 2.0f, 3.0f, 0.0f); | |||
| LOLUNIT_ASSERT_EQUAL(a4, a4); | |||
| LOLUNIT_ASSERT_NOT_DIFFERENT(a4, a4); | |||
| LOLUNIT_ASSERT_DIFFERENT(a4, b4); | |||
| LOLUNIT_ASSERT_NOT_EQUAL(a4, b4); | |||
| LOLUNIT_ASSERT_DIFFERENT(a4, c4); | |||
| LOLUNIT_ASSERT_NOT_EQUAL(a4, c4); | |||
| LOLUNIT_ASSERT_DIFFERENT(a4, d4); | |||
| LOLUNIT_ASSERT_NOT_EQUAL(a4, d4); | |||
| LOLUNIT_ASSERT_DIFFERENT(a4, e4); | |||
| LOLUNIT_ASSERT_NOT_EQUAL(a4, e4); | |||
| lolunit_assert_equal(a4, a4); | |||
| lolunit_assert_not_different(a4, a4); | |||
| lolunit_assert_different(a4, b4); | |||
| lolunit_assert_not_equal(a4, b4); | |||
| lolunit_assert_different(a4, c4); | |||
| lolunit_assert_not_equal(a4, c4); | |||
| lolunit_assert_different(a4, d4); | |||
| lolunit_assert_not_equal(a4, d4); | |||
| lolunit_assert_different(a4, e4); | |||
| lolunit_assert_not_equal(a4, e4); | |||
| } | |||
| LOLUNIT_TEST(VectorInequality) | |||
| lolunit_declare_test(VectorInequality) | |||
| { | |||
| vec2 a2(1.0f, 3.0f); | |||
| vec2 b2(0.0f, 0.0f); | |||
| @@ -81,52 +81,52 @@ LOLUNIT_FIXTURE(VectorTest) | |||
| vec2 e2(3.0f, 3.0f); | |||
| vec2 f2(4.0f, 4.0f); | |||
| LOLUNIT_ASSERT_LEQUAL(a2, a2); | |||
| LOLUNIT_ASSERT_NOT_LESS(a2, a2); | |||
| LOLUNIT_ASSERT_NOT_LEQUAL(a2, b2); | |||
| LOLUNIT_ASSERT_NOT_LESS(a2, b2); | |||
| LOLUNIT_ASSERT_NOT_LEQUAL(a2, c2); | |||
| LOLUNIT_ASSERT_NOT_LESS(a2, c2); | |||
| LOLUNIT_ASSERT_NOT_LEQUAL(a2, d2); | |||
| LOLUNIT_ASSERT_NOT_LESS(a2, d2); | |||
| LOLUNIT_ASSERT_LEQUAL(a2, e2); | |||
| LOLUNIT_ASSERT_NOT_LESS(a2, e2); | |||
| LOLUNIT_ASSERT_LEQUAL(a2, f2); | |||
| LOLUNIT_ASSERT_LESS(a2, f2); | |||
| lolunit_assert_lequal(a2, a2); | |||
| lolunit_assert_not_less(a2, a2); | |||
| lolunit_assert_not_lequal(a2, b2); | |||
| lolunit_assert_not_less(a2, b2); | |||
| lolunit_assert_not_lequal(a2, c2); | |||
| lolunit_assert_not_less(a2, c2); | |||
| lolunit_assert_not_lequal(a2, d2); | |||
| lolunit_assert_not_less(a2, d2); | |||
| lolunit_assert_lequal(a2, e2); | |||
| lolunit_assert_not_less(a2, e2); | |||
| lolunit_assert_lequal(a2, f2); | |||
| lolunit_assert_less(a2, f2); | |||
| } | |||
| LOLUNIT_TEST(VectorInit) | |||
| lolunit_declare_test(VectorInit) | |||
| { | |||
| vec2 a { 1.f, 2.f }; | |||
| LOLUNIT_ASSERT_EQUAL(1.f, a.x); | |||
| LOLUNIT_ASSERT_EQUAL(2.f, a.y); | |||
| lolunit_assert_equal(1.f, a.x); | |||
| lolunit_assert_equal(2.f, a.y); | |||
| vec3 b { 1.f, 2.f, 3.f }; | |||
| LOLUNIT_ASSERT_EQUAL(1.f, b.x); | |||
| LOLUNIT_ASSERT_EQUAL(2.f, b.y); | |||
| LOLUNIT_ASSERT_EQUAL(3.f, b.z); | |||
| lolunit_assert_equal(1.f, b.x); | |||
| lolunit_assert_equal(2.f, b.y); | |||
| lolunit_assert_equal(3.f, b.z); | |||
| vec4 c { 1.f, 2.f, 3.f, 4.f }; | |||
| LOLUNIT_ASSERT_EQUAL(1.f, c.x); | |||
| LOLUNIT_ASSERT_EQUAL(2.f, c.y); | |||
| LOLUNIT_ASSERT_EQUAL(3.f, c.z); | |||
| LOLUNIT_ASSERT_EQUAL(4.f, c.w); | |||
| lolunit_assert_equal(1.f, c.x); | |||
| lolunit_assert_equal(2.f, c.y); | |||
| lolunit_assert_equal(3.f, c.z); | |||
| lolunit_assert_equal(4.f, c.w); | |||
| vec_t<float, 10> d { 1.f, 2.f, 3.f, 4.f, 5.f }; | |||
| LOLUNIT_ASSERT_EQUAL(1.f, d[0]); | |||
| LOLUNIT_ASSERT_EQUAL(2.f, d[1]); | |||
| LOLUNIT_ASSERT_EQUAL(3.f, d[2]); | |||
| LOLUNIT_ASSERT_EQUAL(4.f, d[3]); | |||
| LOLUNIT_ASSERT_EQUAL(5.f, d[4]); | |||
| LOLUNIT_ASSERT_EQUAL(0.f, d[5]); | |||
| LOLUNIT_ASSERT_EQUAL(0.f, d[6]); | |||
| LOLUNIT_ASSERT_EQUAL(0.f, d[7]); | |||
| LOLUNIT_ASSERT_EQUAL(0.f, d[8]); | |||
| LOLUNIT_ASSERT_EQUAL(0.f, d[9]); | |||
| lolunit_assert_equal(1.f, d[0]); | |||
| lolunit_assert_equal(2.f, d[1]); | |||
| lolunit_assert_equal(3.f, d[2]); | |||
| lolunit_assert_equal(4.f, d[3]); | |||
| lolunit_assert_equal(5.f, d[4]); | |||
| lolunit_assert_equal(0.f, d[5]); | |||
| lolunit_assert_equal(0.f, d[6]); | |||
| lolunit_assert_equal(0.f, d[7]); | |||
| lolunit_assert_equal(0.f, d[8]); | |||
| lolunit_assert_equal(0.f, d[9]); | |||
| } | |||
| LOLUNIT_TEST(VectorSwizzle) | |||
| lolunit_declare_test(VectorSwizzle) | |||
| { | |||
| vec3 a(1.0f, 2.0f, 3.0f); | |||
| vec3 b(4.0f, 5.0f, 6.0f); | |||
| @@ -134,134 +134,134 @@ LOLUNIT_FIXTURE(VectorTest) | |||
| c = a; | |||
| c.x = b.y; | |||
| LOLUNIT_ASSERT_EQUAL(c.x, 5.0f); | |||
| LOLUNIT_ASSERT_EQUAL(c.y, 2.0f); | |||
| LOLUNIT_ASSERT_EQUAL(c.z, 3.0f); | |||
| lolunit_assert_equal(c.x, 5.0f); | |||
| lolunit_assert_equal(c.y, 2.0f); | |||
| lolunit_assert_equal(c.z, 3.0f); | |||
| c = a.zyx; | |||
| LOLUNIT_ASSERT_EQUAL(c.x, 3.0f); | |||
| LOLUNIT_ASSERT_EQUAL(c.y, 2.0f); | |||
| LOLUNIT_ASSERT_EQUAL(c.z, 1.0f); | |||
| lolunit_assert_equal(c.x, 3.0f); | |||
| lolunit_assert_equal(c.y, 2.0f); | |||
| lolunit_assert_equal(c.z, 1.0f); | |||
| #if 0 /* Visual Studio doesn't support these yet. */ | |||
| c = a; | |||
| c.xy = b.yz; | |||
| LOLUNIT_ASSERT_EQUAL(c.x, 5.0f); | |||
| LOLUNIT_ASSERT_EQUAL(c.y, 6.0f); | |||
| LOLUNIT_ASSERT_EQUAL(c.z, 3.0f); | |||
| lolunit_assert_equal(c.x, 5.0f); | |||
| lolunit_assert_equal(c.y, 6.0f); | |||
| lolunit_assert_equal(c.z, 3.0f); | |||
| c = a; | |||
| c.xy = b.zz; | |||
| LOLUNIT_ASSERT_EQUAL(c.x, 6.0f); | |||
| LOLUNIT_ASSERT_EQUAL(c.y, 6.0f); | |||
| LOLUNIT_ASSERT_EQUAL(c.z, 3.0f); | |||
| lolunit_assert_equal(c.x, 6.0f); | |||
| lolunit_assert_equal(c.y, 6.0f); | |||
| lolunit_assert_equal(c.z, 3.0f); | |||
| c = a; | |||
| c.xz = b.xy; | |||
| LOLUNIT_ASSERT_EQUAL(c.x, 4.0f); | |||
| LOLUNIT_ASSERT_EQUAL(c.y, 2.0f); | |||
| LOLUNIT_ASSERT_EQUAL(c.z, 5.0f); | |||
| lolunit_assert_equal(c.x, 4.0f); | |||
| lolunit_assert_equal(c.y, 2.0f); | |||
| lolunit_assert_equal(c.z, 5.0f); | |||
| c = a; | |||
| c.xz = b.xz; | |||
| LOLUNIT_ASSERT_EQUAL(c.x, 4.0f); | |||
| LOLUNIT_ASSERT_EQUAL(c.y, 2.0f); | |||
| LOLUNIT_ASSERT_EQUAL(c.z, 6.0f); | |||
| lolunit_assert_equal(c.x, 4.0f); | |||
| lolunit_assert_equal(c.y, 2.0f); | |||
| lolunit_assert_equal(c.z, 6.0f); | |||
| c = a; | |||
| c.xz = c.zy = b.yx; | |||
| LOLUNIT_ASSERT_EQUAL(c.x, 5.0f); | |||
| LOLUNIT_ASSERT_EQUAL(c.y, 4.0f); | |||
| LOLUNIT_ASSERT_EQUAL(c.z, 4.0f); | |||
| lolunit_assert_equal(c.x, 5.0f); | |||
| lolunit_assert_equal(c.y, 4.0f); | |||
| lolunit_assert_equal(c.z, 4.0f); | |||
| #endif | |||
| } | |||
| LOLUNIT_TEST(VectorSwizzleMul) | |||
| lolunit_declare_test(VectorSwizzleMul) | |||
| { | |||
| ivec3 a(1, 2, 3); | |||
| ivec3 b = a * 2; | |||
| LOLUNIT_ASSERT_EQUAL(b.x, 2); | |||
| LOLUNIT_ASSERT_EQUAL(b.y, 4); | |||
| LOLUNIT_ASSERT_EQUAL(b.z, 6); | |||
| lolunit_assert_equal(b.x, 2); | |||
| lolunit_assert_equal(b.y, 4); | |||
| lolunit_assert_equal(b.z, 6); | |||
| ivec3 c = (ivec3)a.zyx * 2; | |||
| LOLUNIT_ASSERT_EQUAL(c.x, 6); | |||
| LOLUNIT_ASSERT_EQUAL(c.y, 4); | |||
| LOLUNIT_ASSERT_EQUAL(c.z, 2); | |||
| lolunit_assert_equal(c.x, 6); | |||
| lolunit_assert_equal(c.y, 4); | |||
| lolunit_assert_equal(c.z, 2); | |||
| ivec3 d = 2 * (ivec3)a.zyx; | |||
| LOLUNIT_ASSERT_EQUAL(d.x, 6); | |||
| LOLUNIT_ASSERT_EQUAL(d.y, 4); | |||
| LOLUNIT_ASSERT_EQUAL(d.z, 2); | |||
| lolunit_assert_equal(d.x, 6); | |||
| lolunit_assert_equal(d.y, 4); | |||
| lolunit_assert_equal(d.z, 2); | |||
| ivec3 e = a.zyx * 2; | |||
| LOLUNIT_ASSERT_EQUAL(e.x, 6); | |||
| LOLUNIT_ASSERT_EQUAL(e.y, 4); | |||
| LOLUNIT_ASSERT_EQUAL(e.z, 2); | |||
| lolunit_assert_equal(e.x, 6); | |||
| lolunit_assert_equal(e.y, 4); | |||
| lolunit_assert_equal(e.z, 2); | |||
| ivec3 f = 2 * a.zyx; | |||
| LOLUNIT_ASSERT_EQUAL(f.x, 6); | |||
| LOLUNIT_ASSERT_EQUAL(f.y, 4); | |||
| LOLUNIT_ASSERT_EQUAL(f.z, 2); | |||
| lolunit_assert_equal(f.x, 6); | |||
| lolunit_assert_equal(f.y, 4); | |||
| lolunit_assert_equal(f.z, 2); | |||
| } | |||
| LOLUNIT_TEST(VectorUnaryMinus) | |||
| lolunit_declare_test(VectorUnaryMinus) | |||
| { | |||
| vec2 a(1.0f, 3.0f); | |||
| vec2 b(-1.0f, -3.0f); | |||
| LOLUNIT_ASSERT_EQUAL(a, -b); | |||
| LOLUNIT_ASSERT_EQUAL(-a, b); | |||
| lolunit_assert_equal(a, -b); | |||
| lolunit_assert_equal(-a, b); | |||
| } | |||
| LOLUNIT_TEST(CastVector) | |||
| lolunit_declare_test(CastVector) | |||
| { | |||
| vec2 a1(1.0f, 3.0f); | |||
| vec3 b(a1, 0.0f); | |||
| vec2 a2(b.xy); | |||
| LOLUNIT_ASSERT_EQUAL(b.x, a1.x); | |||
| LOLUNIT_ASSERT_EQUAL(b.y, a1.y); | |||
| LOLUNIT_ASSERT_EQUAL(b.z, 0.0f); | |||
| LOLUNIT_ASSERT_EQUAL(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_equal(a2, a1); | |||
| vec4 c(a1, 0.0f, 0.0f); | |||
| vec2 a3(c.xy); | |||
| 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_EQUAL(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_equal(a3, a1); | |||
| } | |||
| LOLUNIT_TEST(Orthogonal) | |||
| lolunit_declare_test(Orthogonal) | |||
| { | |||
| vec3 a(1.f, 0.f, 0.f); | |||
| vec3 b(0.f, 1.f, 0.f); | |||
| vec3 c(0.f, 0.f, 1.f); | |||
| LOLUNIT_ASSERT_DOUBLES_EQUAL(dot(orthogonal(a), a), 0.f, 1e-6f); | |||
| LOLUNIT_ASSERT_DOUBLES_EQUAL(dot(orthogonal(b), b), 0.f, 1e-6f); | |||
| LOLUNIT_ASSERT_DOUBLES_EQUAL(dot(orthogonal(c), c), 0.f, 1e-6f); | |||
| lolunit_assert_doubles_equal(dot(orthogonal(a), a), 0.f, 1e-6f); | |||
| lolunit_assert_doubles_equal(dot(orthogonal(b), b), 0.f, 1e-6f); | |||
| lolunit_assert_doubles_equal(dot(orthogonal(c), c), 0.f, 1e-6f); | |||
| /* The length of the orthogonal vector should be at least | |||
| * sqrt(2)/2 times the length of the original vector. */ | |||
| LOLUNIT_ASSERT_GREATER(length(orthogonal(a)), 0.7f); | |||
| LOLUNIT_ASSERT_GREATER(length(orthogonal(b)), 0.7f); | |||
| LOLUNIT_ASSERT_GREATER(length(orthogonal(c)), 0.7f); | |||
| lolunit_assert_greater(length(orthogonal(a)), 0.7f); | |||
| lolunit_assert_greater(length(orthogonal(b)), 0.7f); | |||
| lolunit_assert_greater(length(orthogonal(c)), 0.7f); | |||
| LOLUNIT_ASSERT_DOUBLES_EQUAL(dot(orthonormal(a), a), 0.f, 1e-6f); | |||
| LOLUNIT_ASSERT_DOUBLES_EQUAL(dot(orthonormal(b), b), 0.f, 1e-6f); | |||
| LOLUNIT_ASSERT_DOUBLES_EQUAL(dot(orthonormal(c), c), 0.f, 1e-6f); | |||
| lolunit_assert_doubles_equal(dot(orthonormal(a), a), 0.f, 1e-6f); | |||
| lolunit_assert_doubles_equal(dot(orthonormal(b), b), 0.f, 1e-6f); | |||
| lolunit_assert_doubles_equal(dot(orthonormal(c), c), 0.f, 1e-6f); | |||
| /* The length of the orthonormal vector should be 1. */ | |||
| LOLUNIT_ASSERT_DOUBLES_EQUAL(length(orthonormal(a)), 1.f, 1e-6f); | |||
| LOLUNIT_ASSERT_DOUBLES_EQUAL(length(orthonormal(b)), 1.f, 1e-6f); | |||
| LOLUNIT_ASSERT_DOUBLES_EQUAL(length(orthonormal(c)), 1.f, 1e-6f); | |||
| lolunit_assert_doubles_equal(length(orthonormal(a)), 1.f, 1e-6f); | |||
| lolunit_assert_doubles_equal(length(orthonormal(b)), 1.f, 1e-6f); | |||
| lolunit_assert_doubles_equal(length(orthonormal(c)), 1.f, 1e-6f); | |||
| } | |||
| LOLUNIT_TEST(LargeVectors) | |||
| lolunit_declare_test(LargeVectors) | |||
| { | |||
| vec_t<int, 50> v0(0); | |||
| vec_t<int, 50> v1(1); | |||
| @@ -270,43 +270,43 @@ LOLUNIT_FIXTURE(VectorTest) | |||
| auto va = v0 + v3; | |||
| auto vb = v1 + v2; | |||
| LOLUNIT_ASSERT(va == vb); | |||
| lolunit_assert(va == vb); | |||
| } | |||
| #if !LOL_FEATURE_VISUAL_STUDIO_THAT_FUCKING_PIECE_OF_SHIT_COMPILER | |||
| LOLUNIT_TEST(VectorIterator) | |||
| lolunit_declare_test(VectorIterator) | |||
| { | |||
| vec4 v4(1.125f, 1.25f, 1.375f, 1.25f); | |||
| for (auto x : v4) | |||
| { | |||
| LOLUNIT_ASSERT_GREATER(x, 1.0f); | |||
| LOLUNIT_ASSERT_LESS(x, 1.5f); | |||
| lolunit_assert_greater(x, 1.0f); | |||
| lolunit_assert_less(x, 1.5f); | |||
| } | |||
| for (auto &x : v4) | |||
| { | |||
| LOLUNIT_ASSERT_GREATER(x, 1.0f); | |||
| LOLUNIT_ASSERT_LESS(x, 1.5f); | |||
| lolunit_assert_greater(x, 1.0f); | |||
| lolunit_assert_less(x, 1.5f); | |||
| } | |||
| for (auto x : v4.zywx) | |||
| { | |||
| LOLUNIT_ASSERT_GREATER(x, 1.0f); | |||
| LOLUNIT_ASSERT_LESS(x, 1.5f); | |||
| lolunit_assert_greater(x, 1.0f); | |||
| lolunit_assert_less(x, 1.5f); | |||
| } | |||
| vec4 const &v4c = v4; | |||
| for (auto x : v4c) | |||
| { | |||
| LOLUNIT_ASSERT_GREATER(x, 1.0f); | |||
| LOLUNIT_ASSERT_LESS(x, 1.5f); | |||
| lolunit_assert_greater(x, 1.0f); | |||
| lolunit_assert_less(x, 1.5f); | |||
| } | |||
| for (auto &x : v4c) | |||
| { | |||
| LOLUNIT_ASSERT_GREATER(x, 1.0f); | |||
| LOLUNIT_ASSERT_LESS(x, 1.5f); | |||
| lolunit_assert_greater(x, 1.0f); | |||
| lolunit_assert_less(x, 1.5f); | |||
| } | |||
| } | |||
| #endif | |||
| @@ -18,24 +18,24 @@ | |||
| namespace lol | |||
| { | |||
| LOLUNIT_FIXTURE(ThreadTest) | |||
| lolunit_declare_fixture(ThreadTest) | |||
| { | |||
| void SetUp() {} | |||
| void TearDown() {} | |||
| LOLUNIT_TEST(QueueTryPush) | |||
| lolunit_declare_test(QueueTryPush) | |||
| { | |||
| Queue<int, 1> q; | |||
| bool b1 = q.TryPush(0); | |||
| LOLUNIT_ASSERT_EQUAL(true, b1); | |||
| lolunit_assert_equal(true, b1); | |||
| bool b2 = q.TryPush(1); | |||
| LOLUNIT_ASSERT_EQUAL(false, b2); | |||
| lolunit_assert_equal(false, b2); | |||
| } | |||
| LOLUNIT_TEST(QueueTryPop) | |||
| lolunit_declare_test(QueueTryPop) | |||
| { | |||
| Queue<int, 1> q; | |||
| int tmp; | |||
| @@ -43,12 +43,12 @@ LOLUNIT_FIXTURE(ThreadTest) | |||
| q.Push(42); | |||
| bool b1 = q.TryPop(tmp); | |||
| LOLUNIT_ASSERT_EQUAL(true, b1); | |||
| LOLUNIT_ASSERT_EQUAL(42, tmp); | |||
| lolunit_assert_equal(true, b1); | |||
| lolunit_assert_equal(42, tmp); | |||
| bool b2 = q.TryPop(tmp); | |||
| LOLUNIT_ASSERT_EQUAL(false, b2); | |||
| LOLUNIT_ASSERT_EQUAL(42, tmp); | |||
| lolunit_assert_equal(false, b2); | |||
| lolunit_assert_equal(42, tmp); | |||
| } | |||
| }; | |||
| @@ -26,7 +26,7 @@ namespace lol | |||
| /* | |||
| * This is the base class for all fixtures. It keeps track of all | |||
| * fixtures registered through the LOLUNIT_FIXTURE macro and puts them | |||
| * fixtures registered through the lolunit_declare_fixture macro and puts them | |||
| * in a linked list. | |||
| */ | |||
| class FixtureBase | |||
| @@ -81,7 +81,7 @@ private: | |||
| /* | |||
| * This template specialises FixtureBase and provides registration of | |||
| * test cases in a linked list through the LOLUNIT_TEST macro. | |||
| * test cases in a linked list through the lolunit_declare_test macro. | |||
| */ | |||
| template<class T> class Fixture : protected FixtureBase | |||
| { | |||
| @@ -93,9 +93,15 @@ public: | |||
| void (FixtureClass::* m_fun)(); | |||
| char const *m_testname; | |||
| TestCase *m_next; | |||
| protected: | |||
| static inline std::string make_msg(std::string const str) | |||
| { | |||
| return "- " + str + "\n"; | |||
| } | |||
| }; | |||
| Fixture<T>() | |||
| Fixture() | |||
| { | |||
| AddFixture(this); | |||
| } | |||
| @@ -198,61 +204,61 @@ public: | |||
| testcases += f->m_testcases; | |||
| failcases += f->m_failcases; | |||
| } | |||
| std::cout << std::endl; | |||
| std::cout << "\n"; | |||
| std::cout << std::endl << std::endl; | |||
| std::cout << "\n\n"; | |||
| if (failcases) | |||
| { | |||
| std::cout << "!!!FAILURES!!!" << std::endl; | |||
| std::cout << "Test Results:" << std::endl; | |||
| std::cout << "!!!FAILURES!!!\n"; | |||
| std::cout << "Test Results:\n"; | |||
| std::cout << "Run: " << testcases | |||
| << " Failures: " << failcases | |||
| << " Errors: 0" << std::endl; /* TODO: handle errors */ | |||
| << " Errors: 0\n"; /* TODO: handle errors */ | |||
| std::cout << errors.str(); | |||
| ret = false; | |||
| } | |||
| else | |||
| { | |||
| std::cout << "OK (" << testcases << " tests)" << std::endl; | |||
| std::cout << "OK (" << testcases << " tests)\n"; | |||
| } | |||
| std::cout << std::endl << std::endl; | |||
| std::cout << "\n\n"; | |||
| return ret; | |||
| } | |||
| }; | |||
| #define LOLUNIT_ASSERT_GENERIC(msg, cond) \ | |||
| #define lolunit_assert_generic(msg, cond) \ | |||
| do { \ | |||
| m_asserts++; \ | |||
| if (True() && !(cond)) \ | |||
| { \ | |||
| m_errorlog << std::endl << std::endl; \ | |||
| m_errorlog << "\n\n"; \ | |||
| m_errorlog << ++m_failcases << ") test: " \ | |||
| << lol_unit_helper_name(this) << "::" << m_currentname \ | |||
| << " (F) line: " << __LINE__ << " " \ | |||
| << __FILE__ << std::endl; \ | |||
| m_errorlog << "assertion failed" << std::endl; \ | |||
| m_errorlog << "- Expression: " << #cond << std::endl; \ | |||
| << __FILE__ << "\n"; \ | |||
| m_errorlog << "assertion failed\n"; \ | |||
| m_errorlog << "- Expression: " << #cond << "\n"; \ | |||
| m_errorlog << msg; \ | |||
| m_failure = true; \ | |||
| return; \ | |||
| } \ | |||
| } while (!True()) | |||
| #define LOLUNIT_ASSERT_OP(op, modifier, opdesc, msg, a, b) \ | |||
| #define lolunit_assert_op(op, modifier, opdesc, msg, a, b) \ | |||
| do { \ | |||
| m_asserts++; \ | |||
| if (True() && !modifier((a) op (b))) \ | |||
| { \ | |||
| m_errorlog << std::endl << std::endl; \ | |||
| m_errorlog << "\n\n"; \ | |||
| m_errorlog << ++m_failcases << ") test: " \ | |||
| << lol_unit_helper_name(this) << "::" << m_currentname \ | |||
| << " (F) line: " << __LINE__ << " " \ | |||
| << __FILE__ << std::endl; \ | |||
| m_errorlog << opdesc << " assertion failed" << std::endl; \ | |||
| m_errorlog << "- Expected: " << #a << " = " << (a) << std::endl; \ | |||
| m_errorlog << "- Actual : " << #b << " = " << (b) << std::endl; \ | |||
| << __FILE__ << "\n"; \ | |||
| m_errorlog << opdesc << " assertion failed\n"; \ | |||
| m_errorlog << "- Expected: " << #a << " = " << (a) << "\n"; \ | |||
| m_errorlog << "- Actual : " << #b << " = " << (b) << "\n"; \ | |||
| m_errorlog << msg; \ | |||
| m_errorlog << m_context.str(); \ | |||
| m_failure = true; \ | |||
| @@ -260,26 +266,23 @@ public: | |||
| } \ | |||
| } while (!True()) | |||
| #define LOLUNIT_MSG(msg) \ | |||
| "- " << msg << std::endl | |||
| #define LOLUNIT_ASSERT_DOUBLES_EQUAL_GENERIC(msg, a, b, t) \ | |||
| #define lolunit_assert_doubles_equal_generic(msg, a, b, t) \ | |||
| do { \ | |||
| m_asserts++; \ | |||
| using std::fabs; \ | |||
| if (True() && fabs((a) - (b)) > fabs((t))) \ | |||
| { \ | |||
| m_errorlog << std::endl << std::endl; \ | |||
| m_errorlog << "\n\n"; \ | |||
| m_errorlog << ++m_failcases << ") test: " \ | |||
| << lol_unit_helper_name(this) << "::" << m_currentname \ | |||
| << " (F) line: " << __LINE__ << " " \ | |||
| << __FILE__ << std::endl; \ | |||
| m_errorlog << "double equality assertion failed" << std::endl; \ | |||
| << __FILE__ << "\n"; \ | |||
| m_errorlog << "double equality assertion failed\n"; \ | |||
| std::streamsize old_prec = m_errorlog.precision(); \ | |||
| m_errorlog << std::setprecision(16); \ | |||
| m_errorlog << "- Expected: " << #a << " = " << (a) << std::endl; \ | |||
| m_errorlog << "- Actual : " << #b << " = " << (b) << std::endl; \ | |||
| m_errorlog << "- Delta : " << (t) << std::endl; \ | |||
| m_errorlog << "- Expected: " << #a << " = " << (a) << "\n"; \ | |||
| m_errorlog << "- Actual : " << #b << " = " << (b) << "\n"; \ | |||
| m_errorlog << "- Delta : " << (t) << "\n"; \ | |||
| m_errorlog << std::setprecision(old_prec); \ | |||
| m_errorlog << msg; \ | |||
| m_errorlog << m_context.str(); \ | |||
| @@ -292,7 +295,7 @@ public: | |||
| * Public helper macros | |||
| */ | |||
| #define LOLUNIT_FIXTURE(N) \ | |||
| #define lolunit_declare_fixture(N) \ | |||
| class N; \ | |||
| /* This pattern allows us to statically create a Fixture instance \ | |||
| * before its exact implementation was defined. */ \ | |||
| @@ -313,7 +316,7 @@ public: | |||
| /* Now the user can define the implementation */ \ | |||
| class N : public lol::Fixture<N> | |||
| #define LOLUNIT_TEST(N) \ | |||
| #define lolunit_declare_test(N) \ | |||
| /* For each test in the fixture, we create an object that will \ | |||
| * automatically register the test method in a list global to the \ | |||
| * specialised fixture. */ \ | |||
| @@ -333,95 +336,95 @@ public: | |||
| * Provide context for error messages | |||
| */ | |||
| #define LOLUNIT_SET_CONTEXT(n) \ | |||
| #define lolunit_set_context(n) \ | |||
| do { \ | |||
| m_context.str(""); \ | |||
| m_context << "- Context : " << #n << " = " << (n) << std::endl; \ | |||
| m_context << "- Context : " << #n << " = " << (n) << "\n"; \ | |||
| } while (!True()) | |||
| #define LOLUNIT_UNSET_CONTEXT(n) \ | |||
| #define lolunit_unset_context(n) \ | |||
| m_context.str("") | |||
| /* | |||
| * Public assert macros | |||
| */ | |||
| #define LOLUNIT_FAIL(msg) \ | |||
| #define lolunit_fail(msg) \ | |||
| do { \ | |||
| m_asserts++; \ | |||
| m_errorlog << std::endl << std::endl; \ | |||
| m_errorlog << "\n\n"; \ | |||
| m_errorlog << ++m_failcases << ") test: " \ | |||
| << lol_unit_helper_name(this) << "::" << m_currentname \ | |||
| << " (F) line: " << __LINE__ << " " \ | |||
| << __FILE__ << std::endl; \ | |||
| m_errorlog << "forced failure" << std::endl; \ | |||
| m_errorlog << LOLUNIT_MSG(msg); \ | |||
| << __FILE__ << "\n"; \ | |||
| m_errorlog << "forced failure\n"; \ | |||
| m_errorlog << make_msg(msg); \ | |||
| m_errorlog << m_context.str(); \ | |||
| m_failure = true; \ | |||
| return; \ | |||
| } while (!True()) | |||
| #define LOLUNIT_ASSERT(cond) \ | |||
| LOLUNIT_ASSERT_GENERIC("", cond) | |||
| #define LOLUNIT_ASSERT_MESSAGE(m, cond) \ | |||
| LOLUNIT_ASSERT_GENERIC(LOLUNIT_MSG(m), cond) | |||
| #define LOLUNIT_ASSERT_EQUAL(a, b) \ | |||
| LOLUNIT_ASSERT_OP(==, (bool), "equality", "", a, b) | |||
| #define LOLUNIT_ASSERT_EQUAL_MESSAGE(m, a, b) \ | |||
| LOLUNIT_ASSERT_OP(==, (bool), "equality", LOLUNIT_MSG(m), a, b) | |||
| #define LOLUNIT_ASSERT_DIFFERENT(a, b) \ | |||
| LOLUNIT_ASSERT_OP(!=, (bool), "inequality", "", a, b) | |||
| #define LOLUNIT_ASSERT_DIFFERENT_MESSAGE(m, a, b) \ | |||
| LOLUNIT_ASSERT_OP(!=, (bool), "inequality", LOLUNIT_MSG(m), a, b) | |||
| #define LOLUNIT_ASSERT_LESS(a, b) \ | |||
| LOLUNIT_ASSERT_OP(<, (bool), "less than", "", a, b) | |||
| #define LOLUNIT_ASSERT_LESS_MESSAGE(m, a, b) \ | |||
| LOLUNIT_ASSERT_OP(<, (bool), "less than", LOLUNIT_MSG(m), a, b) | |||
| #define LOLUNIT_ASSERT_LEQUAL(a, b) \ | |||
| LOLUNIT_ASSERT_OP(<=, (bool), "less than or equal", "", a, b) | |||
| #define LOLUNIT_ASSERT_LEQUAL_MESSAGE(m, a, b) \ | |||
| LOLUNIT_ASSERT_OP(<=, (bool), "less than or equal", LOLUNIT_MSG(m), a, b) | |||
| #define LOLUNIT_ASSERT_GREATER(a, b) \ | |||
| LOLUNIT_ASSERT_OP(>, (bool), "greater than", "", a, b) | |||
| #define LOLUNIT_ASSERT_GREATER_MESSAGE(m, a, b) \ | |||
| LOLUNIT_ASSERT_OP(>, (bool), "greater than", LOLUNIT_MSG(m), a, b) | |||
| #define LOLUNIT_ASSERT_GEQUAL(a, b) \ | |||
| LOLUNIT_ASSERT_OP(>=, (bool), "greater than or equal", "", a, b) | |||
| #define LOLUNIT_ASSERT_GEQUAL_MESSAGE(m, a, b) \ | |||
| LOLUNIT_ASSERT_OP(>=, (bool), "greater than or equal", LOLUNIT_MSG(m), a, b) | |||
| #define LOLUNIT_ASSERT_NOT_EQUAL(a, b) \ | |||
| LOLUNIT_ASSERT_OP(==, !, "not equality", "", a, b) | |||
| #define LOLUNIT_ASSERT_NOT_EQUAL_MESSAGE(m, a, b) \ | |||
| LOLUNIT_ASSERT_OP(==, !, "not equality", LOLUNIT_MSG(m), a, b) | |||
| #define LOLUNIT_ASSERT_NOT_DIFFERENT(a, b) \ | |||
| LOLUNIT_ASSERT_OP(!=, !, "not inequality", "", a, b) | |||
| #define LOLUNIT_ASSERT_NOT_DIFFERENT_MESSAGE(m, a, b) \ | |||
| LOLUNIT_ASSERT_OP(!=, !, "not inequality", LOLUNIT_MSG(m), a, b) | |||
| #define LOLUNIT_ASSERT_NOT_LESS(a, b) \ | |||
| LOLUNIT_ASSERT_OP(<, !, "not less than", "", a, b) | |||
| #define LOLUNIT_ASSERT_NOT_LESS_MESSAGE(m, a, b) \ | |||
| LOLUNIT_ASSERT_OP(<, !, "not less than", LOLUNIT_MSG(m), a, b) | |||
| #define LOLUNIT_ASSERT_NOT_LEQUAL(a, b) \ | |||
| LOLUNIT_ASSERT_OP(<=, !, "not less than or equal", "", a, b) | |||
| #define LOLUNIT_ASSERT_NOT_LEQUAL_MESSAGE(m, a, b) \ | |||
| LOLUNIT_ASSERT_OP(<=, !, "not less than or equal", LOLUNIT_MSG(m), a, b) | |||
| #define LOLUNIT_ASSERT_NOT_GREATER(a, b) \ | |||
| LOLUNIT_ASSERT_OP(>, !, "not greater than", "", a, b) | |||
| #define LOLUNIT_ASSERT_NOT_GREATER_MESSAGE(m, a, b) \ | |||
| LOLUNIT_ASSERT_OP(>, !, "not greater than", LOLUNIT_MSG(m), a, b) | |||
| #define LOLUNIT_ASSERT_NOT_GEQUAL(a, b) \ | |||
| LOLUNIT_ASSERT_OP(>=, !, "not greater than or equal", "", a, b) | |||
| #define LOLUNIT_ASSERT_NOT_GEQUAL_MESSAGE(m, a, b) \ | |||
| LOLUNIT_ASSERT_OP(>=, !, "not greater than or equal", LOLUNIT_MSG(m), a, b) | |||
| #define LOLUNIT_ASSERT_DOUBLES_EQUAL(a, b, t) \ | |||
| LOLUNIT_ASSERT_DOUBLES_EQUAL_GENERIC("", a, b, t) | |||
| #define LOLUNIT_ASSERT_DOUBLES_EQUAL_MESSAGE(msg, a, b, t) \ | |||
| LOLUNIT_ASSERT_DOUBLES_EQUAL_GENERIC(LOLUNIT_MSG(msg), a, b, t) | |||
| #define lolunit_assert(cond) \ | |||
| lolunit_assert_generic("", cond) | |||
| #define lolunit_assert_message(m, cond) \ | |||
| lolunit_assert_generic(make_msg(m), cond) | |||
| #define lolunit_assert_equal(a, b) \ | |||
| lolunit_assert_op(==, (bool), "equality", "", a, b) | |||
| #define lolunit_assert_equal_message(m, a, b) \ | |||
| lolunit_assert_op(==, (bool), "equality", make_msg(m), a, b) | |||
| #define lolunit_assert_different(a, b) \ | |||
| lolunit_assert_op(!=, (bool), "inequality", "", a, b) | |||
| #define lolunit_assert_different_message(m, a, b) \ | |||
| lolunit_assert_op(!=, (bool), "inequality", make_msg(m), a, b) | |||
| #define lolunit_assert_less(a, b) \ | |||
| lolunit_assert_op(<, (bool), "less than", "", a, b) | |||
| #define lolunit_assert_less_message(m, a, b) \ | |||
| lolunit_assert_op(<, (bool), "less than", make_msg(m), a, b) | |||
| #define lolunit_assert_lequal(a, b) \ | |||
| lolunit_assert_op(<=, (bool), "less than or equal", "", a, b) | |||
| #define lolunit_assert_lequal_message(m, a, b) \ | |||
| lolunit_assert_op(<=, (bool), "less than or equal", make_msg(m), a, b) | |||
| #define lolunit_assert_greater(a, b) \ | |||
| lolunit_assert_op(>, (bool), "greater than", "", a, b) | |||
| #define lolunit_assert_greater_message(m, a, b) \ | |||
| lolunit_assert_op(>, (bool), "greater than", make_msg(m), a, b) | |||
| #define lolunit_assert_gequal(a, b) \ | |||
| lolunit_assert_op(>=, (bool), "greater than or equal", "", a, b) | |||
| #define lolunit_assert_gequal_message(m, a, b) \ | |||
| lolunit_assert_op(>=, (bool), "greater than or equal", make_msg(m), a, b) | |||
| #define lolunit_assert_not_equal(a, b) \ | |||
| lolunit_assert_op(==, !, "not equality", "", a, b) | |||
| #define lolunit_assert_not_equal_message(m, a, b) \ | |||
| lolunit_assert_op(==, !, "not equality", make_msg(m), a, b) | |||
| #define lolunit_assert_not_different(a, b) \ | |||
| lolunit_assert_op(!=, !, "not inequality", "", a, b) | |||
| #define lolunit_assert_not_different_message(m, a, b) \ | |||
| lolunit_assert_op(!=, !, "not inequality", make_msg(m), a, b) | |||
| #define lolunit_assert_not_less(a, b) \ | |||
| lolunit_assert_op(<, !, "not less than", "", a, b) | |||
| #define lolunit_assert_not_less_message(m, a, b) \ | |||
| lolunit_assert_op(<, !, "not less than", make_msg(m), a, b) | |||
| #define lolunit_assert_not_lequal(a, b) \ | |||
| lolunit_assert_op(<=, !, "not less than or equal", "", a, b) | |||
| #define lolunit_assert_not_lequal_message(m, a, b) \ | |||
| lolunit_assert_op(<=, !, "not less than or equal", make_msg(m), a, b) | |||
| #define lolunit_assert_not_greater(a, b) \ | |||
| lolunit_assert_op(>, !, "not greater than", "", a, b) | |||
| #define lolunit_assert_not_greater_message(m, a, b) \ | |||
| lolunit_assert_op(>, !, "not greater than", make_msg(m), a, b) | |||
| #define lolunit_assert_not_gequal(a, b) \ | |||
| lolunit_assert_op(>=, !, "not greater than or equal", "", a, b) | |||
| #define lolunit_assert_not_gequal_message(m, a, b) \ | |||
| lolunit_assert_op(>=, !, "not greater than or equal", make_msg(m), a, b) | |||
| #define lolunit_assert_doubles_equal(a, b, t) \ | |||
| lolunit_assert_doubles_equal_generic("", a, b, t) | |||
| #define lolunit_assert_doubles_equal_message(msg, a, b, t) \ | |||
| lolunit_assert_doubles_equal_generic(make_msg(msg), a, b, t) | |||
| } /* namespace lol */ | |||
| @@ -46,6 +46,11 @@ au Syntax cpp | |||
| \ syn match cConstant | |||
| \ "\<\(F\|D\|LD\)_\(PI\|PI_[234]\|[12]_PI\|SQRT_[23]\|SQRT_1_2\)\>" | |||
| " Unit testing | |||
| au Syntax cpp | |||
| \ syn match cOperator | |||
| \ "\<lolunit_\(fail\|assert\)[a-z_]*\>" | |||
| " Global keywords | |||
| au Syntax cpp | |||
| \ syn keyword cConstant | |||