diff options
| author | Martin Hořeňovský | 2022-07-17 14:00:04 +0200 |
|---|---|---|
| committer | Martin Hořeňovský | 2022-07-17 19:15:20 +0200 |
| commit | 9c9f35068edaa1290789c56f241fc54e7de0eeb0 (patch) | |
| tree | 21e6acbce31ac5fcf0145e627bc88ce2e0cec935 /src/catch2 | |
| parent | 1bd233866c5ba1d94fbea34b260685b4b4ecb796 (diff) | |
| download | catch3-9c9f35068edaa1290789c56f241fc54e7de0eeb0.tar.gz | |
Normalize C++ namespace in JUnit's reporter classname field
Closes #2468
Diffstat (limited to 'src/catch2')
| -rw-r--r-- | src/catch2/reporters/catch_reporter_junit.cpp | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/src/catch2/reporters/catch_reporter_junit.cpp b/src/catch2/reporters/catch_reporter_junit.cpp index 37546cd7..c24d1efa 100644 --- a/src/catch2/reporters/catch_reporter_junit.cpp +++ b/src/catch2/reporters/catch_reporter_junit.cpp @@ -67,6 +67,15 @@ namespace Catch { return rss.str(); } + static void normalizeNamespaceMarkers(std::string& str) { + std::size_t pos = str.find( "::" ); + while ( pos != str.npos ) { + str.replace( pos, 2, "." ); + pos += 1; + pos = str.find( "::", pos ); + } + } + } // anonymous namespace JunitReporter::JunitReporter( ReporterConfig&& _config ) @@ -170,6 +179,8 @@ namespace Catch { if ( !m_config->name().empty() ) className = static_cast<std::string>(m_config->name()) + '.' + className; + normalizeNamespaceMarkers(className); + writeSection( className, "", rootSection, stats.testInfo->okToFail() ); } |