@@ -3257,36 +3257,42 @@ static void safe_api()
32573257}
32583258
32593259static void isAbsolutePath () {
3260- #ifdef _WIN32
3261- ASSERT_EQUALS (true , simplecpp::isAbsolutePath (" C:\\ foo\\ bar" ));
3262- ASSERT_EQUALS (true , simplecpp::isAbsolutePath (" C:/foo/bar" ));
3263- ASSERT_EQUALS (true , simplecpp::isAbsolutePath (" \\\\ foo\\ bar" ));
3260+ #if defined(_WIN32) || defined(__CYGWIN__) || defined(__MINGW32__) || defined(__MSYS__)
3261+ constexpr bool supportsWin = true ;
3262+ #else
3263+ constexpr bool supportsWin = false ;
3264+ #endif
3265+
3266+ #if !defined(_WIN32) || defined(__MINGW32__)
3267+ constexpr bool supportsUnx = true ;
3268+ #else
3269+ constexpr bool supportsUnx = false ;
3270+ #endif
3271+
3272+ // valid Windows paths
3273+ ASSERT_EQUALS (supportsWin, simplecpp::isAbsolutePath (" C:\\ foo\\ bar" ));
3274+ ASSERT_EQUALS (supportsWin, simplecpp::isAbsolutePath (" C:/foo/bar" ));
3275+ ASSERT_EQUALS (supportsWin, simplecpp::isAbsolutePath (" \\\\ foo\\ bar" ));
32643276
3277+ // valid Unix paths
3278+ ASSERT_EQUALS (supportsUnx, simplecpp::isAbsolutePath (" /foo/bar" ));
3279+ ASSERT_EQUALS (supportsUnx, simplecpp::isAbsolutePath (" /" ));
3280+ ASSERT_EQUALS (supportsUnx, simplecpp::isAbsolutePath (" //host/foo/bar" ));
3281+
3282+ // invalid paths
32653283 ASSERT_EQUALS (false , simplecpp::isAbsolutePath (" foo\\ bar" ));
32663284 ASSERT_EQUALS (false , simplecpp::isAbsolutePath (" foo/bar" ));
32673285 ASSERT_EQUALS (false , simplecpp::isAbsolutePath (" foo.cpp" ));
32683286 ASSERT_EQUALS (false , simplecpp::isAbsolutePath (" C:foo.cpp" ));
32693287 ASSERT_EQUALS (false , simplecpp::isAbsolutePath (" C:foo\\ bar.cpp" ));
32703288 ASSERT_EQUALS (false , simplecpp::isAbsolutePath (" bar.cpp" ));
3271- // ASSERT_EQUALS(true, simplecpp::isAbsolutePath("\\")); // TODO
32723289 ASSERT_EQUALS (false , simplecpp::isAbsolutePath (" 0:\\ foo\\ bar" ));
32733290 ASSERT_EQUALS (false , simplecpp::isAbsolutePath (" 0:/foo/bar" ));
32743291 ASSERT_EQUALS (false , simplecpp::isAbsolutePath (" \\ foo\\ bar" ));
3292+
3293+ // ASSERT_EQUALS(true, simplecpp::isAbsolutePath("\\")); // TODO
32753294 // ASSERT_EQUALS(false, simplecpp::isAbsolutePath("\\\\")); // TODO
32763295 // ASSERT_EQUALS(false, simplecpp::isAbsolutePath("//")); // TODO
3277- ASSERT_EQUALS (false , simplecpp::isAbsolutePath (" /foo/bar" ));
3278- ASSERT_EQUALS (false , simplecpp::isAbsolutePath (" /" ));
3279- #else
3280- ASSERT_EQUALS (true , simplecpp::isAbsolutePath (" /foo/bar" ));
3281- ASSERT_EQUALS (true , simplecpp::isAbsolutePath (" /" ));
3282- ASSERT_EQUALS (true , simplecpp::isAbsolutePath (" //host/foo/bar" ));
3283-
3284- ASSERT_EQUALS (false , simplecpp::isAbsolutePath (" foo/bar" ));
3285- ASSERT_EQUALS (false , simplecpp::isAbsolutePath (" foo.cpp" ));
3286- ASSERT_EQUALS (false , simplecpp::isAbsolutePath (" C:\\ foo\\ bar" ));
3287- ASSERT_EQUALS (false , simplecpp::isAbsolutePath (" C:/foo/bar" ));
3288- ASSERT_EQUALS (false , simplecpp::isAbsolutePath (" \\\\ foo\\ bar" ));
3289- #endif
32903296}
32913297
32923298// crashes detected by fuzzer
0 commit comments