Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(470)

Unified Diff: tests/Sk4xTest.cpp

Issue 1048593002: Refactor Sk2x<T> + Sk4x<T> into SkNf<N,T> and SkNi<N,T> (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: This is actually faster Created 5 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « tests/Sk2xTest.cpp ('k') | tests/SkNxTest.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tests/Sk4xTest.cpp
diff --git a/tests/Sk4xTest.cpp b/tests/Sk4xTest.cpp
deleted file mode 100644
index 4dc4c3621cc78ace09cf2f79f0c59d69950f6a8c..0000000000000000000000000000000000000000
--- a/tests/Sk4xTest.cpp
+++ /dev/null
@@ -1,145 +0,0 @@
-#include "Test.h"
-#include "Sk4x.h"
-
-#define ASSERT_EQ(a, b) REPORTER_ASSERT(r, a.equal(b).allTrue())
-#define ASSERT_NE(a, b) REPORTER_ASSERT(r, a.notEqual(b).allTrue())
-
-DEF_TEST(Sk4x_Construction, r) {
- Sk4f uninitialized;
- Sk4f zero(0,0,0,0);
- Sk4f foo(1,2,3,4),
- bar(foo),
- baz = bar;
- ASSERT_EQ(foo, bar);
- ASSERT_EQ(bar, baz);
- ASSERT_EQ(baz, foo);
-}
-
-struct AlignedFloats {
- Sk4f forces16ByteAlignment; // On 64-bit machines, the stack starts 128-bit aligned,
- float fs[5]; // but not necessarily so on 32-bit. Adding an Sk4f forces it.
-};
-
-DEF_TEST(Sk4x_LoadStore, r) {
- AlignedFloats aligned;
- // fs will be 16-byte aligned, fs+1 not.
- float* fs = aligned.fs;
- for (int i = 0; i < 5; i++) { // set to 5,6,7,8,9
- fs[i] = float(i+5);
- }
-
- Sk4f foo = Sk4f::Load(fs);
- Sk4f bar = Sk4f::LoadAligned(fs);
- ASSERT_EQ(foo, bar);
-
- foo = Sk4f::Load(fs+1);
- ASSERT_NE(foo, bar);
-
- foo.storeAligned(fs);
- bar.store(fs+1);
- REPORTER_ASSERT(r, fs[0] == 6 &&
- fs[1] == 5 &&
- fs[2] == 6 &&
- fs[3] == 7 &&
- fs[4] == 8);
-}
-
-DEF_TEST(Sk4x_Conversions, r) {
- // Assuming IEEE floats.
- Sk4f zerof(0,0,0,0);
- Sk4i zeroi(0,0,0,0);
- ASSERT_EQ(zeroi, zerof.cast<Sk4i>());
- ASSERT_EQ(zeroi, zerof.reinterpret<Sk4i>());
- ASSERT_EQ(zerof, zeroi.cast<Sk4f>());
- ASSERT_EQ(zerof, zeroi.reinterpret<Sk4f>());
-
- Sk4f twof(2,2,2,2);
- Sk4i twoi(2,2,2,2);
- ASSERT_EQ(twoi, twof.cast<Sk4i>());
- ASSERT_NE(twoi, twof.reinterpret<Sk4i>());
- ASSERT_EQ(twof, twoi.cast<Sk4f>());
- ASSERT_NE(twof, twoi.reinterpret<Sk4f>());
-
- ASSERT_EQ(Sk4i(0,0,0,0), Sk4f(0.5f, 0.49f, 0.51f, 0.99f).cast<Sk4i>());
- ASSERT_EQ(Sk4i(1,1,1,1), Sk4f(1.5f, 1.49f, 1.51f, 1.99f).cast<Sk4i>());
-}
-
-DEF_TEST(Sk4x_Bits, r) {
- ASSERT_EQ(Sk4i(0,0,0,0).bitNot(), Sk4i(-1,-1,-1,-1));
-
- Sk4i a(2,3,4,5),
- b(1,3,5,7);
- ASSERT_EQ(Sk4i(0,3,4,5), a & b);
- ASSERT_EQ(Sk4i(3,3,5,7), a | b);
-}
-
-DEF_TEST(Sk4x_Arith, r) {
- ASSERT_EQ(Sk4f(4,6,8,10), Sk4f(1,2,3,4) + Sk4f(3,4,5,6));
- ASSERT_EQ(Sk4f(-2,-2,-2,-2), Sk4f(1,2,3,4) - Sk4f(3,4,5,6));
- ASSERT_EQ(Sk4f(3,8,15,24), Sk4f(1,2,3,4) * Sk4f(3,4,5,6));
-
- ASSERT_EQ(Sk4f(-1,-2,-3,-4), -Sk4f(1,2,3,4));
-
- float third = 1.0f/3.0f;
- ASSERT_EQ(Sk4f(1*third, 0.5f, 0.6f, 2*third), Sk4f(1,2,3,4) / Sk4f(3,4,5,6));
- ASSERT_EQ(Sk4i(4,6,8,10), Sk4i(1,2,3,4) + Sk4i(3,4,5,6));
- ASSERT_EQ(Sk4i(-2,-2,-2,-2), Sk4i(1,2,3,4) - Sk4i(3,4,5,6));
- ASSERT_EQ(Sk4i(3,8,15,24), Sk4i(1,2,3,4) * Sk4i(3,4,5,6));
-}
-
-DEF_TEST(Sk4x_ExplicitPromotion, r) {
- ASSERT_EQ(Sk4f(2,4,6,8), Sk4f(1,2,3,4) * Sk4f(2.0f));
-}
-
-DEF_TEST(Sk4x_Sqrt, r) {
- Sk4f squares(4, 16, 25, 121),
- roots(2, 4, 5, 11);
- // .sqrt() should be pretty precise.
- Sk4f error = roots.subtract(squares.sqrt());
- REPORTER_ASSERT(r, (error > Sk4f(-0.000001f)).allTrue());
- REPORTER_ASSERT(r, (error < Sk4f(+0.000001f)).allTrue());
-
- // .rsqrt() isn't so precise (for SSE), but should be pretty close.
- error = roots.subtract(squares.multiply(squares.rsqrt()));
- REPORTER_ASSERT(r, (error > Sk4f(-0.01f)).allTrue());
- REPORTER_ASSERT(r, (error < Sk4f(+0.01f)).allTrue());
-}
-
-DEF_TEST(Sk4x_Comparison, r) {
- ASSERT_EQ(Sk4f(1,2,3,4), Sk4f(1,2,3,4));
- ASSERT_NE(Sk4f(4,3,2,1), Sk4f(1,2,3,4));
-
- ASSERT_EQ(Sk4i(-1,-1,0,-1), Sk4f(1,2,5,4) == Sk4f(1,2,3,4));
-
- ASSERT_EQ(Sk4i(-1,-1,-1,-1), Sk4f(1,2,3,4) < Sk4f(2,3,4,5));
- ASSERT_EQ(Sk4i(-1,-1,-1,-1), Sk4f(1,2,3,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aacc(), Sk4i(1,1,3,3));
- ASSERT_EQ(Sk4i(1,2,3,4).bbdd(), Sk4i(2,2,4,4));
-}
« no previous file with comments | « tests/Sk2xTest.cpp ('k') | tests/SkNxTest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698