Skip to content

Commit 3c23be1

Browse files
committed
fixup! add helper function in test
1 parent f86827c commit 3c23be1

File tree

2 files changed

+29
-124
lines changed

2 files changed

+29
-124
lines changed

lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/unordered_map/TestDataFormatterLibccUnorderedMap.py

Lines changed: 22 additions & 117 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,22 @@
99

1010

1111
class LibcxxUnorderedMapDataFormatterTestCase(TestBase):
12+
def check_reference(self, var_name: str, expected_type: str):
13+
self.expect_var_path(
14+
var_name,
15+
summary="size=1",
16+
type=expected_type,
17+
children=[
18+
ValueCheck(
19+
name="[0]",
20+
children=[
21+
ValueCheck(name="first", summary='"Hello"'),
22+
ValueCheck(name="second", summary='"World"'),
23+
],
24+
),
25+
],
26+
)
27+
1228
@add_test_categories(["libc++"])
1329
def test_iterator_formatters(self):
1430
"""Test that std::unordered_map related structures are formatted correctly when printed.
@@ -68,123 +84,12 @@ def test_iterator_formatters(self):
6884
lldbutil.continue_to_breakpoint(process, bkpt)
6985

7086
# Test references to std::unordered_map
71-
self.expect_var_path(
72-
"ref1",
73-
summary="size=2",
74-
type="const StringMapT &",
75-
children=[
76-
ValueCheck(
77-
name="[0]",
78-
children=[
79-
ValueCheck(name="first", summary='"Baz"'),
80-
ValueCheck(name="second", summary='"Qux"'),
81-
],
82-
),
83-
ValueCheck(
84-
name="[1]",
85-
children=[
86-
ValueCheck(name="first", summary='"Foo"'),
87-
ValueCheck(name="second", summary='"Bar"'),
88-
],
89-
),
90-
],
91-
)
92-
93-
self.expect_var_path(
94-
"ref2",
95-
summary="size=2",
96-
type="StringMapT &",
97-
children=[
98-
ValueCheck(
99-
name="[0]",
100-
children=[
101-
ValueCheck(name="first", summary='"Baz"'),
102-
ValueCheck(name="second", summary='"Qux"'),
103-
],
104-
),
105-
ValueCheck(
106-
name="[1]",
107-
children=[
108-
ValueCheck(name="first", summary='"Foo"'),
109-
ValueCheck(name="second", summary='"Bar"'),
110-
],
111-
),
112-
],
113-
)
114-
115-
self.expect_var_path(
116-
"ref3",
117-
summary="size=2",
118-
type="StringMapTRef",
119-
children=[
120-
ValueCheck(
121-
name="[0]",
122-
children=[
123-
ValueCheck(name="first", summary='"Baz"'),
124-
ValueCheck(name="second", summary='"Qux"'),
125-
],
126-
),
127-
ValueCheck(
128-
name="[1]",
129-
children=[
130-
ValueCheck(name="first", summary='"Foo"'),
131-
ValueCheck(name="second", summary='"Bar"'),
132-
],
133-
),
134-
],
135-
)
136-
137-
self.expect_var_path(
138-
"ref4",
139-
summary="size=2",
140-
type="const StringMapT &",
141-
children=[
142-
ValueCheck(
143-
name="[0]",
144-
children=[
145-
ValueCheck(name="first", summary='"Baz"'),
146-
ValueCheck(name="second", summary='"Qux"'),
147-
],
148-
),
149-
ValueCheck(
150-
name="[1]",
151-
children=[
152-
ValueCheck(name="first", summary='"Foo"'),
153-
ValueCheck(name="second", summary='"Bar"'),
154-
],
155-
),
156-
],
157-
)
158-
159-
self.expect_var_path(
160-
"ref5",
161-
summary="size=1",
162-
type="const StringMapT &&",
163-
children=[
164-
ValueCheck(
165-
name="[0]",
166-
children=[
167-
ValueCheck(name="first", summary='"Foo"'),
168-
ValueCheck(name="second", summary='"Bar"'),
169-
],
170-
),
171-
],
172-
)
173-
174-
self.expect_var_path(
175-
"ref6",
176-
summary="size=1",
177-
type="StringMapT &&",
178-
children=[
179-
ValueCheck(
180-
name="[0]",
181-
children=[
182-
ValueCheck(name="first", summary='"Baz"'),
183-
ValueCheck(name="second", summary='"Qux"'),
184-
],
185-
),
186-
],
187-
)
87+
self.check_reference("ref1", "const StringMapT &")
88+
self.check_reference("ref2", "StringMapT &")
89+
self.check_reference("ref3", "StringMapTRef")
90+
self.check_reference("ref4", "const StringMapT &")
91+
self.check_reference("ref5", "const StringMapT &&")
92+
self.check_reference("ref6", "StringMapT &&")
18893

18994
# FIXME: we're getting this wrong.
19095
self.expect_var_path(

lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/unordered_map/main.cpp

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,10 @@
55
using StringMapT = std::unordered_map<std::string, std::string>;
66
using StringMapTRef = const StringMapT &;
77

8-
void check_references(const StringMapT &ref1, StringMapT &ref2,
9-
StringMapTRef ref3, StringMapTRef &ref4,
10-
const StringMapT &&ref5, StringMapT &&ref6,
11-
const StringMapT *const &ref7) {
8+
static void check_references(const StringMapT &ref1, StringMapT &ref2,
9+
StringMapTRef ref3, StringMapTRef &ref4,
10+
const StringMapT &&ref5, StringMapT &&ref6,
11+
const StringMapT *const &ref7) {
1212
std::printf("Break here");
1313
}
1414

@@ -32,9 +32,9 @@ int main() {
3232

3333
std::printf("Break here");
3434

35-
check_references(string_map, string_map, string_map, string_map,
36-
StringMapT{{"Foo", "Bar"}}, StringMapT{{"Baz", "Qux"}},
37-
&string_map);
35+
StringMapT tmp{{"Hello", "World"}};
36+
check_references(tmp, tmp, tmp, tmp, StringMapT{tmp}, StringMapT{tmp},
37+
&tmp);
3838
}
3939

4040
return 0;

0 commit comments

Comments
 (0)