OLD | NEW |
1 #include "Test.h" | 1 #include "Test.h" |
2 #include "Sk4x.h" | 2 #include "Sk4x.h" |
3 | 3 |
4 #define ASSERT_EQ(a, b) REPORTER_ASSERT(r, a.equal(b).allTrue()) | 4 #define ASSERT_EQ(a, b) REPORTER_ASSERT(r, a.equal(b).allTrue()) |
5 #define ASSERT_NE(a, b) REPORTER_ASSERT(r, a.notEqual(b).allTrue()) | 5 #define ASSERT_NE(a, b) REPORTER_ASSERT(r, a.notEqual(b).allTrue()) |
6 | 6 |
7 DEF_TEST(Sk4x_Construction, r) { | 7 DEF_TEST(Sk4x_Construction, r) { |
8 Sk4f uninitialized; | 8 Sk4f uninitialized; |
9 Sk4f zero(0,0,0,0); | 9 Sk4f zero(0,0,0,0); |
10 Sk4f foo(1,2,3,4), | 10 Sk4f foo(1,2,3,4), |
(...skipping 24 matching lines...) Expand all Loading... |
35 foo = Sk4f::Load(fs+1); | 35 foo = Sk4f::Load(fs+1); |
36 ASSERT_NE(foo, bar); | 36 ASSERT_NE(foo, bar); |
37 | 37 |
38 foo.storeAligned(fs); | 38 foo.storeAligned(fs); |
39 bar.store(fs+1); | 39 bar.store(fs+1); |
40 REPORTER_ASSERT(r, fs[0] == 6 && | 40 REPORTER_ASSERT(r, fs[0] == 6 && |
41 fs[1] == 5 && | 41 fs[1] == 5 && |
42 fs[2] == 6 && | 42 fs[2] == 6 && |
43 fs[3] == 7 && | 43 fs[3] == 7 && |
44 fs[4] == 8); | 44 fs[4] == 8); |
| 45 |
| 46 // Load2 and store2(). |
| 47 float two[2] = { 1.0f, 2.0f }; |
| 48 Sk4f twoIn4f = Sk4f::Load2(two); |
| 49 twoIn4f = twoIn4f.multiply(Sk4f(2.0f)); |
| 50 twoIn4f.store2(two); |
| 51 |
| 52 REPORTER_ASSERT(r, two[0] == 2.0f); |
| 53 REPORTER_ASSERT(r, two[1] == 4.0f); |
45 } | 54 } |
46 | 55 |
47 DEF_TEST(Sk4x_Conversions, r) { | 56 DEF_TEST(Sk4x_Conversions, r) { |
48 // Assuming IEEE floats. | 57 // Assuming IEEE floats. |
49 Sk4f zerof(0,0,0,0); | 58 Sk4f zerof(0,0,0,0); |
50 Sk4i zeroi(0,0,0,0); | 59 Sk4i zeroi(0,0,0,0); |
51 ASSERT_EQ(zeroi, zerof.cast<Sk4i>()); | 60 ASSERT_EQ(zeroi, zerof.cast<Sk4i>()); |
52 ASSERT_EQ(zeroi, zerof.reinterpret<Sk4i>()); | 61 ASSERT_EQ(zeroi, zerof.reinterpret<Sk4i>()); |
53 ASSERT_EQ(zerof, zeroi.cast<Sk4f>()); | 62 ASSERT_EQ(zerof, zeroi.cast<Sk4f>()); |
54 ASSERT_EQ(zerof, zeroi.reinterpret<Sk4f>()); | 63 ASSERT_EQ(zerof, zeroi.reinterpret<Sk4f>()); |
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
130 } | 139 } |
131 | 140 |
132 DEF_TEST(Sk4x_Swizzle, r) { | 141 DEF_TEST(Sk4x_Swizzle, r) { |
133 ASSERT_EQ(Sk4f(3,4,1,2), Sk4f(1,2,3,4).zwxy()); | 142 ASSERT_EQ(Sk4f(3,4,1,2), Sk4f(1,2,3,4).zwxy()); |
134 ASSERT_EQ(Sk4f(1,2,5,6), Sk4f::XYAB(Sk4f(1,2,3,4), Sk4f(5,6,7,8))); | 143 ASSERT_EQ(Sk4f(1,2,5,6), Sk4f::XYAB(Sk4f(1,2,3,4), Sk4f(5,6,7,8))); |
135 ASSERT_EQ(Sk4f(3,4,7,8), Sk4f::ZWCD(Sk4f(1,2,3,4), Sk4f(5,6,7,8))); | 144 ASSERT_EQ(Sk4f(3,4,7,8), Sk4f::ZWCD(Sk4f(1,2,3,4), Sk4f(5,6,7,8))); |
136 ASSERT_EQ(Sk4i(3,4,1,2), Sk4i(1,2,3,4).zwxy()); | 145 ASSERT_EQ(Sk4i(3,4,1,2), Sk4i(1,2,3,4).zwxy()); |
137 ASSERT_EQ(Sk4i(1,2,5,6), Sk4i::XYAB(Sk4i(1,2,3,4), Sk4i(5,6,7,8))); | 146 ASSERT_EQ(Sk4i(1,2,5,6), Sk4i::XYAB(Sk4i(1,2,3,4), Sk4i(5,6,7,8))); |
138 ASSERT_EQ(Sk4i(3,4,7,8), Sk4i::ZWCD(Sk4i(1,2,3,4), Sk4i(5,6,7,8))); | 147 ASSERT_EQ(Sk4i(3,4,7,8), Sk4i::ZWCD(Sk4i(1,2,3,4), Sk4i(5,6,7,8))); |
139 } | 148 } |
OLD | NEW |