OLD | NEW |
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" |
(...skipping 85 matching lines...) Loading... |
96 check<float>("0.0625 0.0625", 6.25e-2f); | 96 check<float>("0.0625 0.0625", 6.25e-2f); |
97 | 97 |
98 check<double>("0 0", 0.0); | 98 check<double>("0 0", 0.0); |
99 check<double>("123 123", 123.0); | 99 check<double>("123 123", 123.0); |
100 check<double>("-0.5 -0.5", -0.5); | 100 check<double>("-0.5 -0.5", -0.5); |
101 check<double>("1.25 1.25", 1.25); | 101 check<double>("1.25 1.25", 1.25); |
102 check<double>("0.0625 0.0625", 6.25e-2); | 102 check<double>("0.0625 0.0625", 6.25e-2); |
103 } | 103 } |
104 | 104 |
105 | 105 |
| 106 #if defined(__GNUC__) && (__GNUC__ == 4) && (__GNUC_MINOR__ <= 4) |
| 107 // Work around bad optimization by GCC 4.4.6 on PPC Linux |
| 108 #pragma GCC optimize "O0" |
| 109 #endif |
106 TEST(CharacterOutput) { | 110 TEST(CharacterOutput) { |
107 check<char>("a a", 'a'); | 111 check<char>("a a", 'a'); |
108 check<signed char>("B B", 'B'); | 112 check<signed char>("B B", 'B'); |
109 check<unsigned char>("9 9", '9'); | 113 check<unsigned char>("9 9", '9'); |
110 check<const char*>("bye bye", "bye"); | 114 check<const char*>("bye bye", "bye"); |
111 | 115 |
112 OStringStream os; | 116 OStringStream os; |
113 os.put('H').write("ello", 4); | 117 os.put('H').write("ello", 4); |
114 CHECK_EQ("Hello", os.c_str()); | 118 CHECK_EQ("Hello", os.c_str()); |
115 } | 119 } |
| 120 #if defined(__GNUC__) && (__GNUC__ == 4) && (__GNUC_MINOR__ <= 4) |
| 121 #pragma GCC reset_options |
| 122 #endif |
116 | 123 |
117 | 124 |
118 TEST(Manipulators) { | 125 TEST(Manipulators) { |
119 OStringStream os; | 126 OStringStream os; |
120 os << 123 << hex << 123 << endl << 123 << dec << 123 << 123; | 127 os << 123 << hex << 123 << endl << 123 << dec << 123 << 123; |
121 CHECK_EQ("1237b\n7b123123", os.c_str()); | 128 CHECK_EQ("1237b\n7b123123", os.c_str()); |
122 } | 129 } |
123 | 130 |
124 | 131 |
125 class MiscStuff { | 132 class MiscStuff { |
(...skipping 13 matching lines...) Loading... |
139 return os << "{i:" << m.i_ << ", d:" << m.d_ << ", s:'" << m.s_ << "'}"; | 146 return os << "{i:" << m.i_ << ", d:" << m.d_ << ", s:'" << m.s_ << "'}"; |
140 } | 147 } |
141 | 148 |
142 | 149 |
143 TEST(CustomOutput) { | 150 TEST(CustomOutput) { |
144 OStringStream os; | 151 OStringStream os; |
145 MiscStuff m(123, 4.5, "Hurz!"); | 152 MiscStuff m(123, 4.5, "Hurz!"); |
146 os << m; | 153 os << m; |
147 CHECK_EQ("{i:123, d:4.5, s:'Hurz!'}", os.c_str()); | 154 CHECK_EQ("{i:123, d:4.5, s:'Hurz!'}", os.c_str()); |
148 } | 155 } |
OLD | NEW |