1 /* 2 * Copyright 2016 Google Inc. 3 * 4 * Use of this source code is governed by a BSD-style license that can be 5 * found in the LICENSE file. 6 */ 7 8 #include "Sk4x4f.h" 9 #include "Test.h" 10 11 DEF_TEST(Sk4x4f, r) { 12 Sk4x4f f; 13 14 Sk4f x{ 0, 1, 2, 3}, 15 y{ 4, 5, 6, 7}, 16 z{ 8, 9,10,11}, 17 w{12,13,14,15}; 18 f = Sk4x4f::Transpose(x,y,z,w); 19 REPORTER_ASSERT(r, f.r[0] == 0 && f.r[1] == 4 && f.r[2] == 8 && f.r[3] == 12); 20 REPORTER_ASSERT(r, f.g[0] == 1 && f.g[1] == 5 && f.g[2] == 9 && f.g[3] == 13); 21 REPORTER_ASSERT(r, f.b[0] == 2 && f.b[1] == 6 && f.b[2] == 10 && f.b[3] == 14); 22 REPORTER_ASSERT(r, f.a[0] == 3 && f.a[1] == 7 && f.a[2] == 11 && f.a[3] == 15); 23 24 Sk4f s,t,u,v; 25 f.transpose(&s,&t,&u,&v); 26 REPORTER_ASSERT(r, (x == s).allTrue() 27 && (y == t).allTrue() 28 && (z == u).allTrue() 29 && (w == v).allTrue()); 30 31 32 float fs[16] = {0,1,2,3, 4,5,6,7, 8,9,10,11, 12,13,14,15}; 33 f = Sk4x4f::Transpose(fs); 34 REPORTER_ASSERT(r, f.r[0] == 0 && f.r[1] == 4 && f.r[2] == 8 && f.r[3] == 12); 35 REPORTER_ASSERT(r, f.g[0] == 1 && f.g[1] == 5 && f.g[2] == 9 && f.g[3] == 13); 36 REPORTER_ASSERT(r, f.b[0] == 2 && f.b[1] == 6 && f.b[2] == 10 && f.b[3] == 14); 37 REPORTER_ASSERT(r, f.a[0] == 3 && f.a[1] == 7 && f.a[2] == 11 && f.a[3] == 15); 38 39 float fs_back[16]; 40 f.transpose(fs_back); 41 REPORTER_ASSERT(r, 0 == memcmp(fs, fs_back, sizeof(fs))); 42 43 44 uint8_t bs[16] = {0,1,2,3, 4,5,6,7, 8,9,10,11, 12,13,14,15}; 45 f = Sk4x4f::Transpose(bs); 46 REPORTER_ASSERT(r, f.r[0] == 0 && f.r[1] == 4 && f.r[2] == 8 && f.r[3] == 12); 47 REPORTER_ASSERT(r, f.g[0] == 1 && f.g[1] == 5 && f.g[2] == 9 && f.g[3] == 13); 48 REPORTER_ASSERT(r, f.b[0] == 2 && f.b[1] == 6 && f.b[2] == 10 && f.b[3] == 14); 49 REPORTER_ASSERT(r, f.a[0] == 3 && f.a[1] == 7 && f.a[2] == 11 && f.a[3] == 15); 50 51 uint8_t bs_back[16]; 52 f.transpose(bs_back); 53 REPORTER_ASSERT(r, 0 == memcmp(bs, bs_back, sizeof(bs))); 54 } 55