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

Side by Side Diff: cc/base/math_util_unittest.cc

Issue 2803853007: Ignore rounding error between clip_layer_length_ and scroll_layer_length_ (Closed)
Patch Set: expose IsFloatNearlyTheSame & add comment Created 3 years, 8 months 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
« no previous file with comments | « cc/base/math_util.cc ('k') | cc/layers/scrollbar_layer_impl_base.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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
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
OLDNEW
« no previous file with comments | « cc/base/math_util.cc ('k') | cc/layers/scrollbar_layer_impl_base.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698