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

Side by Side Diff: test/cctest/test-gc-tracer.cc

Issue 414743002: Revert "Track history of events in GCTracer." (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 6 years, 5 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 | Annotate | Revision Log
« no previous file with comments | « test/cctest/cctest.gyp ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 // Copyright 2014 the V8 project authors. All rights reserved.
2 // Redistribution and use in source and binary forms, with or without
3 // modification, are permitted provided that the following conditions are
4 // met:
5 //
6 // * Redistributions of source code must retain the above copyright
7 // notice, this list of conditions and the following disclaimer.
8 // * Redistributions in binary form must reproduce the above
9 // copyright notice, this list of conditions and the following
10 // disclaimer in the documentation and/or other materials provided
11 // with the distribution.
12 // * Neither the name of Google Inc. nor the names of its
13 // contributors may be used to endorse or promote products derived
14 // from this software without specific prior written permission.
15 //
16 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
17 // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
18 // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
19 // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
20 // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
21 // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
22 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
23 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
24 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
26 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27
28 #include <stdlib.h>
29 #include <utility>
30
31 #include "src/v8.h"
32
33 #include "test/cctest/cctest.h"
34
35 using namespace v8::internal;
36
37 TEST(RingBufferPartialFill) {
38 const size_t max_size = 6;
39 typedef RingBuffer<size_t, max_size>::const_iterator Iter;
40 RingBuffer<size_t, max_size> ring_buffer;
41 CHECK(ring_buffer.empty());
42 CHECK_EQ(ring_buffer.size(), 0);
43 CHECK(ring_buffer.begin() == ring_buffer.end());
44
45 // Fill ring_buffer partially: [0, 1, 2]
46 for (size_t i = 0; i < max_size/2; i++)
47 ring_buffer.push_back(i);
48
49 CHECK(!ring_buffer.empty());
50 CHECK(ring_buffer.size() == max_size/2);
51 CHECK(ring_buffer.begin() != ring_buffer.end());
52
53 // Test forward itartion
54 size_t i = 0;
55 for (Iter iter = ring_buffer.begin(); iter != ring_buffer.end(); ++iter) {
56 CHECK(*iter == i);
57 ++i;
58 }
59 CHECK_EQ(i, 3); // one past last element.
60
61 // Test backward iteration
62 i = 2;
63 Iter iter = ring_buffer.back();
64 while (true) {
65 CHECK(*iter == i);
66 if (iter == ring_buffer.begin())
67 break;
68 --iter;
69 --i;
70 }
71 CHECK_EQ(i, 0);
72 }
73
74
75 TEST(RingBufferWrapAround) {
76 const size_t max_size = 6;
77 typedef RingBuffer<size_t, max_size>::const_iterator Iter;
78 RingBuffer<size_t, max_size> ring_buffer;
79
80 // Fill ring_buffer (wrap around): [9, 10, 11, 12, 13, 14]
81 for (size_t i = 0; i < 2 * max_size + 3; i++)
82 ring_buffer.push_back(i);
83
84 CHECK(!ring_buffer.empty());
85 CHECK(ring_buffer.size() == max_size);
86 CHECK(ring_buffer.begin() != ring_buffer.end());
87
88 // Test forward iteration
89 size_t i = 9;
90 for (Iter iter = ring_buffer.begin(); iter != ring_buffer.end(); ++iter) {
91 CHECK(*iter == i);
92 ++i;
93 }
94 CHECK_EQ(i, 15); // one past last element.
95
96 // Test backward iteration
97 i = 14;
98 Iter iter = ring_buffer.back();
99 while (true) {
100 CHECK(*iter == i);
101 if (iter == ring_buffer.begin())
102 break;
103 --iter;
104 --i;
105 }
106 CHECK_EQ(i, 9);
107 }
108
109
110 TEST(RingBufferPushFront) {
111 const size_t max_size = 6;
112 typedef RingBuffer<size_t, max_size>::const_iterator Iter;
113 RingBuffer<size_t, max_size> ring_buffer;
114
115 // Fill ring_buffer (wrap around): [14, 13, 12, 11, 10, 9]
116 for (size_t i = 0; i < 2 * max_size + 3; i++)
117 ring_buffer.push_front(i);
118
119 CHECK(!ring_buffer.empty());
120 CHECK(ring_buffer.size() == max_size);
121 CHECK(ring_buffer.begin() != ring_buffer.end());
122
123 // Test forward iteration
124 size_t i = 14;
125 for (Iter iter = ring_buffer.begin(); iter != ring_buffer.end(); ++iter) {
126 CHECK(*iter == i);
127 --i;
128 }
129 CHECK_EQ(i, 8); // one past last element.
130 }
OLDNEW
« no previous file with comments | « test/cctest/cctest.gyp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698