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

Side by Side Diff: test/cctest/test-log-utils.cc

Issue 390004: Fix warnings on Win64. (Closed)
Patch Set: Created 11 years, 1 month 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
OLDNEW
1 // Copyright 2006-2009 the V8 project authors. All rights reserved. 1 // Copyright 2006-2009 the V8 project authors. All rights reserved.
2 // 2 //
3 // Tests of logging utilities from log-utils.h 3 // Tests of logging utilities from log-utils.h
4 4
5 #ifdef ENABLE_LOGGING_AND_PROFILING 5 #ifdef ENABLE_LOGGING_AND_PROFILING
6 6
7 #include "v8.h" 7 #include "v8.h"
8 8
9 #include "log-utils.h" 9 #include "log-utils.h"
10 #include "cctest.h" 10 #include "cctest.h"
11 11
12 using v8::internal::CStrVector; 12 using v8::internal::CStrVector;
13 using v8::internal::EmbeddedVector; 13 using v8::internal::EmbeddedVector;
14 using v8::internal::LogDynamicBuffer; 14 using v8::internal::LogDynamicBuffer;
15 using v8::internal::LogRecordCompressor; 15 using v8::internal::LogRecordCompressor;
16 using v8::internal::MutableCStrVector; 16 using v8::internal::MutableCStrVector;
17 using v8::internal::ScopedVector; 17 using v8::internal::ScopedVector;
18 using v8::internal::Vector; 18 using v8::internal::Vector;
19 using v8::internal::StrLength;
19 20
20 // Fills 'ref_buffer' with test data: a sequence of two-digit 21 // Fills 'ref_buffer' with test data: a sequence of two-digit
21 // hex numbers: '0001020304...'. Then writes 'ref_buffer' contents to 'dynabuf'. 22 // hex numbers: '0001020304...'. Then writes 'ref_buffer' contents to 'dynabuf'.
22 static void WriteData(LogDynamicBuffer* dynabuf, Vector<char>* ref_buffer) { 23 static void WriteData(LogDynamicBuffer* dynabuf, Vector<char>* ref_buffer) {
23 static const char kHex[] = "0123456789ABCDEF"; 24 static const char kHex[] = "0123456789ABCDEF";
24 CHECK_GT(ref_buffer->length(), 0); 25 CHECK_GT(ref_buffer->length(), 0);
25 CHECK_GT(513, ref_buffer->length()); 26 CHECK_GT(513, ref_buffer->length());
26 for (int i = 0, half_len = ref_buffer->length() >> 1; i < half_len; ++i) { 27 for (int i = 0, half_len = ref_buffer->length() >> 1; i < half_len; ++i) {
27 (*ref_buffer)[i << 1] = kHex[i >> 4]; 28 (*ref_buffer)[i << 1] = kHex[i >> 4];
28 (*ref_buffer)[(i << 1) + 1] = kHex[i & 15]; 29 (*ref_buffer)[(i << 1) + 1] = kHex[i & 15];
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after
111 CHECK_EQ(ref_buf, buf); 112 CHECK_EQ(ref_buf, buf);
112 // Try to read near the end with a buffer larger than remaining data size. 113 // Try to read near the end with a buffer larger than remaining data size.
113 EmbeddedVector<char, 48> tail_buf; 114 EmbeddedVector<char, 48> tail_buf;
114 CHECK_EQ(32, ReadData(&dynabuf, 128 - 32, &tail_buf)); 115 CHECK_EQ(32, ReadData(&dynabuf, 128 - 32, &tail_buf));
115 CHECK_EQ(ref_buf.SubVector(128 - 32, 128), tail_buf.SubVector(0, 32)); 116 CHECK_EQ(ref_buf.SubVector(128 - 32, 128), tail_buf.SubVector(0, 32));
116 } 117 }
117 118
118 119
119 TEST(DynaBufSealing) { 120 TEST(DynaBufSealing) {
120 const char* seal = "Sealed"; 121 const char* seal = "Sealed";
121 const int seal_size = strlen(seal); 122 const int seal_size = StrLength(seal);
122 LogDynamicBuffer dynabuf(32, 128, seal, seal_size); 123 LogDynamicBuffer dynabuf(32, 128, seal, seal_size);
123 EmbeddedVector<char, 100> ref_buf; 124 EmbeddedVector<char, 100> ref_buf;
124 WriteData(&dynabuf, &ref_buf); 125 WriteData(&dynabuf, &ref_buf);
125 // Try to write data that will not fit in the buffer. 126 // Try to write data that will not fit in the buffer.
126 CHECK_EQ(0, dynabuf.Write(ref_buf.start(), 128 - 100 - seal_size + 1)); 127 CHECK_EQ(0, dynabuf.Write(ref_buf.start(), 128 - 100 - seal_size + 1));
127 // Now the buffer is sealed, writing of any amount of data is forbidden. 128 // Now the buffer is sealed, writing of any amount of data is forbidden.
128 CHECK_EQ(0, dynabuf.Write(ref_buf.start(), 1)); 129 CHECK_EQ(0, dynabuf.Write(ref_buf.start(), 1));
129 EmbeddedVector<char, 100> buf; 130 EmbeddedVector<char, 100> buf;
130 CHECK_EQ(100, ReadData(&dynabuf, 0, &buf)); 131 CHECK_EQ(100, ReadData(&dynabuf, 0, &buf));
131 CHECK_EQ(ref_buf, buf); 132 CHECK_EQ(ref_buf, buf);
(...skipping 168 matching lines...) Expand 10 before | Expand all | Expand 10 after
300 CHECK(comp.Store(string_3)); 301 CHECK(comp.Store(string_3));
301 // string_2 compressed using string_1. 302 // string_2 compressed using string_1.
302 CheckCompression(&comp, "#1:8"); 303 CheckCompression(&comp, "#1:8");
303 const Vector<const char> string_4 = CStrVector("xxx"); 304 const Vector<const char> string_4 = CStrVector("xxx");
304 CHECK(comp.Store(string_4)); 305 CHECK(comp.Store(string_4));
305 // string_3 can't be compressed using string_2 --- too short. 306 // string_3 can't be compressed using string_2 --- too short.
306 CheckCompression(&comp, string_3); 307 CheckCompression(&comp, string_3);
307 } 308 }
308 309
309 #endif // ENABLE_LOGGING_AND_PROFILING 310 #endif // ENABLE_LOGGING_AND_PROFILING
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698