1 //===- llvm/unittest/Support/ScopedPrinterTest.cpp - ScopedPrinter tests --===//
3 // 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
7 //===----------------------------------------------------------------------===//
9 #include "llvm/Support/ScopedPrinter.h"
10 #include "llvm/ADT/APSInt.h"
11 #include "gtest/gtest.h"
16 TEST(JSONScopedPrinterTest
, PrettyPrintCtor
) {
17 auto PrintFunc
= [](ScopedPrinter
&W
) {
19 W
.printString("Key", "Value");
21 std::string StreamBuffer
;
22 raw_string_ostream
OS(StreamBuffer
);
23 JSONScopedPrinter
PrettyPrintWriter(OS
, /*PrettyPrint=*/true);
24 JSONScopedPrinter
NoPrettyPrintWriter(OS
, /*PrettyPrint=*/false);
26 const char *PrettyPrintOut
= R
"({
29 const char *NoPrettyPrintOut
= R
"({"Key
":"Value
"})";
30 PrintFunc(PrettyPrintWriter
);
31 EXPECT_EQ(PrettyPrintOut
, OS
.str());
33 PrintFunc(NoPrettyPrintWriter
);
34 EXPECT_EQ(NoPrettyPrintOut
, OS
.str());
37 TEST(JSONScopedPrinterTest
, DelimitedScopeCtor
) {
38 std::string StreamBuffer
;
39 raw_string_ostream
OS(StreamBuffer
);
41 JSONScopedPrinter
DictScopeWriter(OS
, /*PrettyPrint=*/false,
42 std::make_unique
<DictScope
>());
43 DictScopeWriter
.printString("Label", "DictScope");
45 EXPECT_EQ(R
"({"Label
":"DictScope
"})", OS
.str());
48 JSONScopedPrinter
ListScopeWriter(OS
, /*PrettyPrint=*/false,
49 std::make_unique
<ListScope
>());
50 ListScopeWriter
.printString("ListScope");
52 EXPECT_EQ(R
"(["ListScope
"])", OS
.str());
55 JSONScopedPrinter
NoScopeWriter(OS
, /*PrettyPrint=*/false);
56 NoScopeWriter
.printString("NoScope");
58 EXPECT_EQ(R
"("NoScope
")", OS
.str());
61 class ScopedPrinterTest
: public ::testing::Test
{
63 std::string StreamBuffer
;
64 raw_string_ostream OS
;
66 JSONScopedPrinter JSONWriter
;
68 bool HasPrintedToJSON
;
71 : OS(StreamBuffer
), Writer(OS
), JSONWriter(OS
, /*PrettyPrint=*/true),
72 HasPrintedToJSON(false) {}
74 using PrintFunc
= function_ref
<void(ScopedPrinter
&)>;
76 void verifyScopedPrinter(StringRef Expected
, PrintFunc Func
) {
79 EXPECT_EQ(Expected
.str(), OS
.str());
83 void verifyJSONScopedPrinter(StringRef Expected
, PrintFunc Func
) {
85 DictScope
D(JSONWriter
);
89 EXPECT_EQ(Expected
.str(), OS
.str());
91 HasPrintedToJSON
= true;
94 void verifyAll(StringRef ExpectedOut
, StringRef JSONExpectedOut
,
96 verifyScopedPrinter(ExpectedOut
, Func
);
97 verifyJSONScopedPrinter(JSONExpectedOut
, Func
);
101 // JSONScopedPrinter fails an assert if nothing's been printed.
102 if (!HasPrintedToJSON
)
103 JSONWriter
.printString("");
107 TEST_F(ScopedPrinterTest
, GetKind
) {
108 EXPECT_EQ(ScopedPrinter::ScopedPrinterKind::Base
, Writer
.getKind());
109 EXPECT_EQ(ScopedPrinter::ScopedPrinterKind::JSON
, JSONWriter
.getKind());
112 TEST_F(ScopedPrinterTest
, ClassOf
) {
113 EXPECT_TRUE(ScopedPrinter::classof(&Writer
));
114 EXPECT_TRUE(JSONScopedPrinter::classof(&JSONWriter
));
115 EXPECT_FALSE(ScopedPrinter::classof(&JSONWriter
));
116 EXPECT_FALSE(JSONScopedPrinter::classof(&Writer
));
119 TEST_F(ScopedPrinterTest
, Indent
) {
120 auto PrintFunc
= [](ScopedPrinter
&W
) {
128 const char *ExpectedOut
= R
"(|
132 verifyScopedPrinter(ExpectedOut
, PrintFunc
);
135 TEST_F(ScopedPrinterTest
, Unindent
) {
136 auto PrintFunc
= [](ScopedPrinter
&W
) {
147 const char *ExpectedOut
= R
"( |
152 verifyScopedPrinter(ExpectedOut
, PrintFunc
);
155 TEST_F(ScopedPrinterTest
, ResetIndent
) {
156 auto PrintFunc
= [](ScopedPrinter
&W
) {
163 const char *ExpectedOut
= R
"( |
166 verifyScopedPrinter(ExpectedOut
, PrintFunc
);
169 TEST_F(ScopedPrinterTest
, PrintIndent
) {
170 auto PrintFunc
= [](ScopedPrinter
&W
) {
178 const char *ExpectedOut
= R
"(|
181 verifyScopedPrinter(ExpectedOut
, PrintFunc
);
184 TEST_F(ScopedPrinterTest
, GetIndentLevel
) {
185 EXPECT_EQ(Writer
.getIndentLevel(), 0);
187 EXPECT_EQ(Writer
.getIndentLevel(), 1);
189 EXPECT_EQ(Writer
.getIndentLevel(), 2);
191 EXPECT_EQ(Writer
.getIndentLevel(), 1);
193 Writer
.resetIndent();
194 EXPECT_EQ(Writer
.getIndentLevel(), 0);
196 EXPECT_EQ(Writer
.getIndentLevel(), 0);
198 EXPECT_EQ(Writer
.getIndentLevel(), 1);
201 TEST_F(ScopedPrinterTest
, SetPrefix
) {
202 auto PrintFunc
= [](ScopedPrinter
&W
) {
203 W
.setPrefix("Prefix1");
210 W
.setPrefix("Prefix2");
215 const char *ExpectedOut
= R
"(Prefix1 Prefix1 |
219 verifyScopedPrinter(ExpectedOut
, PrintFunc
);
222 TEST_F(ScopedPrinterTest
, PrintEnum
) {
223 auto PrintFunc
= [](ScopedPrinter
&W
) {
224 const EnumEntry
<int> EnumList
[] = {{"Name1", "AltName1", 1},
225 {"Name2", "AltName2", 2},
226 {"Name3", "AltName3", 3},
227 {"Name4", "AltName4", 2}};
228 EnumEntry
<int> OtherEnum
{"Name5", "AltName5", 5};
229 W
.printEnum("Exists", EnumList
[1].Value
, makeArrayRef(EnumList
));
230 W
.printEnum("DoesNotExist", OtherEnum
.Value
, makeArrayRef(EnumList
));
233 const char *ExpectedOut
= R
"(Exists: Name2 (0x2)
237 const char *JSONExpectedOut
= R
"({
244 verifyAll(ExpectedOut
, JSONExpectedOut
, PrintFunc
);
247 TEST_F(ScopedPrinterTest
, PrintFlag
) {
248 auto PrintFunc
= [](ScopedPrinter
&W
) {
249 const EnumEntry
<uint16_t> SingleBitFlags
[] = {
250 {"Name0", "AltName0", 0},
251 {"Name1", "AltName1", 1},
252 {"Name2", "AltName2", 1 << 1},
253 {"Name3", "AltName3", 1 << 2}};
254 const EnumEntry
<uint16_t> UnsortedFlags
[] = {
255 {"C", "c", 1}, {"B", "b", 1 << 1}, {"A", "a", 1 << 2}};
256 const EnumEntry
<uint16_t> EnumFlags
[] = {
257 {"FirstByte1", "First1", 0x1u
}, {"FirstByte2", "First2", 0x2u
},
258 {"FirstByte3", "First3", 0x3u
}, {"SecondByte1", "Second1", 0x10u
},
259 {"SecondByte2", "Second2", 0x20u
}, {"SecondByte3", "Second3", 0x30u
},
260 {"ThirdByte1", "Third1", 0x100u
}, {"ThirdByte2", "Third2", 0x200u
},
261 {"ThirdByte3", "Third3", 0x300u
}};
262 W
.printFlags("ZeroFlag", 0, makeArrayRef(SingleBitFlags
));
263 W
.printFlags("NoFlag", 1 << 3, makeArrayRef(SingleBitFlags
));
264 W
.printFlags("Flag1", SingleBitFlags
[1].Value
,
265 makeArrayRef(SingleBitFlags
));
266 W
.printFlags("Flag1&3", (1 << 2) + 1, makeArrayRef(SingleBitFlags
));
268 W
.printFlags("ZeroFlagRaw", 0);
269 W
.printFlags("NoFlagRaw", 1 << 3);
270 W
.printFlags("Flag1Raw", SingleBitFlags
[1].Value
);
271 W
.printFlags("Flag1&3Raw", (1 << 2) + 1);
273 W
.printFlags("FlagSorted", (1 << 2) + (1 << 1) + 1,
274 makeArrayRef(UnsortedFlags
));
276 uint16_t NoBitMask
= 0;
277 uint16_t FirstByteMask
= 0xFu
;
278 uint16_t SecondByteMask
= 0xF0u
;
279 uint16_t ThirdByteMask
= 0xF00u
;
280 W
.printFlags("NoBitMask", 0xFFFu
, makeArrayRef(EnumFlags
), NoBitMask
);
281 W
.printFlags("FirstByteMask", 0x3u
, makeArrayRef(EnumFlags
), FirstByteMask
);
282 W
.printFlags("SecondByteMask", 0x30u
, makeArrayRef(EnumFlags
),
284 W
.printFlags("ValueOutsideMask", 0x1u
, makeArrayRef(EnumFlags
),
286 W
.printFlags("FirstSecondByteMask", 0xFFu
, makeArrayRef(EnumFlags
),
287 FirstByteMask
, SecondByteMask
);
288 W
.printFlags("FirstSecondThirdByteMask", 0x333u
, makeArrayRef(EnumFlags
),
289 FirstByteMask
, SecondByteMask
, ThirdByteMask
);
292 const char *ExpectedOut
= R
"(ZeroFlag [ (0x0)
331 FirstByteMask [ (0x3)
334 SecondByteMask [ (0x30)
337 ValueOutsideMask [ (0x1)
340 FirstSecondByteMask [ (0xFF)
342 FirstSecondThirdByteMask [ (0x333)
349 const char *JSONExpectedOut
= R
"({
424 "Name
": "FirstByte1
",
428 "Name
": "FirstByte2
",
432 "Name
": "FirstByte3
",
436 "Name
": "SecondByte1
",
440 "Name
": "SecondByte2
",
444 "Name
": "SecondByte3
",
448 "Name
": "ThirdByte1
",
452 "Name
": "ThirdByte2
",
456 "Name
": "ThirdByte3
",
465 "Name
": "FirstByte3
",
474 "Name
": "SecondByte3
",
479 "ValueOutsideMask
": {
483 "Name
": "FirstByte1
",
488 "FirstSecondByteMask
": {
492 "FirstSecondThirdByteMask
": {
496 "Name
": "FirstByte3
",
500 "Name
": "SecondByte3
",
504 "Name
": "ThirdByte3
",
510 verifyAll(ExpectedOut
, JSONExpectedOut
, PrintFunc
);
513 TEST_F(ScopedPrinterTest
, PrintNumber
) {
514 auto PrintFunc
= [](ScopedPrinter
&W
) {
515 uint64_t Unsigned64Max
= std::numeric_limits
<uint64_t>::max();
516 uint64_t Unsigned64Min
= std::numeric_limits
<uint64_t>::min();
517 W
.printNumber("uint64_t-max", Unsigned64Max
);
518 W
.printNumber("uint64_t-min", Unsigned64Min
);
520 uint32_t Unsigned32Max
= std::numeric_limits
<uint32_t>::max();
521 uint32_t Unsigned32Min
= std::numeric_limits
<uint32_t>::min();
522 W
.printNumber("uint32_t-max", Unsigned32Max
);
523 W
.printNumber("uint32_t-min", Unsigned32Min
);
525 uint16_t Unsigned16Max
= std::numeric_limits
<uint16_t>::max();
526 uint16_t Unsigned16Min
= std::numeric_limits
<uint16_t>::min();
527 W
.printNumber("uint16_t-max", Unsigned16Max
);
528 W
.printNumber("uint16_t-min", Unsigned16Min
);
530 uint8_t Unsigned8Max
= std::numeric_limits
<uint8_t>::max();
531 uint8_t Unsigned8Min
= std::numeric_limits
<uint8_t>::min();
532 W
.printNumber("uint8_t-max", Unsigned8Max
);
533 W
.printNumber("uint8_t-min", Unsigned8Min
);
535 int64_t Signed64Max
= std::numeric_limits
<int64_t>::max();
536 int64_t Signed64Min
= std::numeric_limits
<int64_t>::min();
537 W
.printNumber("int64_t-max", Signed64Max
);
538 W
.printNumber("int64_t-min", Signed64Min
);
540 int32_t Signed32Max
= std::numeric_limits
<int32_t>::max();
541 int32_t Signed32Min
= std::numeric_limits
<int32_t>::min();
542 W
.printNumber("int32_t-max", Signed32Max
);
543 W
.printNumber("int32_t-min", Signed32Min
);
545 int16_t Signed16Max
= std::numeric_limits
<int16_t>::max();
546 int16_t Signed16Min
= std::numeric_limits
<int16_t>::min();
547 W
.printNumber("int16_t-max", Signed16Max
);
548 W
.printNumber("int16_t-min", Signed16Min
);
550 int8_t Signed8Max
= std::numeric_limits
<int8_t>::max();
551 int8_t Signed8Min
= std::numeric_limits
<int8_t>::min();
552 W
.printNumber("int8_t-max", Signed8Max
);
553 W
.printNumber("int8_t-min", Signed8Min
);
555 APSInt
LargeNum("9999999999999999999999");
556 W
.printNumber("apsint", LargeNum
);
558 W
.printNumber("label", "value", 0);
561 const char *ExpectedOut
= R
"(uint64_t-max: 18446744073709551615
563 uint32_t-max: 4294967295
569 int64_t-max: 9223372036854775807
570 int64_t-min: -9223372036854775808
571 int32_t-max: 2147483647
572 int32_t-min: -2147483648
577 apsint: 9999999999999999999999
581 const char *JSONExpectedOut
= R
"({
582 "uint64_t-max
": 18446744073709551615,
584 "uint32_t-max
": 4294967295,
586 "uint16_t-max
": 65535,
590 "int64_t-max
": 9223372036854775807,
591 "int64_t-min
": -9223372036854775808,
592 "int32_t-max
": 2147483647,
593 "int32_t-min
": -2147483648,
594 "int16_t-max
": 32767,
595 "int16_t-min
": -32768,
598 "apsint
": 9999999999999999999999,
604 verifyAll(ExpectedOut
, JSONExpectedOut
, PrintFunc
);
607 TEST_F(ScopedPrinterTest
, PrintBoolean
) {
608 auto PrintFunc
= [](ScopedPrinter
&W
) {
609 W
.printBoolean("True", true);
610 W
.printBoolean("False", false);
613 const char *ExpectedOut
= R
"(True: Yes
617 const char *JSONExpectedOut
= R
"({
621 verifyAll(ExpectedOut
, JSONExpectedOut
, PrintFunc
);
624 TEST_F(ScopedPrinterTest
, PrintVersion
) {
625 auto PrintFunc
= [](ScopedPrinter
&W
) {
626 W
.printVersion("Version", "123", "456", "789");
628 const char *ExpectedOut
= R
"(Version: 123.456.789
630 verifyScopedPrinter(ExpectedOut
, PrintFunc
);
633 TEST_F(ScopedPrinterTest
, PrintList
) {
634 auto PrintFunc
= [](ScopedPrinter
&W
) {
635 const std::vector
<uint64_t> EmptyList
;
636 const std::vector
<std::string
> StringList
= {"foo", "bar", "baz"};
637 const bool BoolList
[] = {true, false};
638 const std::vector
<uint64_t> Unsigned64List
= {
639 std::numeric_limits
<uint64_t>::max(),
640 std::numeric_limits
<uint64_t>::min()};
641 const std::vector
<uint32_t> Unsigned32List
= {
642 std::numeric_limits
<uint32_t>::max(),
643 std::numeric_limits
<uint32_t>::min()};
644 const std::vector
<uint16_t> Unsigned16List
= {
645 std::numeric_limits
<uint16_t>::max(),
646 std::numeric_limits
<uint16_t>::min()};
647 const std::vector
<uint8_t> Unsigned8List
= {
648 std::numeric_limits
<uint8_t>::max(),
649 std::numeric_limits
<uint8_t>::min()};
650 const std::vector
<int64_t> Signed64List
= {
651 std::numeric_limits
<int64_t>::max(),
652 std::numeric_limits
<int64_t>::min()};
653 const std::vector
<int32_t> Signed32List
= {
654 std::numeric_limits
<int32_t>::max(),
655 std::numeric_limits
<int32_t>::min()};
656 const std::vector
<int16_t> Signed16List
= {
657 std::numeric_limits
<int16_t>::max(),
658 std::numeric_limits
<int16_t>::min()};
659 const std::vector
<int8_t> Signed8List
= {
660 std::numeric_limits
<int8_t>::max(), std::numeric_limits
<int8_t>::min()};
661 const std::vector
<APSInt
> APSIntList
= {APSInt("9999999999999999999999"),
662 APSInt("-9999999999999999999999")};
663 W
.printList("EmptyList", EmptyList
);
664 W
.printList("StringList", StringList
);
665 W
.printList("BoolList", makeArrayRef(BoolList
));
666 W
.printList("uint64List", Unsigned64List
);
667 W
.printList("uint32List", Unsigned32List
);
668 W
.printList("uint16List", Unsigned16List
);
669 W
.printList("uint8List", Unsigned8List
);
670 W
.printList("int64List", Signed64List
);
671 W
.printList("int32List", Signed32List
);
672 W
.printList("int16List", Signed16List
);
673 W
.printList("int8List", Signed8List
);
674 W
.printList("APSIntList", APSIntList
);
677 const char *ExpectedOut
= R
"(EmptyList: []
678 StringList: [foo, bar, baz]
680 uint64List: [18446744073709551615, 0]
681 uint32List: [4294967295, 0]
682 uint16List: [65535, 0]
684 int64List: [9223372036854775807, -9223372036854775808]
685 int32List: [2147483647, -2147483648]
686 int16List: [32767, -32768]
687 int8List: [127, -128]
688 APSIntList: [9999999999999999999999, -9999999999999999999999]
691 const char *JSONExpectedOut
= R
"({
703 18446744073709551615,
735 9999999999999999999999,
736 -9999999999999999999999
739 verifyAll(ExpectedOut
, JSONExpectedOut
, PrintFunc
);
742 TEST_F(ScopedPrinterTest
, PrintListPrinter
) {
743 auto PrintFunc
= [](ScopedPrinter
&W
) {
744 const std::string StringList
[] = {"a", "ab", "abc"};
745 W
.printList("StringSizeList", StringList
,
746 [](raw_ostream
&OS
, StringRef Item
) { OS
<< Item
.size(); });
749 const char *ExpectedOut
= R
"(StringSizeList: [1, 2, 3]
751 verifyScopedPrinter(ExpectedOut
, PrintFunc
);
754 TEST_F(ScopedPrinterTest
, PrintHex
) {
755 auto PrintFunc
= [](ScopedPrinter
&W
) {
756 W
.printHex("HexNumber", 0x10);
757 W
.printHex("HexLabel", "Name", 0x10);
760 const char *ExpectedOut
= R
"(HexNumber: 0x10
761 HexLabel: Name (0x10)
764 const char *JSONExpectedOut
= R
"({
771 verifyAll(ExpectedOut
, JSONExpectedOut
, PrintFunc
);
774 TEST_F(ScopedPrinterTest
, PrintHexList
) {
775 auto PrintFunc
= [](ScopedPrinter
&W
) {
776 const uint64_t HexList
[] = {0x1, 0x10, 0x100};
777 W
.printHexList("HexList", HexList
);
779 const char *ExpectedOut
= R
"(HexList: [0x1, 0x10, 0x100]
782 const char *JSONExpectedOut
= R
"({
789 verifyAll(ExpectedOut
, JSONExpectedOut
, PrintFunc
);
792 TEST_F(ScopedPrinterTest
, PrintSymbolOffset
) {
793 auto PrintFunc
= [](ScopedPrinter
&W
) {
794 W
.printSymbolOffset("SymbolOffset", "SymbolName", 0x10);
795 W
.printSymbolOffset("NoSymbolOffset", "SymbolName", 0);
797 const char *ExpectedOut
= R
"(SymbolOffset: SymbolName+0x10
798 NoSymbolOffset: SymbolName+0x0
801 const char *JSONExpectedOut
= R
"({
803 "SymName
": "SymbolName
",
807 "SymName
": "SymbolName
",
811 verifyAll(ExpectedOut
, JSONExpectedOut
, PrintFunc
);
814 TEST_F(ScopedPrinterTest
, PrintString
) {
815 auto PrintFunc
= [](ScopedPrinter
&W
) {
816 const StringRef
StringRefValue("Value");
817 const std::string StringValue
= "Value";
818 const char *CharArrayValue
= "Value";
819 W
.printString("StringRef", StringRefValue
);
820 W
.printString("String", StringValue
);
821 W
.printString("CharArray", CharArrayValue
);
822 ListScope
L(W
, "StringList");
823 W
.printString(StringRefValue
);
826 const char *ExpectedOut
= R
"(StringRef: Value
834 const char *JSONExpectedOut
= R
"({
835 "StringRef
": "Value
",
837 "CharArray
": "Value
",
842 verifyAll(ExpectedOut
, JSONExpectedOut
, PrintFunc
);
845 TEST_F(ScopedPrinterTest
, PrintBinary
) {
846 auto PrintFunc
= [](ScopedPrinter
&W
) {
847 std::vector
<uint8_t> IntArray
= {70, 111, 111, 66, 97, 114};
848 std::vector
<char> CharArray
= {'F', 'o', 'o', 'B', 'a', 'r'};
849 std::vector
<uint8_t> InvalidChars
= {255, 255};
850 W
.printBinary("Binary1", "FooBar", IntArray
);
851 W
.printBinary("Binary2", "FooBar", CharArray
);
852 W
.printBinary("Binary3", IntArray
);
853 W
.printBinary("Binary4", CharArray
);
854 W
.printBinary("Binary5", StringRef("FooBar"));
855 W
.printBinary("Binary6", StringRef("Multiple Line FooBar"));
856 W
.printBinaryBlock("Binary7", IntArray
, 20);
857 W
.printBinaryBlock("Binary8", IntArray
);
858 W
.printBinaryBlock("Binary9", "FooBar");
859 W
.printBinaryBlock("Binary10", "Multiple Line FooBar");
860 W
.printBinaryBlock("Binary11", InvalidChars
);
863 const char *ExpectedOut
= R
"(Binary1: FooBar (46 6F 6F 42 61 72)
864 Binary2: FooBar (46 6F 6F 42 61 72)
865 Binary3: (46 6F 6F 42 61 72)
866 Binary4: (46 6F 6F 42 61 72)
867 Binary5: (46 6F 6F 42 61 72)
869 0000: 4D756C74 69706C65 204C696E 6520466F |Multiple Line Fo|
870 0010: 6F426172 |oBar|
873 0014: 466F6F42 6172 |FooBar|
876 0000: 466F6F42 6172 |FooBar|
879 0000: 466F6F42 6172 |FooBar|
882 0000: 4D756C74 69706C65 204C696E 6520466F |Multiple Line Fo|
883 0010: 6F426172 |oBar|
890 const char *JSONExpectedOut
= R
"({
1039 verifyAll(ExpectedOut
, JSONExpectedOut
, PrintFunc
);
1042 TEST_F(ScopedPrinterTest
, PrintObject
) {
1043 auto PrintFunc
= [](ScopedPrinter
&W
) { W
.printObject("Object", "Value"); };
1045 const char *ExpectedOut
= R
"(Object: Value
1048 const char *JSONExpectedOut
= R
"({
1051 verifyAll(ExpectedOut
, JSONExpectedOut
, PrintFunc
);
1054 TEST_F(ScopedPrinterTest
, StartLine
) {
1055 auto PrintFunc
= [](ScopedPrinter
&W
) {
1056 W
.startLine() << "|";
1058 W
.startLine() << "|";
1060 W
.startLine() << "|";
1063 const char *ExpectedOut
= "| | |";
1064 verifyScopedPrinter(ExpectedOut
, PrintFunc
);
1067 TEST_F(ScopedPrinterTest
, GetOStream
) {
1068 auto PrintFunc
= [](ScopedPrinter
&W
) { W
.getOStream() << "Test"; };
1070 const char *ExpectedOut
= "Test";
1071 verifyScopedPrinter(ExpectedOut
, PrintFunc
);
1074 TEST_F(ScopedPrinterTest
, PrintScope
) {
1075 auto PrintFunc
= [](ScopedPrinter
&W
) {
1077 DictScope
O(W
, "Object");
1078 { DictScope
OO(W
, "ObjectInObject"); }
1079 { ListScope
LO(W
, "ListInObject"); }
1082 ListScope
L(W
, "List");
1083 { DictScope
OL(W
, "ObjectInList"); }
1084 { ListScope
LL(W
, "ListInList"); }
1088 const char *ExpectedOut
= R
"(Object {
1102 const char *JSONExpectedOut
= R
"({
1104 "ObjectInObject
": {},
1116 verifyAll(ExpectedOut
, JSONExpectedOut
, PrintFunc
);