Bump version to 19.1.0-rc3
[llvm-project.git] / llvm / unittests / Testing / ADT / StringMapTest.cpp
blob06bbaee72e5166297927dd7f2fe75bb7249b9c5b
1 //===- StringMapTest.cpp --------------------------------------------------===//
2 //
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
6 //
7 //===----------------------------------------------------------------------===//
9 #include "llvm/Testing/ADT/StringMap.h"
10 #include "llvm/ADT/StringMap.h"
12 #include "gtest/gtest.h"
13 #include <sstream>
15 namespace llvm {
16 namespace {
18 TEST(StringMapTest, StringMapStream) {
19 std::ostringstream OS;
20 StringMap<int> Map;
21 Map["A"] = 42;
22 Map["Z"] = 35;
23 Map["B"] = 7;
24 OS << Map;
26 EXPECT_EQ(OS.str(), R"({
27 {"A": 42},
28 {"B": 7},
29 {"Z": 35},
30 })");
33 TEST(StringMapTest, NestedStringMapStream) {
34 std::ostringstream OS;
35 StringMap<StringMap<int>> Map;
36 Map["Z"];
37 Map["A"]["Apple"] = 5;
38 Map["B"]["Bee"] = 3;
39 Map["A"]["Axe"] = 3;
40 OS << Map;
42 EXPECT_EQ(OS.str(), R"({
43 {"A": {
44 {"Apple": 5},
45 {"Axe": 3},
46 }},
47 {"B": {
48 {"Bee": 3},
49 }},
50 {"Z": { }},
51 })");
54 } // namespace
55 } // namespace llvm