OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2011 Google Inc. | 2 * Copyright 2011 Google Inc. |
3 * | 3 * |
4 * 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 |
5 * found in the LICENSE file. | 5 * found in the LICENSE file. |
6 */ | 6 */ |
7 | 7 |
| 8 #include "float.h" |
| 9 |
8 #include "SkColorPriv.h" | 10 #include "SkColorPriv.h" |
9 #include "SkEndian.h" | 11 #include "SkEndian.h" |
10 #include "SkFloatBits.h" | 12 #include "SkFloatBits.h" |
11 #include "SkFloatingPoint.h" | 13 #include "SkFloatingPoint.h" |
12 #include "SkHalf.h" | 14 #include "SkHalf.h" |
13 #include "SkMathPriv.h" | 15 #include "SkMathPriv.h" |
14 #include "SkPoint.h" | 16 #include "SkPoint.h" |
15 #include "SkRandom.h" | 17 #include "SkRandom.h" |
16 #include "Test.h" | 18 #include "Test.h" |
17 | 19 |
(...skipping 671 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
689 test_divmod<int16_t>(r); | 691 test_divmod<int16_t>(r); |
690 } | 692 } |
691 | 693 |
692 DEF_TEST(divmod_s32, r) { | 694 DEF_TEST(divmod_s32, r) { |
693 test_divmod<int32_t>(r); | 695 test_divmod<int32_t>(r); |
694 } | 696 } |
695 | 697 |
696 DEF_TEST(divmod_s64, r) { | 698 DEF_TEST(divmod_s64, r) { |
697 test_divmod<int64_t>(r); | 699 test_divmod<int64_t>(r); |
698 } | 700 } |
| 701 |
| 702 DEF_TEST(PinToFixed, reporter) { |
| 703 // double |
| 704 REPORTER_ASSERT(reporter, 0 == SkDoublePinToFixed(0.0)); |
| 705 REPORTER_ASSERT(reporter, 0x10000 == SkDoublePinToFixed(1.0)); |
| 706 REPORTER_ASSERT(reporter, 0x7FFFFFFE == SkDoublePinToFixed(32767.999984741)); |
| 707 REPORTER_ASSERT(reporter, 0x7FFFFFFF == SkDoublePinToFixed(32767.999984742)); |
| 708 REPORTER_ASSERT(reporter, 0x7FFFFFFF == SkDoublePinToFixed(32767.999999999)); |
| 709 REPORTER_ASSERT(reporter, 0x7FFFFFFF == SkDoublePinToFixed(32768.0)); |
| 710 REPORTER_ASSERT(reporter, 0x7FFFFFFF == SkDoublePinToFixed(5e10)); |
| 711 REPORTER_ASSERT(reporter, 0x7FFFFFFF == SkDoublePinToFixed(DBL_MAX)); |
| 712 REPORTER_ASSERT(reporter, -0x10000 == SkDoublePinToFixed(-1.0)); |
| 713 // SK_FixedMin is defined to be -SK_FixedMax |
| 714 REPORTER_ASSERT(reporter, -0x7FFFFFFE == SkDoublePinToFixed(-32767.999984741))
; |
| 715 REPORTER_ASSERT(reporter, -0x7FFFFFFF == SkDoublePinToFixed(-32767.999984742))
; |
| 716 REPORTER_ASSERT(reporter, -0x7FFFFFFF == SkDoublePinToFixed(-32767.999999999))
; |
| 717 REPORTER_ASSERT(reporter, -0x7FFFFFFF == SkDoublePinToFixed(-32768.0)); |
| 718 REPORTER_ASSERT(reporter, -0x7FFFFFFF == SkDoublePinToFixed(-5e10)); |
| 719 REPORTER_ASSERT(reporter, -0x7FFFFFFF == SkDoublePinToFixed(-DBL_MAX)); |
| 720 |
| 721 // float |
| 722 REPORTER_ASSERT(reporter, 0 == SkFloatPinToFixed(0.0f)); |
| 723 REPORTER_ASSERT(reporter, 0x10000 == SkFloatPinToFixed(1.0f)); |
| 724 REPORTER_ASSERT(reporter, 0x7FFFFF80 == SkFloatPinToFixed(32767.9990f)); |
| 725 REPORTER_ASSERT(reporter, 0x7FFFFFFF == SkFloatPinToFixed(32767.9991f)); |
| 726 REPORTER_ASSERT(reporter, 0x7FFFFFFF == SkFloatPinToFixed(32768.0f)); |
| 727 REPORTER_ASSERT(reporter, 0x7FFFFFFF == SkFloatPinToFixed(5e10f)); |
| 728 REPORTER_ASSERT(reporter, 0x7FFFFFFF == SkFloatPinToFixed(FLT_MAX)); |
| 729 REPORTER_ASSERT(reporter, -0x10000 == SkFloatPinToFixed(-1.0f)); |
| 730 // SK_FixedMin is defined to be -SK_FixedMax |
| 731 REPORTER_ASSERT(reporter, -0x7FFFFF80 == SkFloatPinToFixed(-32767.9990f)); |
| 732 REPORTER_ASSERT(reporter, -0x7FFFFFFF == SkFloatPinToFixed(-32767.9991f)); |
| 733 REPORTER_ASSERT(reporter, -0x7FFFFFFF == SkFloatPinToFixed(-32768.0f)); |
| 734 REPORTER_ASSERT(reporter, -0x7FFFFFFF == SkFloatPinToFixed(-5e10f)); |
| 735 REPORTER_ASSERT(reporter, -0x7FFFFFFF == SkFloatPinToFixed(-FLT_MAX)); |
| 736 } |
OLD | NEW |