blob: 497d31317ce7a3e9044c1be94c98b25af153ee9f [file] [log] [blame]
Misha Brukman1757a812009-04-01 21:36:40 +00001//===- llvm/unittest/Support/raw_ostream_test.cpp - raw_ostream tests -----===//
Daniel Dunbaraf419912009-03-17 16:14:59 +00002//
Chandler Carruth2946cd72019-01-19 08:50:56 +00003// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4// See https://llvm.org/LICENSE.txt for license information.
5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
Daniel Dunbaraf419912009-03-17 16:14:59 +00006//
7//===----------------------------------------------------------------------===//
8
Daniel Dunbar47a309c2009-08-23 20:31:39 +00009#include "llvm/ADT/SmallString.h"
Rafael Espindolad31f04b2017-03-13 20:00:25 +000010#include "llvm/Support/FileSystem.h"
Daniel Dunbar47a309c2009-08-23 20:31:39 +000011#include "llvm/Support/Format.h"
Daniel Dunbaraf419912009-03-17 16:14:59 +000012#include "llvm/Support/raw_ostream.h"
Chandler Carruth9a67b072017-06-06 11:06:56 +000013#include "gtest/gtest.h"
Daniel Dunbaraf419912009-03-17 16:14:59 +000014
15using namespace llvm;
16
17namespace {
18
19template<typename T> std::string printToString(const T &Value) {
20 std::string res;
21 llvm::raw_string_ostream(res) << Value;
22 return res;
23}
24
Daniel Dunbar47a309c2009-08-23 20:31:39 +000025/// printToString - Print the given value to a stream which only has \arg
26/// BytesLeftInBuffer bytes left in the buffer. This is useful for testing edge
27/// cases in the buffer handling logic.
28template<typename T> std::string printToString(const T &Value,
29 unsigned BytesLeftInBuffer) {
30 // FIXME: This is relying on internal knowledge of how raw_ostream works to
31 // get the buffer position right.
32 SmallString<256> SVec;
33 assert(BytesLeftInBuffer < 256 && "Invalid buffer count!");
34 llvm::raw_svector_ostream OS(SVec);
35 unsigned StartIndex = 256 - BytesLeftInBuffer;
36 for (unsigned i = 0; i != StartIndex; ++i)
37 OS << '?';
38 OS << Value;
39 return OS.str().substr(StartIndex);
40}
41
Daniel Dunbaraf419912009-03-17 16:14:59 +000042template<typename T> std::string printToStringUnbuffered(const T &Value) {
43 std::string res;
44 llvm::raw_string_ostream OS(res);
45 OS.SetUnbuffered();
46 OS << Value;
47 return res;
48}
49
50TEST(raw_ostreamTest, Types_Buffered) {
51 // Char
52 EXPECT_EQ("c", printToString('c'));
53
54 // String
55 EXPECT_EQ("hello", printToString("hello"));
56 EXPECT_EQ("hello", printToString(std::string("hello")));
57
58 // Int
59 EXPECT_EQ("0", printToString(0));
60 EXPECT_EQ("2425", printToString(2425));
61 EXPECT_EQ("-2425", printToString(-2425));
62
63 // Long long
64 EXPECT_EQ("0", printToString(0LL));
65 EXPECT_EQ("257257257235709", printToString(257257257235709LL));
66 EXPECT_EQ("-257257257235709", printToString(-257257257235709LL));
67
68 // Double
69 EXPECT_EQ("1.100000e+00", printToString(1.1));
70
71 // void*
Craig Topper66f09ad2014-06-08 22:29:17 +000072 EXPECT_EQ("0x0", printToString((void*) nullptr));
Reid Kleckner19d532b2016-02-10 19:11:15 +000073 EXPECT_EQ("0xbeef", printToString((void*) 0xbeefLL));
74 EXPECT_EQ("0xdeadbeef", printToString((void*) 0xdeadbeefLL));
Daniel Dunbarfaea9712009-08-19 19:58:19 +000075
76 // Min and max.
77 EXPECT_EQ("18446744073709551615", printToString(UINT64_MAX));
78 EXPECT_EQ("-9223372036854775808", printToString(INT64_MIN));
Daniel Dunbaraf419912009-03-17 16:14:59 +000079}
80
81TEST(raw_ostreamTest, Types_Unbuffered) {
82 // Char
83 EXPECT_EQ("c", printToStringUnbuffered('c'));
84
85 // String
86 EXPECT_EQ("hello", printToStringUnbuffered("hello"));
87 EXPECT_EQ("hello", printToStringUnbuffered(std::string("hello")));
88
89 // Int
90 EXPECT_EQ("0", printToStringUnbuffered(0));
91 EXPECT_EQ("2425", printToStringUnbuffered(2425));
92 EXPECT_EQ("-2425", printToStringUnbuffered(-2425));
93
94 // Long long
95 EXPECT_EQ("0", printToStringUnbuffered(0LL));
96 EXPECT_EQ("257257257235709", printToStringUnbuffered(257257257235709LL));
97 EXPECT_EQ("-257257257235709", printToStringUnbuffered(-257257257235709LL));
98
99 // Double
100 EXPECT_EQ("1.100000e+00", printToStringUnbuffered(1.1));
101
102 // void*
Craig Topper66f09ad2014-06-08 22:29:17 +0000103 EXPECT_EQ("0x0", printToStringUnbuffered((void*) nullptr));
Reid Kleckner19d532b2016-02-10 19:11:15 +0000104 EXPECT_EQ("0xbeef", printToStringUnbuffered((void*) 0xbeefLL));
105 EXPECT_EQ("0xdeadbeef", printToStringUnbuffered((void*) 0xdeadbeefLL));
Daniel Dunbarfaea9712009-08-19 19:58:19 +0000106
107 // Min and max.
108 EXPECT_EQ("18446744073709551615", printToStringUnbuffered(UINT64_MAX));
109 EXPECT_EQ("-9223372036854775808", printToStringUnbuffered(INT64_MIN));
Daniel Dunbaraf419912009-03-17 16:14:59 +0000110}
111
Daniel Dunbar47a309c2009-08-23 20:31:39 +0000112TEST(raw_ostreamTest, BufferEdge) {
113 EXPECT_EQ("1.20", printToString(format("%.2f", 1.2), 1));
114 EXPECT_EQ("1.20", printToString(format("%.2f", 1.2), 2));
115 EXPECT_EQ("1.20", printToString(format("%.2f", 1.2), 3));
116 EXPECT_EQ("1.20", printToString(format("%.2f", 1.2), 4));
117 EXPECT_EQ("1.20", printToString(format("%.2f", 1.2), 10));
118}
119
Daniel Dunbar316b4a02009-09-15 20:31:46 +0000120TEST(raw_ostreamTest, TinyBuffer) {
121 std::string Str;
122 raw_string_ostream OS(Str);
123 OS.SetBufferSize(1);
124 OS << "hello";
125 OS << 1;
126 OS << 'w' << 'o' << 'r' << 'l' << 'd';
127 EXPECT_EQ("hello1world", OS.str());
128}
129
Daniel Dunbar4108c432009-10-17 20:43:08 +0000130TEST(raw_ostreamTest, WriteEscaped) {
131 std::string Str;
132
133 Str = "";
134 raw_string_ostream(Str).write_escaped("hi");
135 EXPECT_EQ("hi", Str);
136
137 Str = "";
138 raw_string_ostream(Str).write_escaped("\\\t\n\"");
139 EXPECT_EQ("\\\\\\t\\n\\\"", Str);
140
141 Str = "";
142 raw_string_ostream(Str).write_escaped("\1\10\200");
143 EXPECT_EQ("\\001\\010\\200", Str);
144}
145
Nick Kledzike6480372014-09-25 20:30:58 +0000146TEST(raw_ostreamTest, Justify) {
147 EXPECT_EQ("xyz ", printToString(left_justify("xyz", 6), 6));
148 EXPECT_EQ("abc", printToString(left_justify("abc", 3), 3));
149 EXPECT_EQ("big", printToString(left_justify("big", 1), 3));
150 EXPECT_EQ(" xyz", printToString(right_justify("xyz", 6), 6));
151 EXPECT_EQ("abc", printToString(right_justify("abc", 3), 3));
152 EXPECT_EQ("big", printToString(right_justify("big", 1), 3));
Frederich Munch5e9d6d02017-07-13 16:11:08 +0000153 EXPECT_EQ(" on ", printToString(center_justify("on", 9), 9));
154 EXPECT_EQ(" off ", printToString(center_justify("off", 10), 10));
155 EXPECT_EQ("single ", printToString(center_justify("single", 7), 7));
156 EXPECT_EQ("none", printToString(center_justify("none", 1), 4));
157 EXPECT_EQ("none", printToString(center_justify("none", 1), 1));
Nick Kledzike6480372014-09-25 20:30:58 +0000158}
159
160TEST(raw_ostreamTest, FormatHex) {
161 EXPECT_EQ("0x1234", printToString(format_hex(0x1234, 6), 6));
162 EXPECT_EQ("0x001234", printToString(format_hex(0x1234, 8), 8));
163 EXPECT_EQ("0x00001234", printToString(format_hex(0x1234, 10), 10));
164 EXPECT_EQ("0x1234", printToString(format_hex(0x1234, 4), 6));
165 EXPECT_EQ("0xff", printToString(format_hex(255, 4), 4));
166 EXPECT_EQ("0xFF", printToString(format_hex(255, 4, true), 4));
167 EXPECT_EQ("0x1", printToString(format_hex(1, 3), 3));
168 EXPECT_EQ("0x12", printToString(format_hex(0x12, 3), 4));
169 EXPECT_EQ("0x123", printToString(format_hex(0x123, 3), 5));
Zachary Turner39571b32015-01-26 18:21:33 +0000170 EXPECT_EQ("FF", printToString(format_hex_no_prefix(0xFF, 2, true), 4));
171 EXPECT_EQ("ABCD", printToString(format_hex_no_prefix(0xABCD, 2, true), 4));
Nick Kledzike6480372014-09-25 20:30:58 +0000172 EXPECT_EQ("0xffffffffffffffff",
173 printToString(format_hex(UINT64_MAX, 18), 18));
174 EXPECT_EQ("0x8000000000000000",
175 printToString(format_hex((INT64_MIN), 18), 18));
176}
177
178TEST(raw_ostreamTest, FormatDecimal) {
179 EXPECT_EQ(" 0", printToString(format_decimal(0, 4), 4));
180 EXPECT_EQ(" -1", printToString(format_decimal(-1, 4), 4));
181 EXPECT_EQ(" -1", printToString(format_decimal(-1, 6), 6));
182 EXPECT_EQ("1234567890", printToString(format_decimal(1234567890, 10), 10));
183 EXPECT_EQ(" 9223372036854775807",
184 printToString(format_decimal(INT64_MAX, 21), 21));
185 EXPECT_EQ(" -9223372036854775808",
186 printToString(format_decimal(INT64_MIN, 21), 21));
187}
188
Zachary Turner4a86af02016-11-10 20:16:45 +0000189static std::string formatted_bytes_str(ArrayRef<uint8_t> Bytes,
190 llvm::Optional<uint64_t> Offset = None,
191 uint32_t NumPerLine = 16,
192 uint8_t ByteGroupSize = 4) {
Greg Claytonbde0a162016-11-09 00:15:54 +0000193 std::string S;
Zachary Turner4a86af02016-11-10 20:16:45 +0000194 raw_string_ostream Str(S);
195 Str << format_bytes(Bytes, Offset, NumPerLine, ByteGroupSize);
196 Str.flush();
Greg Claytonbde0a162016-11-09 00:15:54 +0000197 return S;
198}
Nick Kledzike6480372014-09-25 20:30:58 +0000199
Zachary Turner4a86af02016-11-10 20:16:45 +0000200static std::string format_bytes_with_ascii_str(ArrayRef<uint8_t> Bytes,
201 Optional<uint64_t> Offset = None,
202 uint32_t NumPerLine = 16,
203 uint8_t ByteGroupSize = 4) {
Greg Claytonbde0a162016-11-09 00:15:54 +0000204 std::string S;
Zachary Turner4a86af02016-11-10 20:16:45 +0000205 raw_string_ostream Str(S);
206 Str << format_bytes_with_ascii(Bytes, Offset, NumPerLine, ByteGroupSize);
207 Str.flush();
Greg Claytonbde0a162016-11-09 00:15:54 +0000208 return S;
209}
210
211TEST(raw_ostreamTest, FormattedHexBytes) {
Zachary Turner4a86af02016-11-10 20:16:45 +0000212 std::vector<uint8_t> Buf = {'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i',
213 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r',
214 's', 't', 'u', 'v', 'w', 'x', 'y', 'z', '0',
215 '1', '2', '3', '4', '5', '6', '7', '8', '9'};
216 ArrayRef<uint8_t> B(Buf);
217
Greg Claytonbde0a162016-11-09 00:15:54 +0000218 // Test invalid input.
Zachary Turner4a86af02016-11-10 20:16:45 +0000219 EXPECT_EQ("", formatted_bytes_str(ArrayRef<uint8_t>()));
220 EXPECT_EQ("", format_bytes_with_ascii_str(ArrayRef<uint8_t>()));
Greg Claytonbde0a162016-11-09 00:15:54 +0000221 //----------------------------------------------------------------------
222 // Test hex byte output with the default 4 byte groups
223 //----------------------------------------------------------------------
Zachary Turner4a86af02016-11-10 20:16:45 +0000224 EXPECT_EQ("61", formatted_bytes_str(B.take_front()));
225 EXPECT_EQ("61626364 65", formatted_bytes_str(B.take_front(5)));
Greg Claytonbde0a162016-11-09 00:15:54 +0000226 // Test that 16 bytes get written to a line correctly.
Zachary Turner4a86af02016-11-10 20:16:45 +0000227 EXPECT_EQ("61626364 65666768 696a6b6c 6d6e6f70",
228 formatted_bytes_str(B.take_front(16)));
Greg Claytonbde0a162016-11-09 00:15:54 +0000229 // Test raw bytes with default 16 bytes per line wrapping.
Zachary Turner4a86af02016-11-10 20:16:45 +0000230 EXPECT_EQ("61626364 65666768 696a6b6c 6d6e6f70\n71",
231 formatted_bytes_str(B.take_front(17)));
Greg Claytonbde0a162016-11-09 00:15:54 +0000232 // Test raw bytes with 1 bytes per line wrapping.
Zachary Turner4a86af02016-11-10 20:16:45 +0000233 EXPECT_EQ("61\n62\n63\n64\n65\n66",
234 formatted_bytes_str(B.take_front(6), None, 1));
Greg Claytonbde0a162016-11-09 00:15:54 +0000235 // Test raw bytes with 7 bytes per line wrapping.
236 EXPECT_EQ("61626364 656667\n68696a6b 6c6d6e\n6f7071",
Zachary Turner4a86af02016-11-10 20:16:45 +0000237 formatted_bytes_str(B.take_front(17), None, 7));
Greg Claytonbde0a162016-11-09 00:15:54 +0000238 // Test raw bytes with 8 bytes per line wrapping.
239 EXPECT_EQ("61626364 65666768\n696a6b6c 6d6e6f70\n71",
Zachary Turner4a86af02016-11-10 20:16:45 +0000240 formatted_bytes_str(B.take_front(17), None, 8));
Greg Claytonbde0a162016-11-09 00:15:54 +0000241 //----------------------------------------------------------------------
242 // Test hex byte output with the 1 byte groups
243 //----------------------------------------------------------------------
Zachary Turner4a86af02016-11-10 20:16:45 +0000244 EXPECT_EQ("61 62 63 64 65",
245 formatted_bytes_str(B.take_front(5), None, 16, 1));
Greg Claytonbde0a162016-11-09 00:15:54 +0000246 // Test that 16 bytes get written to a line correctly.
247 EXPECT_EQ("61 62 63 64 65 66 67 68 69 6a 6b 6c 6d 6e 6f 70",
Zachary Turner4a86af02016-11-10 20:16:45 +0000248 formatted_bytes_str(B.take_front(16), None, 16, 1));
Greg Claytonbde0a162016-11-09 00:15:54 +0000249 // Test raw bytes with default 16 bytes per line wrapping.
250 EXPECT_EQ("61 62 63 64 65 66 67 68 69 6a 6b 6c 6d 6e 6f 70\n71",
Zachary Turner4a86af02016-11-10 20:16:45 +0000251 formatted_bytes_str(B.take_front(17), None, 16, 1));
Greg Claytonbde0a162016-11-09 00:15:54 +0000252 // Test raw bytes with 7 bytes per line wrapping.
253 EXPECT_EQ("61 62 63 64 65 66 67\n68 69 6a 6b 6c 6d 6e\n6f 70 71",
Zachary Turner4a86af02016-11-10 20:16:45 +0000254 formatted_bytes_str(B.take_front(17), None, 7, 1));
Greg Claytonbde0a162016-11-09 00:15:54 +0000255 // Test raw bytes with 8 bytes per line wrapping.
256 EXPECT_EQ("61 62 63 64 65 66 67 68\n69 6a 6b 6c 6d 6e 6f 70\n71",
Zachary Turner4a86af02016-11-10 20:16:45 +0000257 formatted_bytes_str(B.take_front(17), None, 8, 1));
Greg Claytonbde0a162016-11-09 00:15:54 +0000258
259 //----------------------------------------------------------------------
260 // Test hex byte output with the 2 byte groups
261 //----------------------------------------------------------------------
Zachary Turner4a86af02016-11-10 20:16:45 +0000262 EXPECT_EQ("6162 6364 65", formatted_bytes_str(B.take_front(5), None, 16, 2));
Greg Claytonbde0a162016-11-09 00:15:54 +0000263 // Test that 16 bytes get written to a line correctly.
264 EXPECT_EQ("6162 6364 6566 6768 696a 6b6c 6d6e 6f70",
Zachary Turner4a86af02016-11-10 20:16:45 +0000265 formatted_bytes_str(B.take_front(16), None, 16, 2));
Greg Claytonbde0a162016-11-09 00:15:54 +0000266 // Test raw bytes with default 16 bytes per line wrapping.
267 EXPECT_EQ("6162 6364 6566 6768 696a 6b6c 6d6e 6f70\n71",
Zachary Turner4a86af02016-11-10 20:16:45 +0000268 formatted_bytes_str(B.take_front(17), None, 16, 2));
Greg Claytonbde0a162016-11-09 00:15:54 +0000269 // Test raw bytes with 7 bytes per line wrapping.
270 EXPECT_EQ("6162 6364 6566 67\n6869 6a6b 6c6d 6e\n6f70 71",
Zachary Turner4a86af02016-11-10 20:16:45 +0000271 formatted_bytes_str(B.take_front(17), None, 7, 2));
Greg Claytonbde0a162016-11-09 00:15:54 +0000272 // Test raw bytes with 8 bytes per line wrapping.
273 EXPECT_EQ("6162 6364 6566 6768\n696a 6b6c 6d6e 6f70\n71",
Zachary Turner4a86af02016-11-10 20:16:45 +0000274 formatted_bytes_str(B.take_front(17), None, 8, 2));
Greg Claytonbde0a162016-11-09 00:15:54 +0000275
276 //----------------------------------------------------------------------
277 // Test hex bytes with offset with the default 4 byte groups.
278 //----------------------------------------------------------------------
Zachary Turner4a86af02016-11-10 20:16:45 +0000279 EXPECT_EQ("0000: 61", formatted_bytes_str(B.take_front(), 0x0));
280 EXPECT_EQ("1000: 61", formatted_bytes_str(B.take_front(), 0x1000));
281 EXPECT_EQ("1000: 61\n1001: 62",
282 formatted_bytes_str(B.take_front(2), 0x1000, 1));
Greg Claytonbde0a162016-11-09 00:15:54 +0000283 //----------------------------------------------------------------------
284 // Test hex bytes with ASCII with the default 4 byte groups.
285 //----------------------------------------------------------------------
286 EXPECT_EQ("61626364 65666768 696a6b6c 6d6e6f70 |abcdefghijklmnop|",
Zachary Turner4a86af02016-11-10 20:16:45 +0000287 format_bytes_with_ascii_str(B.take_front(16)));
Greg Claytonbde0a162016-11-09 00:15:54 +0000288 EXPECT_EQ("61626364 65666768 |abcdefgh|\n"
289 "696a6b6c 6d6e6f70 |ijklmnop|",
Zachary Turner4a86af02016-11-10 20:16:45 +0000290 format_bytes_with_ascii_str(B.take_front(16), None, 8));
Greg Claytonbde0a162016-11-09 00:15:54 +0000291 EXPECT_EQ("61626364 65666768 |abcdefgh|\n696a6b6c |ijkl|",
Zachary Turner4a86af02016-11-10 20:16:45 +0000292 format_bytes_with_ascii_str(B.take_front(12), None, 8));
293 std::vector<uint8_t> Unprintable = {'a', '\x1e', 'b', '\x1f'};
Greg Claytonbde0a162016-11-09 00:15:54 +0000294 // Make sure the ASCII is still lined up correctly when fewer bytes than 16
295 // bytes per line are available. The ASCII should still be aligned as if 16
296 // bytes of hex might be displayed.
297 EXPECT_EQ("611e621f |a.b.|",
Zachary Turner4a86af02016-11-10 20:16:45 +0000298 format_bytes_with_ascii_str(Unprintable));
Greg Claytonbde0a162016-11-09 00:15:54 +0000299 //----------------------------------------------------------------------
300 // Test hex bytes with ASCII with offsets with the default 4 byte groups.
301 //----------------------------------------------------------------------
Zachary Turner4a86af02016-11-10 20:16:45 +0000302 EXPECT_EQ("0000: 61626364 65666768 "
Greg Claytonbde0a162016-11-09 00:15:54 +0000303 "696a6b6c 6d6e6f70 |abcdefghijklmnop|",
Zachary Turner4a86af02016-11-10 20:16:45 +0000304 format_bytes_with_ascii_str(B.take_front(16), 0));
305 EXPECT_EQ("0000: 61626364 65666768 |abcdefgh|\n"
306 "0008: 696a6b6c 6d6e6f70 |ijklmnop|",
307 format_bytes_with_ascii_str(B.take_front(16), 0, 8));
308 EXPECT_EQ("0000: 61626364 656667 |abcdefg|\n"
309 "0007: 68696a6b 6c |hijkl|",
310 format_bytes_with_ascii_str(B.take_front(12), 0, 7));
Greg Claytonbde0a162016-11-09 00:15:54 +0000311
312 //----------------------------------------------------------------------
313 // Test hex bytes with ASCII with offsets with the default 2 byte groups.
314 //----------------------------------------------------------------------
Zachary Turner4a86af02016-11-10 20:16:45 +0000315 EXPECT_EQ("0000: 6162 6364 6566 6768 "
Greg Claytonbde0a162016-11-09 00:15:54 +0000316 "696a 6b6c 6d6e 6f70 |abcdefghijklmnop|",
Zachary Turner4a86af02016-11-10 20:16:45 +0000317 format_bytes_with_ascii_str(B.take_front(16), 0, 16, 2));
318 EXPECT_EQ("0000: 6162 6364 6566 6768 |abcdefgh|\n"
319 "0008: 696a 6b6c 6d6e 6f70 |ijklmnop|",
320 format_bytes_with_ascii_str(B.take_front(16), 0, 8, 2));
321 EXPECT_EQ("0000: 6162 6364 6566 67 |abcdefg|\n"
322 "0007: 6869 6a6b 6c |hijkl|",
323 format_bytes_with_ascii_str(B.take_front(12), 0, 7, 2));
Greg Claytonbde0a162016-11-09 00:15:54 +0000324
325 //----------------------------------------------------------------------
326 // Test hex bytes with ASCII with offsets with the default 1 byte groups.
327 //----------------------------------------------------------------------
Zachary Turner4a86af02016-11-10 20:16:45 +0000328 EXPECT_EQ("0000: 61 62 63 64 65 66 67 68 "
Greg Claytonbde0a162016-11-09 00:15:54 +0000329 "69 6a 6b 6c 6d 6e 6f 70 |abcdefghijklmnop|",
Zachary Turner4a86af02016-11-10 20:16:45 +0000330 format_bytes_with_ascii_str(B.take_front(16), 0, 16, 1));
331 EXPECT_EQ("0000: 61 62 63 64 65 66 67 68 |abcdefgh|\n"
332 "0008: 69 6a 6b 6c 6d 6e 6f 70 |ijklmnop|",
333 format_bytes_with_ascii_str(B.take_front(16), 0, 8, 1));
334 EXPECT_EQ("0000: 61 62 63 64 65 66 67 |abcdefg|\n"
335 "0007: 68 69 6a 6b 6c |hijkl|",
336 format_bytes_with_ascii_str(B.take_front(12), 0, 7, 1));
Greg Claytonbde0a162016-11-09 00:15:54 +0000337}
Rafael Espindolad31f04b2017-03-13 20:00:25 +0000338
339TEST(raw_fd_ostreamTest, multiple_raw_fd_ostream_to_stdout) {
340 std::error_code EC;
341
Fangrui Songd9b948b2019-08-05 05:43:48 +0000342 { raw_fd_ostream("-", EC, sys::fs::OpenFlags::OF_None); }
343 { raw_fd_ostream("-", EC, sys::fs::OpenFlags::OF_None); }
Rafael Espindolad31f04b2017-03-13 20:00:25 +0000344}
Daniel Dunbaraf419912009-03-17 16:14:59 +0000345}