]> granicus.if.org Git - graphviz/commitdiff
tests: test_utilities: re-write AUTO_NAME to use filesystem::path
authorMagnus Jacobsson <Magnus.Jacobsson@berotec.se>
Thu, 22 Sep 2022 06:57:17 +0000 (08:57 +0200)
committerMagnus Jacobsson <Magnus.Jacobsson@berotec.se>
Thu, 22 Sep 2022 08:21:14 +0000 (10:21 +0200)
This is a simpler version that doesn't rely on GNU statement
expressions (thanks @smattr).

tests/test_utilities.h

index 7382fba7b2beb443130a2d46e74418f6122d3965..4e9768774ac09645af4f54fcd18a9cb36098fcdc 100644 (file)
@@ -46,11 +46,7 @@ extern const std::unordered_set<std::string_view> all_edge_directions;
 /// misc utilities
 
 /// get the base name of the test case file without file extension
-#define AUTO_NAME()                                                            \
-  ({                                                                           \
-    std::string s_{strrchr(__FILE__, '/')};                                    \
-    s_.substr(1, s_.rfind('.') - 1);                                           \
-  })
+#define AUTO_NAME() std::filesystem::path(__FILE__).stem().string()
 
 void write_to_file(const std::filesystem::path &directory,
                    const std::filesystem::path &filename,