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

Side by Side Diff: tests/MathTest.cpp

Issue 100113004: Use DEFINE_TESTCLASS_SHORT macro in tests. (Closed) Base URL: https://skia.googlecode.com/svn/trunk
Patch Set: rebase Created 7 years 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « tests/MD5Test.cpp ('k') | tests/Matrix44Test.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1
2 /* 1 /*
3 * Copyright 2011 Google Inc. 2 * Copyright 2011 Google Inc.
4 * 3 *
5 * Use of this source code is governed by a BSD-style license that can be 4 * Use of this source code is governed by a BSD-style license that can be
6 * found in the LICENSE file. 5 * found in the LICENSE file.
7 */ 6 */
7
8 #include "Test.h" 8 #include "Test.h"
9 #include "TestClassDef.h"
10 #include "SkColorPriv.h"
11 #include "SkEndian.h"
9 #include "SkFloatBits.h" 12 #include "SkFloatBits.h"
10 #include "SkFloatingPoint.h" 13 #include "SkFloatingPoint.h"
11 #include "SkMathPriv.h" 14 #include "SkMathPriv.h"
12 #include "SkPoint.h" 15 #include "SkPoint.h"
13 #include "SkRandom.h" 16 #include "SkRandom.h"
14 #include "SkColorPriv.h"
15 17
16 static void test_clz(skiatest::Reporter* reporter) { 18 static void test_clz(skiatest::Reporter* reporter) {
17 REPORTER_ASSERT(reporter, 32 == SkCLZ(0)); 19 REPORTER_ASSERT(reporter, 32 == SkCLZ(0));
18 REPORTER_ASSERT(reporter, 31 == SkCLZ(1)); 20 REPORTER_ASSERT(reporter, 31 == SkCLZ(1));
19 REPORTER_ASSERT(reporter, 1 == SkCLZ(1 << 30)); 21 REPORTER_ASSERT(reporter, 1 == SkCLZ(1 << 30));
20 REPORTER_ASSERT(reporter, 0 == SkCLZ(~0U)); 22 REPORTER_ASSERT(reporter, 0 == SkCLZ(~0U));
21 23
22 SkRandom rand; 24 SkRandom rand;
23 for (int i = 0; i < 1000; ++i) { 25 for (int i = 0; i < 1000; ++i) {
24 uint32_t mask = rand.nextU(); 26 uint32_t mask = rand.nextU();
(...skipping 398 matching lines...) Expand 10 before | Expand all | Expand 10 after
423 REPORTER_ASSERT(reporter, SkCopySign32(-ix, -ix) == -ix); 425 REPORTER_ASSERT(reporter, SkCopySign32(-ix, -ix) == -ix);
424 426
425 SkScalar sx = rand.nextSScalar1(); 427 SkScalar sx = rand.nextSScalar1();
426 REPORTER_ASSERT(reporter, SkScalarCopySign(sx, sx) == sx); 428 REPORTER_ASSERT(reporter, SkScalarCopySign(sx, sx) == sx);
427 REPORTER_ASSERT(reporter, SkScalarCopySign(sx, -sx) == -sx); 429 REPORTER_ASSERT(reporter, SkScalarCopySign(sx, -sx) == -sx);
428 REPORTER_ASSERT(reporter, SkScalarCopySign(-sx, sx) == sx); 430 REPORTER_ASSERT(reporter, SkScalarCopySign(-sx, sx) == sx);
429 REPORTER_ASSERT(reporter, SkScalarCopySign(-sx, -sx) == -sx); 431 REPORTER_ASSERT(reporter, SkScalarCopySign(-sx, -sx) == -sx);
430 } 432 }
431 } 433 }
432 434
433 static void TestMath(skiatest::Reporter* reporter) { 435 DEF_TEST(Math, reporter) {
434 int i; 436 int i;
435 int32_t x; 437 int32_t x;
436 SkRandom rand; 438 SkRandom rand;
437 439
438 // these should assert 440 // these should assert
439 #if 0 441 #if 0
440 SkToS8(128); 442 SkToS8(128);
441 SkToS8(-129); 443 SkToS8(-129);
442 SkToU8(256); 444 SkToU8(256);
443 SkToU8(-5); 445 SkToU8(-5);
(...skipping 195 matching lines...) Expand 10 before | Expand all | Expand 10 after
639 641
640 if (false) test_floor(reporter); 642 if (false) test_floor(reporter);
641 643
642 // disable for now 644 // disable for now
643 if (false) test_blend31(); // avoid bit rot, suppress warning 645 if (false) test_blend31(); // avoid bit rot, suppress warning
644 646
645 test_muldivround(reporter); 647 test_muldivround(reporter);
646 test_clz(reporter); 648 test_clz(reporter);
647 } 649 }
648 650
649 #include "TestClassDef.h"
650 DEFINE_TESTCLASS("Math", MathTestClass, TestMath)
651
652 ///////////////////////////////////////////////////////////////////////////////
653
654 #include "SkEndian.h"
655
656 template <typename T> struct PairRec { 651 template <typename T> struct PairRec {
657 T fYin; 652 T fYin;
658 T fYang; 653 T fYang;
659 }; 654 };
660 655
661 static void TestEndian(skiatest::Reporter* reporter) { 656 DEF_TEST(TestEndian, reporter) {
662 static const PairRec<uint16_t> g16[] = { 657 static const PairRec<uint16_t> g16[] = {
663 { 0x0, 0x0 }, 658 { 0x0, 0x0 },
664 { 0xFFFF, 0xFFFF }, 659 { 0xFFFF, 0xFFFF },
665 { 0x1122, 0x2211 }, 660 { 0x1122, 0x2211 },
666 }; 661 };
667 static const PairRec<uint32_t> g32[] = { 662 static const PairRec<uint32_t> g32[] = {
668 { 0x0, 0x0 }, 663 { 0x0, 0x0 },
669 { 0xFFFFFFFF, 0xFFFFFFFF }, 664 { 0xFFFFFFFF, 0xFFFFFFFF },
670 { 0x11223344, 0x44332211 }, 665 { 0x11223344, 0x44332211 },
671 }; 666 };
(...skipping 11 matching lines...) Expand all
683 REPORTER_ASSERT(reporter, g16[i].fYang == SkEndianSwap16(g16[i].fYin)); 678 REPORTER_ASSERT(reporter, g16[i].fYang == SkEndianSwap16(g16[i].fYin));
684 } 679 }
685 for (size_t i = 0; i < SK_ARRAY_COUNT(g32); ++i) { 680 for (size_t i = 0; i < SK_ARRAY_COUNT(g32); ++i) {
686 REPORTER_ASSERT(reporter, g32[i].fYang == SkEndianSwap32(g32[i].fYin)); 681 REPORTER_ASSERT(reporter, g32[i].fYang == SkEndianSwap32(g32[i].fYin));
687 } 682 }
688 for (size_t i = 0; i < SK_ARRAY_COUNT(g64); ++i) { 683 for (size_t i = 0; i < SK_ARRAY_COUNT(g64); ++i) {
689 REPORTER_ASSERT(reporter, g64[i].fYang == SkEndianSwap64(g64[i].fYin)); 684 REPORTER_ASSERT(reporter, g64[i].fYang == SkEndianSwap64(g64[i].fYin));
690 } 685 }
691 } 686 }
692 687
693 DEFINE_TESTCLASS("Endian", EndianTestClass, TestEndian)
694
695 template <typename T> 688 template <typename T>
696 static void test_divmod(skiatest::Reporter* r) { 689 static void test_divmod(skiatest::Reporter* r) {
697 const struct { 690 const struct {
698 T numer; 691 T numer;
699 T denom; 692 T denom;
700 } kEdgeCases[] = { 693 } kEdgeCases[] = {
701 {(T)17, (T)17}, 694 {(T)17, (T)17},
702 {(T)17, (T)4}, 695 {(T)17, (T)4},
703 {(T)0, (T)17}, 696 {(T)0, (T)17},
704 // For unsigned T these negatives are just some large numbers. Doesn't hurt to test them. 697 // For unsigned T these negatives are just some large numbers. Doesn't hurt to test them.
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
755 test_divmod<int16_t>(r); 748 test_divmod<int16_t>(r);
756 } 749 }
757 750
758 DEF_TEST(divmod_s32, r) { 751 DEF_TEST(divmod_s32, r) {
759 test_divmod<int32_t>(r); 752 test_divmod<int32_t>(r);
760 } 753 }
761 754
762 DEF_TEST(divmod_s64, r) { 755 DEF_TEST(divmod_s64, r) {
763 test_divmod<int64_t>(r); 756 test_divmod<int64_t>(r);
764 } 757 }
OLDNEW
« no previous file with comments | « tests/MD5Test.cpp ('k') | tests/Matrix44Test.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698