| OLD | NEW |
| 1 // Copyright 2012 The Chromium Authors. All rights reserved. | 1 // Copyright 2012 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "cc/base/math_util.h" | 5 #include "cc/base/math_util.h" |
| 6 | 6 |
| 7 #include <stdint.h> | 7 #include <stdint.h> |
| 8 | 8 |
| 9 #include <cmath> | 9 #include <cmath> |
| 10 | 10 |
| (...skipping 439 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 450 } | 450 } |
| 451 | 451 |
| 452 TEST(MathUtilTest, RoundDownUnderflow) { | 452 TEST(MathUtilTest, RoundDownUnderflow) { |
| 453 // Rounding down -123 by 50 is -150, which underflows int8_t, but fits in | 453 // Rounding down -123 by 50 is -150, which underflows int8_t, but fits in |
| 454 // int16_t. | 454 // int16_t. |
| 455 EXPECT_FALSE(MathUtil::VerifyRoundDown<int8_t>(-123, 50)); | 455 EXPECT_FALSE(MathUtil::VerifyRoundDown<int8_t>(-123, 50)); |
| 456 EXPECT_TRUE(MathUtil::VerifyRoundDown<int16_t>(-123, 50)); | 456 EXPECT_TRUE(MathUtil::VerifyRoundDown<int16_t>(-123, 50)); |
| 457 } | 457 } |
| 458 | 458 |
| 459 #define EXPECT_SIMILAR_VALUE(x, y) \ | 459 #define EXPECT_SIMILAR_VALUE(x, y) \ |
| 460 EXPECT_TRUE(MathUtil::IsNearlyTheSameForTesting(x, y)) | 460 EXPECT_TRUE(MathUtil::IsFloatNearlyTheSame(x, y)) |
| 461 #define EXPECT_DISSIMILAR_VALUE(x, y) \ | 461 #define EXPECT_DISSIMILAR_VALUE(x, y) \ |
| 462 EXPECT_FALSE(MathUtil::IsNearlyTheSameForTesting(x, y)) | 462 EXPECT_FALSE(MathUtil::IsFloatNearlyTheSame(x, y)) |
| 463 | 463 |
| 464 // Arbitrary point that shouldn't be different from zero. | 464 // Arbitrary point that shouldn't be different from zero. |
| 465 static const float zeroish = 1.0e-11f; | 465 static const float zeroish = 1.0e-11f; |
| 466 | 466 |
| 467 TEST(MathUtilTest, Approximate) { | 467 TEST(MathUtilTest, Approximate) { |
| 468 // Same should be similar. | 468 // Same should be similar. |
| 469 EXPECT_SIMILAR_VALUE(1.0f, 1.0f); | 469 EXPECT_SIMILAR_VALUE(1.0f, 1.0f); |
| 470 | 470 |
| 471 // Zero should not cause similarity issues. | 471 // Zero should not cause similarity issues. |
| 472 EXPECT_SIMILAR_VALUE(0.0f, 0.0f); | 472 EXPECT_SIMILAR_VALUE(0.0f, 0.0f); |
| (...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 622 int num_vertices_in_clipped_quad; | 622 int num_vertices_in_clipped_quad; |
| 623 | 623 |
| 624 MathUtil::MapClippedQuad3d(transform, src_quad, clipped_quad, | 624 MathUtil::MapClippedQuad3d(transform, src_quad, clipped_quad, |
| 625 &num_vertices_in_clipped_quad); | 625 &num_vertices_in_clipped_quad); |
| 626 | 626 |
| 627 EXPECT_EQ(num_vertices_in_clipped_quad, 4); | 627 EXPECT_EQ(num_vertices_in_clipped_quad, 4); |
| 628 } | 628 } |
| 629 | 629 |
| 630 } // namespace | 630 } // namespace |
| 631 } // namespace cc | 631 } // namespace cc |
| OLD | NEW |