OLD | NEW |
1 // Copyright 2011 the V8 project authors. All rights reserved. | 1 // Copyright 2011 the V8 project authors. All rights reserved. |
2 // Redistribution and use in source and binary forms, with or without | 2 // Redistribution and use in source and binary forms, with or without |
3 // modification, are permitted provided that the following conditions are | 3 // modification, are permitted provided that the following conditions are |
4 // met: | 4 // met: |
5 // | 5 // |
6 // * Redistributions of source code must retain the above copyright | 6 // * Redistributions of source code must retain the above copyright |
7 // notice, this list of conditions and the following disclaimer. | 7 // notice, this list of conditions and the following disclaimer. |
8 // * Redistributions in binary form must reproduce the above | 8 // * Redistributions in binary form must reproduce the above |
9 // copyright notice, this list of conditions and the following | 9 // copyright notice, this list of conditions and the following |
10 // disclaimer in the documentation and/or other materials provided | 10 // disclaimer in the documentation and/or other materials provided |
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
81 typedef BitSetComputer<bool, 1, kSmiValueSize, uint32_t> BoolComputer; | 81 typedef BitSetComputer<bool, 1, kSmiValueSize, uint32_t> BoolComputer; |
82 CHECK_EQ(0, BoolComputer::word_count(0)); | 82 CHECK_EQ(0, BoolComputer::word_count(0)); |
83 CHECK_EQ(1, BoolComputer::word_count(8)); | 83 CHECK_EQ(1, BoolComputer::word_count(8)); |
84 CHECK_EQ(2, BoolComputer::word_count(50)); | 84 CHECK_EQ(2, BoolComputer::word_count(50)); |
85 CHECK_EQ(0, BoolComputer::index(0, 8)); | 85 CHECK_EQ(0, BoolComputer::index(0, 8)); |
86 CHECK_EQ(100, BoolComputer::index(100, 8)); | 86 CHECK_EQ(100, BoolComputer::index(100, 8)); |
87 CHECK_EQ(1, BoolComputer::index(0, 40)); | 87 CHECK_EQ(1, BoolComputer::index(0, 40)); |
88 uint32_t data = 0; | 88 uint32_t data = 0; |
89 data = BoolComputer::encode(data, 1, true); | 89 data = BoolComputer::encode(data, 1, true); |
90 data = BoolComputer::encode(data, 4, true); | 90 data = BoolComputer::encode(data, 4, true); |
91 CHECK_EQ(true, BoolComputer::decode(data, 1)); | 91 CHECK(BoolComputer::decode(data, 1)); |
92 CHECK_EQ(true, BoolComputer::decode(data, 4)); | 92 CHECK(BoolComputer::decode(data, 4)); |
93 CHECK_EQ(false, BoolComputer::decode(data, 0)); | 93 CHECK(!BoolComputer::decode(data, 0)); |
94 CHECK_EQ(false, BoolComputer::decode(data, 2)); | 94 CHECK(!BoolComputer::decode(data, 2)); |
95 CHECK_EQ(false, BoolComputer::decode(data, 3)); | 95 CHECK(!BoolComputer::decode(data, 3)); |
96 | 96 |
97 // Lets store 2 bits per item with 3000 items and verify the values are | 97 // Lets store 2 bits per item with 3000 items and verify the values are |
98 // correct. | 98 // correct. |
99 typedef BitSetComputer<unsigned char, 2, 8, unsigned char> TwoBits; | 99 typedef BitSetComputer<unsigned char, 2, 8, unsigned char> TwoBits; |
100 const int words = 750; | 100 const int words = 750; |
101 CHECK_EQ(words, TwoBits::word_count(3000)); | 101 CHECK_EQ(words, TwoBits::word_count(3000)); |
102 const int offset = 10; | 102 const int offset = 10; |
103 Vector<unsigned char> buffer = Vector<unsigned char>::New(offset + words); | 103 Vector<unsigned char> buffer = Vector<unsigned char>::New(offset + words); |
104 memset(buffer.start(), 0, sizeof(unsigned char) * buffer.length()); | 104 memset(buffer.start(), 0, sizeof(unsigned char) * buffer.length()); |
105 for (int i = 0; i < words; i++) { | 105 for (int i = 0; i < words; i++) { |
(...skipping 183 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
289 vec.push_back(66); | 289 vec.push_back(66); |
290 for (auto& i : vec) { | 290 for (auto& i : vec) { |
291 ++i; | 291 ++i; |
292 } | 292 } |
293 int j = 12; | 293 int j = 12; |
294 for (auto i : vec) { | 294 for (auto i : vec) { |
295 CHECK_EQ(j, i); | 295 CHECK_EQ(j, i); |
296 j += 11; | 296 j += 11; |
297 } | 297 } |
298 } | 298 } |
OLD | NEW |