OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2012 Intel Corporation | 2 * Copyright (C) 2012 Intel Corporation |
3 * | 3 * |
4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
5 * modification, are permitted provided that the following conditions | 5 * modification, are permitted provided that the following conditions |
6 * are met: | 6 * are met: |
7 * 1. Redistributions of source code must retain the above copyright | 7 * 1. Redistributions of source code must retain the above copyright |
8 * notice, this list of conditions and the following disclaimer. | 8 * notice, this list of conditions and the following disclaimer. |
9 * 2. Redistributions in binary form must reproduce the above copyright | 9 * 2. Redistributions in binary form must reproduce the above copyright |
10 * notice, this list of conditions and the following disclaimer in the | 10 * notice, this list of conditions and the following disclaimer in the |
(...skipping 22 matching lines...) Expand all Loading... |
33 EXPECT_EQ(-8, lrint(-7.5)); | 33 EXPECT_EQ(-8, lrint(-7.5)); |
34 EXPECT_EQ(-8, lrint(-8.5)); | 34 EXPECT_EQ(-8, lrint(-8.5)); |
35 EXPECT_EQ(0, lrint(-0.5)); | 35 EXPECT_EQ(0, lrint(-0.5)); |
36 EXPECT_EQ(0, lrint(0.5)); | 36 EXPECT_EQ(0, lrint(0.5)); |
37 EXPECT_EQ(0, lrint(-0.5)); | 37 EXPECT_EQ(0, lrint(-0.5)); |
38 EXPECT_EQ(1, lrint(1.3)); | 38 EXPECT_EQ(1, lrint(1.3)); |
39 EXPECT_EQ(2, lrint(1.7)); | 39 EXPECT_EQ(2, lrint(1.7)); |
40 EXPECT_EQ(0, lrint(0)); | 40 EXPECT_EQ(0, lrint(0)); |
41 EXPECT_EQ(0, lrint(-0)); | 41 EXPECT_EQ(0, lrint(-0)); |
42 if (sizeof(long int) == 8) { | 42 if (sizeof(long int) == 8) { |
43 // Largest double number with 0.5 precision and one halfway rounding case be
low. | 43 // Largest double number with 0.5 precision and one halfway rounding case |
| 44 // below. |
44 EXPECT_EQ(pow(2.0, 52), lrint(pow(2.0, 52) - 0.5)); | 45 EXPECT_EQ(pow(2.0, 52), lrint(pow(2.0, 52) - 0.5)); |
45 EXPECT_EQ(pow(2.0, 52) - 2, lrint(pow(2.0, 52) - 1.5)); | 46 EXPECT_EQ(pow(2.0, 52) - 2, lrint(pow(2.0, 52) - 1.5)); |
46 // Smallest double number with 0.5 precision and one halfway rounding case a
bove. | 47 // Smallest double number with 0.5 precision and one halfway rounding case |
| 48 // above. |
47 EXPECT_EQ(-pow(2.0, 52), lrint(-pow(2.0, 52) + 0.5)); | 49 EXPECT_EQ(-pow(2.0, 52), lrint(-pow(2.0, 52) + 0.5)); |
48 EXPECT_EQ(-pow(2.0, 52) + 2, lrint(-pow(2.0, 52) + 1.5)); | 50 EXPECT_EQ(-pow(2.0, 52) + 2, lrint(-pow(2.0, 52) + 1.5)); |
49 } | 51 } |
50 } | 52 } |
51 | 53 |
52 TEST(MathExtrasTest, clampToIntLong) { | 54 TEST(MathExtrasTest, clampToIntLong) { |
53 if (sizeof(long) == sizeof(int)) | 55 if (sizeof(long) == sizeof(int)) |
54 return; | 56 return; |
55 | 57 |
56 long maxInt = std::numeric_limits<int>::max(); | 58 long maxInt = std::numeric_limits<int>::max(); |
(...skipping 194 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
251 EXPECT_EQ(0.0, fmod(0.0, negInf)); | 253 EXPECT_EQ(0.0, fmod(0.0, negInf)); |
252 EXPECT_EQ(7.0, fmod(7.0, negInf)); | 254 EXPECT_EQ(7.0, fmod(7.0, negInf)); |
253 EXPECT_EQ(-7.0, fmod(-7.0, negInf)); | 255 EXPECT_EQ(-7.0, fmod(-7.0, negInf)); |
254 | 256 |
255 EXPECT_EQ(1.0, pow(5.0, 0.0)); | 257 EXPECT_EQ(1.0, pow(5.0, 0.0)); |
256 EXPECT_EQ(1.0, pow(-5.0, 0.0)); | 258 EXPECT_EQ(1.0, pow(-5.0, 0.0)); |
257 EXPECT_EQ(1.0, pow(nan, 0.0)); | 259 EXPECT_EQ(1.0, pow(nan, 0.0)); |
258 } | 260 } |
259 | 261 |
260 } // namespace WTF | 262 } // namespace WTF |
OLD | NEW |