Skip to content

Commit 05cfb58

Browse files
committed
Update BreakBeforeFilename tests to respect 32-bit addresses
1 parent 63e801c commit 05cfb58

1 file changed

Lines changed: 44 additions & 42 deletions

File tree

test/unit/lib/formatting.cpp

Lines changed: 44 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,10 @@ namespace {
2121

2222
#if UINTPTR_MAX > 0xffffffff
2323
#define ADDR_PREFIX "00000000"
24+
#define PADDING_TAG " "
2425
#define INLINED_TAG "(inlined) "
2526
#else
27+
#define PADDING_TAG ""
2628
#define ADDR_PREFIX ""
2729
#define INLINED_TAG "(inlined) "
2830
#endif
@@ -134,12 +136,12 @@ TEST(FormatterTest, BreakBeforeFilename) {
134136
split(formatter.format(make_test_stacktrace()), "\n"),
135137
ElementsAre(
136138
"Stack trace (most recent call first):",
137-
"#0 0x0000000000000001 in foo()",
138-
" at foo.cpp:20:30",
139-
"#1 0x0000000000000002 in bar()",
140-
" at bar.cpp:30:40",
141-
"#2 0x0000000000000003 in main",
142-
" at foo.cpp:40:25"
139+
"#0 0x" ADDR_PREFIX "00000001 in foo()",
140+
" " PADDING_TAG " at foo.cpp:20:30",
141+
"#1 0x" ADDR_PREFIX "00000002 in bar()",
142+
" " PADDING_TAG " at bar.cpp:30:40",
143+
"#2 0x" ADDR_PREFIX "00000003 in main",
144+
" " PADDING_TAG " at foo.cpp:40:25"
143145
)
144146
);
145147
}
@@ -174,12 +176,12 @@ TEST(FormatterTest, BreakBeforeFilenameInlines) {
174176
split(formatter.format(trace), "\n"),
175177
ElementsAre(
176178
"Stack trace (most recent call first):",
177-
"#0 0x0000000000000001 in foo()",
178-
" at foo.cpp:20:30",
179-
"#1 (inlined) in bar()",
180-
" at bar.cpp:30:40",
181-
"#2 0x0000000000000003 in main",
182-
" at foo.cpp:40:25"
179+
"#0 0x" ADDR_PREFIX "00000001 in foo()",
180+
" " PADDING_TAG " at foo.cpp:20:30",
181+
"#1 " INLINED_TAG " in bar()",
182+
" " PADDING_TAG " at bar.cpp:30:40",
183+
"#2 0x" ADDR_PREFIX "00000003 in main",
184+
" " PADDING_TAG " at foo.cpp:40:25"
183185
)
184186
);
185187
}
@@ -194,30 +196,30 @@ TEST(FormatterTest, BreakBeforeFilenameLongTrace) {
194196
split(formatter.format(make_test_stacktrace(4)), "\n"),
195197
ElementsAre(
196198
"Stack trace (most recent call first):",
197-
"#0 0x0000000000000001 in foo()",
198-
" at foo.cpp:20:30",
199-
"#1 0x0000000000000002 in bar()",
200-
" at bar.cpp:30:40",
201-
"#2 0x0000000000000003 in main",
202-
" at foo.cpp:40:25",
203-
"#3 0x0000000000000001 in foo()",
204-
" at foo.cpp:20:30",
205-
"#4 0x0000000000000002 in bar()",
206-
" at bar.cpp:30:40",
207-
"#5 0x0000000000000003 in main",
208-
" at foo.cpp:40:25",
209-
"#6 0x0000000000000001 in foo()",
210-
" at foo.cpp:20:30",
211-
"#7 0x0000000000000002 in bar()",
212-
" at bar.cpp:30:40",
213-
"#8 0x0000000000000003 in main",
214-
" at foo.cpp:40:25",
215-
"#9 0x0000000000000001 in foo()",
216-
" at foo.cpp:20:30",
217-
"#10 0x0000000000000002 in bar()",
218-
" at bar.cpp:30:40",
219-
"#11 0x0000000000000003 in main",
220-
" at foo.cpp:40:25"
199+
"#0 0x" ADDR_PREFIX "00000001 in foo()",
200+
" " PADDING_TAG " at foo.cpp:20:30",
201+
"#1 0x" ADDR_PREFIX "00000002 in bar()",
202+
" " PADDING_TAG " at bar.cpp:30:40",
203+
"#2 0x" ADDR_PREFIX "00000003 in main",
204+
" " PADDING_TAG " at foo.cpp:40:25",
205+
"#3 0x" ADDR_PREFIX "00000001 in foo()",
206+
" " PADDING_TAG " at foo.cpp:20:30",
207+
"#4 0x" ADDR_PREFIX "00000002 in bar()",
208+
" " PADDING_TAG " at bar.cpp:30:40",
209+
"#5 0x" ADDR_PREFIX "00000003 in main",
210+
" " PADDING_TAG " at foo.cpp:40:25",
211+
"#6 0x" ADDR_PREFIX "00000001 in foo()",
212+
" " PADDING_TAG " at foo.cpp:20:30",
213+
"#7 0x" ADDR_PREFIX "00000002 in bar()",
214+
" " PADDING_TAG " at bar.cpp:30:40",
215+
"#8 0x" ADDR_PREFIX "00000003 in main",
216+
" " PADDING_TAG " at foo.cpp:40:25",
217+
"#9 0x" ADDR_PREFIX "00000001 in foo()",
218+
" " PADDING_TAG " at foo.cpp:20:30",
219+
"#10 0x" ADDR_PREFIX "00000002 in bar()",
220+
" " PADDING_TAG " at bar.cpp:30:40",
221+
"#11 0x" ADDR_PREFIX "00000003 in main",
222+
" " PADDING_TAG " at foo.cpp:40:25"
221223
)
222224
);
223225
}
@@ -235,12 +237,12 @@ TEST(FormatterTest, BreakBeforeFilenameColors) {
235237
split(formatter.format(make_test_stacktrace()), "\n"),
236238
ElementsAre(
237239
"Stack trace (most recent call first):",
238-
"#0 \x1B[34m0x0000000000000001\x1B[0m in \x1B[33mfoo()\x1B[0m",
239-
" at \x1B[32mfoo.cpp\x1B[0m:\x1B[34m20\x1B[0m:\x1B[34m30\x1B[0m",
240-
"#1 \x1B[34m0x0000000000000002\x1B[0m in \x1B[33mbar()\x1B[0m",
241-
" at \x1B[32mbar.cpp\x1B[0m:\x1B[34m30\x1B[0m:\x1B[34m40\x1B[0m",
242-
"#2 \x1B[34m0x0000000000000003\x1B[0m in \x1B[33mmain\x1B[0m",
243-
" at \x1B[32mfoo.cpp\x1B[0m:\x1B[34m40\x1B[0m:\x1B[34m25\x1B[0m"
240+
"#0 \x1B[34m0x" ADDR_PREFIX "00000001\x1B[0m in \x1B[33mfoo()\x1B[0m",
241+
" " PADDING_TAG " at \x1B[32mfoo.cpp\x1B[0m:\x1B[34m20\x1B[0m:\x1B[34m30\x1B[0m",
242+
"#1 \x1B[34m0x" ADDR_PREFIX "00000002\x1B[0m in \x1B[33mbar()\x1B[0m",
243+
" " PADDING_TAG " at \x1B[32mbar.cpp\x1B[0m:\x1B[34m30\x1B[0m:\x1B[34m40\x1B[0m",
244+
"#2 \x1B[34m0x" ADDR_PREFIX "00000003\x1B[0m in \x1B[33mmain\x1B[0m",
245+
" " PADDING_TAG " at \x1B[32mfoo.cpp\x1B[0m:\x1B[34m40\x1B[0m:\x1B[34m25\x1B[0m"
244246
)
245247
);
246248
}

0 commit comments

Comments
 (0)