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

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

Issue 354143003: Unbreak Win64 build (hopefully). (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 6 years, 6 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 | « no previous file | 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
1 // Copyright 2014 the V8 project authors. All rights reserved. 1 // Copyright 2014 the V8 project authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include <string.h> 5 #include <string.h>
6 #include <limits> 6 #include <limits>
7 7
8 #include "include/v8stdint.h" 8 #include "include/v8stdint.h"
9 #include "src/ostreams.h" 9 #include "src/ostreams.h"
10 #include "test/cctest/cctest.h" 10 #include "test/cctest/cctest.h"
11 11
12 using namespace v8::internal; 12 using namespace v8::internal;
13 13
14 14
15 TEST(OStringStreamConstructor) { 15 TEST(OStringStreamConstructor) {
16 OStringStream oss; 16 OStringStream oss;
17 CHECK_EQ(0, oss.size()); 17 const size_t expected_size = 0;
18 CHECK(expected_size == oss.size());
18 CHECK_GT(oss.capacity(), 0); 19 CHECK_GT(oss.capacity(), 0);
19 CHECK_NE(NULL, oss.data()); 20 CHECK_NE(NULL, oss.data());
20 CHECK_EQ("", oss.c_str()); 21 CHECK_EQ("", oss.c_str());
21 } 22 }
22 23
23 24
24 #define TEST_STRING \ 25 #define TEST_STRING \
25 "Ash nazg durbatuluk, " \ 26 "Ash nazg durbatuluk, " \
26 "ash nazg gimbatul, " \ 27 "ash nazg gimbatul, " \
27 "ash nazg thrakatuluk, " \ 28 "ash nazg thrakatuluk, " \
28 "agh burzum-ishi krimpatul." 29 "agh burzum-ishi krimpatul."
29 30
30 TEST(OStringStreamGrow) { 31 TEST(OStringStreamGrow) {
31 OStringStream oss; 32 OStringStream oss;
32 const int repeat = 30; 33 const int repeat = 30;
33 size_t len = strlen(TEST_STRING); 34 size_t len = strlen(TEST_STRING);
34 for (int i = 0; i < repeat; ++i) { 35 for (int i = 0; i < repeat; ++i) {
35 oss.write(TEST_STRING, len); 36 oss.write(TEST_STRING, len);
36 } 37 }
37 const char* expected = 38 const char* expected =
38 TEST_STRING TEST_STRING TEST_STRING TEST_STRING TEST_STRING 39 TEST_STRING TEST_STRING TEST_STRING TEST_STRING TEST_STRING
39 TEST_STRING TEST_STRING TEST_STRING TEST_STRING TEST_STRING 40 TEST_STRING TEST_STRING TEST_STRING TEST_STRING TEST_STRING
40 TEST_STRING TEST_STRING TEST_STRING TEST_STRING TEST_STRING 41 TEST_STRING TEST_STRING TEST_STRING TEST_STRING TEST_STRING
41 TEST_STRING TEST_STRING TEST_STRING TEST_STRING TEST_STRING 42 TEST_STRING TEST_STRING TEST_STRING TEST_STRING TEST_STRING
42 TEST_STRING TEST_STRING TEST_STRING TEST_STRING TEST_STRING 43 TEST_STRING TEST_STRING TEST_STRING TEST_STRING TEST_STRING
43 TEST_STRING TEST_STRING TEST_STRING TEST_STRING TEST_STRING; 44 TEST_STRING TEST_STRING TEST_STRING TEST_STRING TEST_STRING;
44 const size_t expected_len = len * repeat; 45 const size_t expected_len = len * repeat;
45 CHECK_EQ(static_cast<int>(expected_len), oss.size()); 46 CHECK(expected_len == oss.size());
46 CHECK_GT(oss.capacity(), 0); 47 CHECK_GT(oss.capacity(), 0);
47 CHECK_EQ(0, strncmp(expected, oss.data(), expected_len)); 48 CHECK_EQ(0, strncmp(expected, oss.data(), expected_len));
48 CHECK_EQ(expected, oss.c_str()); 49 CHECK_EQ(expected, oss.c_str());
49 } 50 }
50 51
51 52
52 template <class T> 53 template <class T>
53 static void check(const char* expected, T value) { 54 static void check(const char* expected, T value) {
54 OStringStream oss; 55 OStringStream oss;
55 oss << value << " " << hex << value; 56 oss << value << " " << hex << value;
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after
138 return os << "{i:" << m.i_ << ", d:" << m.d_ << ", s:'" << m.s_ << "'}"; 139 return os << "{i:" << m.i_ << ", d:" << m.d_ << ", s:'" << m.s_ << "'}";
139 } 140 }
140 141
141 142
142 TEST(CustomOutput) { 143 TEST(CustomOutput) {
143 OStringStream os; 144 OStringStream os;
144 MiscStuff m(123, 4.5, "Hurz!"); 145 MiscStuff m(123, 4.5, "Hurz!");
145 os << m; 146 os << m;
146 CHECK_EQ("{i:123, d:4.5, s:'Hurz!'}", os.c_str()); 147 CHECK_EQ("{i:123, d:4.5, s:'Hurz!'}", os.c_str());
147 } 148 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698