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

Unified Diff: base/bits_unittest.cc

Issue 2512593002: Move wtf/BitwiseOperations.h into base/bits.h. (Closed)
Patch Set: Add a TODO. Created 4 years, 1 month 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « base/bits.h ('k') | third_party/WebKit/Source/wtf/BitwiseOperations.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: base/bits_unittest.cc
diff --git a/base/bits_unittest.cc b/base/bits_unittest.cc
index 4f5b6ea49e5a825e119a066692966afd3787e277..270b8ef7d3b472557c0a1840e57a6f46c3d52b5d 100644
--- a/base/bits_unittest.cc
+++ b/base/bits_unittest.cc
@@ -61,5 +61,25 @@ TEST(BitsTest, Align) {
EXPECT_EQ(kSizeTMax / 2 + 1, Align(1, kSizeTMax / 2 + 1));
}
+TEST(BitsTest, CLZWorks) {
+ EXPECT_EQ(32u, CountLeadingZeroBits32(0u));
+ EXPECT_EQ(31u, CountLeadingZeroBits32(1u));
+ EXPECT_EQ(1u, CountLeadingZeroBits32(1u << 30));
+ EXPECT_EQ(0u, CountLeadingZeroBits32(1u << 31));
+
+#if defined(ARCH_CPU_64_BITS)
+ EXPECT_EQ(64u, CountLeadingZeroBitsSizeT(0ull));
+ EXPECT_EQ(63u, CountLeadingZeroBitsSizeT(1ull));
+ EXPECT_EQ(32u, CountLeadingZeroBitsSizeT(1ull << 31));
+ EXPECT_EQ(1u, CountLeadingZeroBitsSizeT(1ull << 62));
+ EXPECT_EQ(0u, CountLeadingZeroBitsSizeT(1ull << 63));
+#else
+ EXPECT_EQ(32u, CountLeadingZeroBitsSizeT(0u));
+ EXPECT_EQ(31u, CountLeadingZeroBitsSizeT(1u));
+ EXPECT_EQ(1u, CountLeadingZeroBitsSizeT(1u << 30));
+ EXPECT_EQ(0u, CountLeadingZeroBitsSizeT(1u << 31));
+#endif
+}
+
} // namespace bits
} // namespace base
« no previous file with comments | « base/bits.h ('k') | third_party/WebKit/Source/wtf/BitwiseOperations.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698