OLD | NEW |
(Empty) | |
| 1 // Copyright 2010 the V8 project authors. All rights reserved. |
| 2 // |
| 3 // Tests of the unbound queue. |
| 4 |
| 5 #include "v8.h" |
| 6 #include "unbound-queue-inl.h" |
| 7 #include "cctest.h" |
| 8 |
| 9 namespace i = v8::internal; |
| 10 |
| 11 using i::UnboundQueue; |
| 12 |
| 13 |
| 14 TEST(SingleRecord) { |
| 15 typedef int Record; |
| 16 UnboundQueue<Record> cq; |
| 17 CHECK(cq.IsEmpty()); |
| 18 cq.Enqueue(1); |
| 19 CHECK(!cq.IsEmpty()); |
| 20 Record rec = 0; |
| 21 cq.Dequeue(&rec); |
| 22 CHECK_EQ(1, rec); |
| 23 CHECK(cq.IsEmpty()); |
| 24 } |
| 25 |
| 26 |
| 27 TEST(MultipleRecords) { |
| 28 typedef int Record; |
| 29 UnboundQueue<Record> cq; |
| 30 CHECK(cq.IsEmpty()); |
| 31 cq.Enqueue(1); |
| 32 CHECK(!cq.IsEmpty()); |
| 33 for (int i = 2; i <= 5; ++i) { |
| 34 cq.Enqueue(i); |
| 35 CHECK(!cq.IsEmpty()); |
| 36 } |
| 37 Record rec = 0; |
| 38 for (int i = 1; i <= 4; ++i) { |
| 39 CHECK(!cq.IsEmpty()); |
| 40 cq.Dequeue(&rec); |
| 41 CHECK_EQ(i, rec); |
| 42 } |
| 43 for (int i = 6; i <= 12; ++i) { |
| 44 cq.Enqueue(i); |
| 45 CHECK(!cq.IsEmpty()); |
| 46 } |
| 47 for (int i = 5; i <= 12; ++i) { |
| 48 CHECK(!cq.IsEmpty()); |
| 49 cq.Dequeue(&rec); |
| 50 CHECK_EQ(i, rec); |
| 51 } |
| 52 CHECK(cq.IsEmpty()); |
| 53 } |
| 54 |
OLD | NEW |