Skip to content
Snippets Groups Projects
Commit 525ced2d authored by Stéphane Del Pino's avatar Stéphane Del Pino
Browse files

Add Demangle tests

parent efac0892
No related branches found
No related tags found
1 merge request!63Feature/utils coverage
...@@ -57,6 +57,7 @@ add_executable (unit_tests ...@@ -57,6 +57,7 @@ add_executable (unit_tests
test_CRSGraph.cpp test_CRSGraph.cpp
test_CRSMatrix.cpp test_CRSMatrix.cpp
test_DataVariant.cpp test_DataVariant.cpp
test_Demangle.cpp
test_DoWhileProcessor.cpp test_DoWhileProcessor.cpp
test_EmbeddedData.cpp test_EmbeddedData.cpp
test_ExecutionPolicy.cpp test_ExecutionPolicy.cpp
......
#ifndef TEST_DEMANGLE_HPP
#define TEST_DEMANGLE_HPP
#include <catch2/catch.hpp>
#include <utils/Demangle.hpp>
#include <cxxabi.h>
// clazy:excludeall=non-pod-global-static
TEST_CASE("Demangle", "[utils]")
{
SECTION("demangle success")
{
const std::string mangled = typeid(std::string).name();
int status = -1;
char* cxa_demangled = abi::__cxa_demangle(mangled.data(), NULL, NULL, &status);
REQUIRE(status == 0);
std::string demangled{cxa_demangled};
free(cxa_demangled);
REQUIRE(demangled == demangle<std::string>());
}
SECTION("demangle failed")
{
const std::string mangled = "not_mangled";
int status = -1;
abi::__cxa_demangle(mangled.data(), NULL, NULL, &status);
REQUIRE(status != 0);
REQUIRE((std::string{"not_mangled"} == demangle("not_mangled")));
}
}
#endif // TEST_DEMANGLE_HPP
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment