]> git.localhorst.tv Git - blobs.git/blob - tst/assert.hpp
randomize creature properties a bit
[blobs.git] / tst / assert.hpp
1 #ifndef BLOBS_TEST_ASSETS_HPP_
2 #define BLOBS_TEST_ASSETS_HPP_
3
4 #include "math/glm.hpp"
5
6 #include <string>
7 #include <limits>
8
9
10 namespace blobs {
11 namespace test {
12
13 template<class T>
14 void AssertEqual(
15         const std::string &msg,
16         const glm::tvec2<T> &expected,
17         const glm::tvec2<T> &actual,
18         T epsilon = std::numeric_limits<T>::epsilon()
19 ) {
20         CPPUNIT_ASSERT_DOUBLES_EQUAL_MESSAGE(
21                 msg + " (X component)",
22                 expected.x, actual.x, epsilon
23         );
24         CPPUNIT_ASSERT_DOUBLES_EQUAL_MESSAGE(
25                 msg + " (Y component)",
26                 expected.y, actual.y, epsilon
27         );
28 }
29
30 template<class T>
31 void AssertEqual(
32         const std::string &msg,
33         const glm::tvec3<T> &expected,
34         const glm::tvec3<T> &actual,
35         T epsilon = std::numeric_limits<T>::epsilon()
36 ) {
37         CPPUNIT_ASSERT_DOUBLES_EQUAL_MESSAGE(
38                 msg + " (X component)",
39                 expected.x, actual.x, epsilon
40         );
41         CPPUNIT_ASSERT_DOUBLES_EQUAL_MESSAGE(
42                 msg + " (Y component)",
43                 expected.y, actual.y, epsilon
44         );
45         CPPUNIT_ASSERT_DOUBLES_EQUAL_MESSAGE(
46                 msg + " (Z component)",
47                 expected.z, actual.z, epsilon
48         );
49 }
50
51 }
52 }
53
54 #endif