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

Side by Side Diff: test/cctest/test-conversions.cc

Issue 877753007: Reland "Initial switch to Chromium-style CHECK_* and DCHECK_* macros.". (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: VS201x now happy? Created 5 years, 10 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 | « test/cctest/test-circular-queue.cc ('k') | test/cctest/test-cpu-profiler.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 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 300 matching lines...) Expand 10 before | Expand all | Expand 10 after
311 class OneBit2: public BitField<uint32_t, 7, 1> {}; 311 class OneBit2: public BitField<uint32_t, 7, 1> {};
312 class EightBit1: public BitField<uint32_t, 0, 8> {}; 312 class EightBit1: public BitField<uint32_t, 0, 8> {};
313 class EightBit2: public BitField<uint32_t, 13, 8> {}; 313 class EightBit2: public BitField<uint32_t, 13, 8> {};
314 314
315 TEST(BitField) { 315 TEST(BitField) {
316 uint32_t x; 316 uint32_t x;
317 317
318 // One bit bit field can hold values 0 and 1. 318 // One bit bit field can hold values 0 and 1.
319 CHECK(!OneBit1::is_valid(static_cast<uint32_t>(-1))); 319 CHECK(!OneBit1::is_valid(static_cast<uint32_t>(-1)));
320 CHECK(!OneBit2::is_valid(static_cast<uint32_t>(-1))); 320 CHECK(!OneBit2::is_valid(static_cast<uint32_t>(-1)));
321 for (int i = 0; i < 2; i++) { 321 for (unsigned i = 0; i < 2; i++) {
322 CHECK(OneBit1::is_valid(i)); 322 CHECK(OneBit1::is_valid(i));
323 x = OneBit1::encode(i); 323 x = OneBit1::encode(i);
324 CHECK_EQ(i, OneBit1::decode(x)); 324 CHECK_EQ(i, OneBit1::decode(x));
325 325
326 CHECK(OneBit2::is_valid(i)); 326 CHECK(OneBit2::is_valid(i));
327 x = OneBit2::encode(i); 327 x = OneBit2::encode(i);
328 CHECK_EQ(i, OneBit2::decode(x)); 328 CHECK_EQ(i, OneBit2::decode(x));
329 } 329 }
330 CHECK(!OneBit1::is_valid(2)); 330 CHECK(!OneBit1::is_valid(2));
331 CHECK(!OneBit2::is_valid(2)); 331 CHECK(!OneBit2::is_valid(2));
332 332
333 // Eight bit bit field can hold values from 0 tp 255. 333 // Eight bit bit field can hold values from 0 tp 255.
334 CHECK(!EightBit1::is_valid(static_cast<uint32_t>(-1))); 334 CHECK(!EightBit1::is_valid(static_cast<uint32_t>(-1)));
335 CHECK(!EightBit2::is_valid(static_cast<uint32_t>(-1))); 335 CHECK(!EightBit2::is_valid(static_cast<uint32_t>(-1)));
336 for (int i = 0; i < 256; i++) { 336 for (unsigned i = 0; i < 256; i++) {
337 CHECK(EightBit1::is_valid(i)); 337 CHECK(EightBit1::is_valid(i));
338 x = EightBit1::encode(i); 338 x = EightBit1::encode(i);
339 CHECK_EQ(i, EightBit1::decode(x)); 339 CHECK_EQ(i, EightBit1::decode(x));
340 CHECK(EightBit2::is_valid(i)); 340 CHECK(EightBit2::is_valid(i));
341 x = EightBit2::encode(i); 341 x = EightBit2::encode(i);
342 CHECK_EQ(i, EightBit2::decode(x)); 342 CHECK_EQ(i, EightBit2::decode(x));
343 } 343 }
344 CHECK(!EightBit1::is_valid(256)); 344 CHECK(!EightBit1::is_valid(256));
345 CHECK(!EightBit2::is_valid(256)); 345 CHECK(!EightBit2::is_valid(256));
346 } 346 }
347 347
348 348
349 class UpperBits: public BitField64<int, 61, 3> {}; 349 class UpperBits: public BitField64<int, 61, 3> {};
350 class MiddleBits: public BitField64<int, 31, 2> {}; 350 class MiddleBits: public BitField64<int, 31, 2> {};
351 351
352 TEST(BitField64) { 352 TEST(BitField64) {
353 uint64_t x; 353 uint64_t x;
354 354
355 // Test most significant bits. 355 // Test most significant bits.
356 x = V8_2PART_UINT64_C(0xE0000000, 00000000); 356 x = V8_2PART_UINT64_C(0xE0000000, 00000000);
357 CHECK(x == UpperBits::encode(7)); 357 CHECK(x == UpperBits::encode(7));
358 CHECK_EQ(7, UpperBits::decode(x)); 358 CHECK_EQ(7, UpperBits::decode(x));
359 359
360 // Test the 32/64-bit boundary bits. 360 // Test the 32/64-bit boundary bits.
361 x = V8_2PART_UINT64_C(0x00000001, 80000000); 361 x = V8_2PART_UINT64_C(0x00000001, 80000000);
362 CHECK(x == MiddleBits::encode(3)); 362 CHECK(x == MiddleBits::encode(3));
363 CHECK_EQ(3, MiddleBits::decode(x)); 363 CHECK_EQ(3, MiddleBits::decode(x));
364 } 364 }
OLDNEW
« no previous file with comments | « test/cctest/test-circular-queue.cc ('k') | test/cctest/test-cpu-profiler.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698