[libcxx-commits] [PATCH] D118130: [demangler] improve test harness
Nathan Sidwell via Phabricator via libcxx-commits
libcxx-commits at lists.llvm.org
Wed Jan 26 04:59:59 PST 2022
This revision was automatically updated to reflect the committed changes.
Closed by commit rG52c7faeae8fc: [demangler] improve test harness (authored by urnathan).
Herald added a project: libc++abi.
Herald added a subscriber: libcxx-commits.
Herald added a reviewer: libc++abi.
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D118130/new/
https://reviews.llvm.org/D118130
Files:
libcxxabi/test/test_demangle.pass.cpp
Index: libcxxabi/test/test_demangle.pass.cpp
===================================================================
--- libcxxabi/test/test_demangle.pass.cpp
+++ libcxxabi/test/test_demangle.pass.cpp
@@ -29946,51 +29946,43 @@
for (unsigned i = 0; i < N; ++i)
{
int status;
- char* demang = __cxxabiv1::__cxa_demangle(cases[i][0], buf, &len, &status);
- if (demang == 0 || std::strcmp(demang, cases[i][1]) != 0)
+ char* demang =
+ __cxxabiv1::__cxa_demangle(cases[i][0], buf, &len, &status);
+ if (!demang || std::strcmp(demang, cases[i][1]) != 0)
{
- std::printf("ERROR demangling %s\nexpected: %s\n", cases[i][0], cases[i][1]);
- if (demang)
- {
- std::printf(" reality: %s\n", demang);
- buf = demang;
- failed = true;
- }
- else
- {
- std::printf("Got instead: NULL, %d\n", status);
- failed = true;
- }
- }
- else
- {
- buf = demang;
+ std::printf("ERROR demangling %s\nexpected: %s\n",
+ cases[i][0], cases[i][1]);
+ std::printf("Got: %d, %s\n", status, demang ? demang : "(null)");
+ failed = true;
}
+ if (demang)
+ buf = demang;
}
- assert(!failed);
free(buf);
+ assert(!failed && "demangle failed");
}
void test_invalid_cases()
{
std::size_t len = 0;
char* buf = nullptr;
+ bool passed = false;
for (unsigned i = 0; i < NI; ++i)
{
int status;
- char* demang = __cxxabiv1::__cxa_demangle(invalid_cases[i], buf, &len, &status);
+ char* demang =
+ __cxxabiv1::__cxa_demangle(invalid_cases[i], buf, &len, &status);
if (status != -2)
{
std::printf("%s should be invalid but is not\n", invalid_cases[i]);
- std::printf("Got status %d\n", status);
- assert(status == -2);
- }
- else
- {
- buf = demang;
+ std::printf("Got: %d, %s\n", status, demang ? demang : "(null)");
+ passed = true;
}
+ if (demang)
+ buf = demang;
}
free(buf);
+ assert(!passed && "demangle did not fail");
}
const char *xfail_cases[] = {
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D118130.403224.patch
Type: text/x-patch
Size: 2369 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/libcxx-commits/attachments/20220126/111c19d4/attachment-0001.bin>
More information about the libcxx-commits
mailing list