Changeset 757
 Timestamp:
 Apr 20, 2011, 12:01:45 PM (12 years ago)
 Location:
 trunk
 Files:

 2 edited
Legend:
 Unmodified
 Added
 Removed

trunk/src/matrix.h
r748 r757 38 38 } 39 39 40 #define BOOL_OP(elems, op, ret) \40 #define BOOL_OP(elems, op, op2, ret) \ 41 41 inline bool operator op(Vec##elems<T> const &val) const \ 42 42 { \ 43 43 for (int n = 0; n < elems; n++) \ 44 if ( (*this)[n] != val[n]) \45 return ret; \46 return !ret; \44 if (!((*this)[n] op2 val[n])) \ 45 return !ret; \ 46 return ret; \ 47 47 } 48 48 … … 79 79 VECTOR_OP(elems, /) \ 80 80 \ 81 BOOL_OP(elems, ==, false) \ 82 BOOL_OP(elems, !=, true) \ 81 BOOL_OP(elems, ==, ==, true) \ 82 BOOL_OP(elems, !=, ==, false) \ 83 BOOL_OP(elems, <=, <=, true) \ 84 BOOL_OP(elems, >=, >=, true) \ 85 BOOL_OP(elems, <, <, true) \ 86 BOOL_OP(elems, >, >, true) \ 83 87 \ 84 88 SCALAR_OP(elems, ) \ 
trunk/test/matrix.cpp
r686 r757 26 26 { 27 27 CPPUNIT_TEST_SUITE(MatrixTest); 28 CPPUNIT_TEST(test_vec_eq); 29 CPPUNIT_TEST(test_vec_lt); 28 30 CPPUNIT_TEST(test_mat_det); 29 31 CPPUNIT_TEST(test_mat_mul); … … 48 50 49 51 void tearDown() {} 52 53 void test_vec_eq() 54 { 55 vec2 a2(1.0f, 2.0f); 56 vec2 b2(0.0f, 2.0f); 57 vec2 c2(1.0f, 0.0f); 58 59 CPPUNIT_ASSERT(a2 == a2); 60 CPPUNIT_ASSERT(!(a2 != a2)); 61 62 CPPUNIT_ASSERT(a2 != b2); 63 CPPUNIT_ASSERT(!(a2 == b2)); 64 CPPUNIT_ASSERT(a2 != c2); 65 CPPUNIT_ASSERT(!(a2 == c2)); 66 67 vec3 a3(1.0f, 2.0f, 3.0f); 68 vec3 b3(0.0f, 2.0f, 3.0f); 69 vec3 c3(1.0f, 0.0f, 3.0f); 70 vec3 d3(1.0f, 2.0f, 0.0f); 71 72 CPPUNIT_ASSERT(a3 == a3); 73 CPPUNIT_ASSERT(!(a3 != a3)); 74 75 CPPUNIT_ASSERT(a3 != b3); 76 CPPUNIT_ASSERT(!(a3 == b3)); 77 CPPUNIT_ASSERT(a3 != c3); 78 CPPUNIT_ASSERT(!(a3 == c3)); 79 CPPUNIT_ASSERT(a3 != d3); 80 CPPUNIT_ASSERT(!(a3 == d3)); 81 82 vec4 a4(1.0f, 2.0f, 3.0f, 4.0f); 83 vec4 b4(0.0f, 2.0f, 3.0f, 4.0f); 84 vec4 c4(1.0f, 0.0f, 3.0f, 4.0f); 85 vec4 d4(1.0f, 2.0f, 0.0f, 4.0f); 86 vec4 e4(1.0f, 2.0f, 3.0f, 0.0f); 87 88 CPPUNIT_ASSERT(a4 == a4); 89 CPPUNIT_ASSERT(!(a4 != a4)); 90 91 CPPUNIT_ASSERT(a4 != b4); 92 CPPUNIT_ASSERT(!(a4 == b4)); 93 CPPUNIT_ASSERT(a4 != c4); 94 CPPUNIT_ASSERT(!(a4 == c4)); 95 CPPUNIT_ASSERT(a4 != d4); 96 CPPUNIT_ASSERT(!(a4 == d4)); 97 CPPUNIT_ASSERT(a4 != e4); 98 CPPUNIT_ASSERT(!(a4 == e4)); 99 } 100 101 void test_vec_lt() 102 { 103 vec2 a2(1.0f, 3.0f); 104 vec2 b2(0.0f, 0.0f); 105 vec2 c2(1.0f, 1.0f); 106 vec2 d2(2.0f, 2.0f); 107 vec2 e2(3.0f, 3.0f); 108 vec2 f2(4.0f, 4.0f); 109 110 CPPUNIT_ASSERT(a2 <= a2); 111 CPPUNIT_ASSERT(!(a2 < a2)); 112 113 CPPUNIT_ASSERT(!(a2 <= b2)); 114 CPPUNIT_ASSERT(!(a2 < b2)); 115 CPPUNIT_ASSERT(!(a2 <= c2)); 116 CPPUNIT_ASSERT(!(a2 < c2)); 117 CPPUNIT_ASSERT(!(a2 <= d2)); 118 CPPUNIT_ASSERT(!(a2 < d2)); 119 CPPUNIT_ASSERT(a2 <= e2); 120 CPPUNIT_ASSERT(!(a2 < e2)); 121 CPPUNIT_ASSERT(a2 <= f2); 122 CPPUNIT_ASSERT(a2 < f2); 123 } 50 124 51 125 void test_mat_det()
Note: See TracChangeset
for help on using the changeset viewer.