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

Unified Diff: test/cctest/test-utils.cc

Issue 679073002: A type vector with multiple IC types needs metadata. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Addressed comments. Created 6 years, 2 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « test/cctest/test-feedback-vector.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: test/cctest/test-utils.cc
diff --git a/test/cctest/test-utils.cc b/test/cctest/test-utils.cc
index 0c1e0412d3484db5d4d94a9c90732ae45e9ece29..8c5ad0e641d772cc11126c90a0ca4f76ea5e4fe3 100644
--- a/test/cctest/test-utils.cc
+++ b/test/cctest/test-utils.cc
@@ -76,6 +76,46 @@ TEST(Utils1) {
}
+TEST(BitSetComputer) {
+ typedef BitSetComputer<bool, 1, kSmiValueSize, uint32_t> BoolComputer;
+ CHECK_EQ(0, BoolComputer::word_count(0));
+ CHECK_EQ(1, BoolComputer::word_count(8));
+ CHECK_EQ(2, BoolComputer::word_count(50));
+ CHECK_EQ(0, BoolComputer::index(0, 8));
+ CHECK_EQ(100, BoolComputer::index(100, 8));
+ CHECK_EQ(1, BoolComputer::index(0, 40));
+ uint32_t data = 0;
+ data = BoolComputer::encode(data, 1, true);
+ data = BoolComputer::encode(data, 4, true);
+ CHECK_EQ(true, BoolComputer::decode(data, 1));
+ CHECK_EQ(true, BoolComputer::decode(data, 4));
+ CHECK_EQ(false, BoolComputer::decode(data, 0));
+ CHECK_EQ(false, BoolComputer::decode(data, 2));
+ CHECK_EQ(false, BoolComputer::decode(data, 3));
+
+ // Lets store 2 bits per item with 3000 items and verify the values are
+ // correct.
+ typedef BitSetComputer<unsigned char, 2, 8, unsigned char> TwoBits;
+ const int words = 750;
+ CHECK_EQ(words, TwoBits::word_count(3000));
+ const int offset = 10;
+ Vector<unsigned char> buffer = Vector<unsigned char>::New(offset + words);
+ memset(buffer.start(), 0, sizeof(unsigned char) * buffer.length());
+ for (int i = 0; i < words; i++) {
+ const int index = TwoBits::index(offset, i);
+ unsigned char data = buffer[index];
+ data = TwoBits::encode(data, i, i % 4);
+ buffer[index] = data;
+ }
+
+ for (int i = 0; i < words; i++) {
+ const int index = TwoBits::index(offset, i);
+ unsigned char data = buffer[index];
+ CHECK_EQ(i % 4, TwoBits::decode(data, i));
+ }
+}
+
+
TEST(SNPrintF) {
// Make sure that strings that are truncated because of too small
// buffers are zero-terminated anyway.
« no previous file with comments | « test/cctest/test-feedback-vector.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698