@@ -3231,6 +3231,26 @@ static void fuzz_crash()
32313231 }
32323232}
32333233
3234+ static void isAbsolutePath () {
3235+ #ifdef _WIN32
3236+ ASSERT_EQUALS (true , simplecpp::isAbsolutePath (" C:\\ foo\\ bar" ));
3237+ ASSERT_EQUALS (true , simplecpp::isAbsolutePath (" C:/foo/bar" ));
3238+ ASSERT_EQUALS (true , simplecpp::isAbsolutePath (" \\\\ foo\\ bar" ));
3239+ ASSERT_EQUALS (false , simplecpp::isAbsolutePath (" foo\\ bar" ));
3240+ ASSERT_EQUALS (false , simplecpp::isAbsolutePath (" foo/bar" ));
3241+ ASSERT_EQUALS (false , simplecpp::isAbsolutePath (" foo.cpp" ));
3242+ ASSERT_EQUALS (false , simplecpp::isAbsolutePath (" C:foo.cpp" ));
3243+ ASSERT_EQUALS (false , simplecpp::isAbsolutePath (" C:foo\\ bar.cpp" ));
3244+ ASSERT_EQUALS (false , simplecpp::isAbsolutePath (" bar.cpp" ));
3245+ // ASSERT_EQUALS(true, simplecpp::isAbsolutePath("\\")); // TODO
3246+ #else
3247+ ASSERT_EQUALS (true , simplecpp::isAbsolutePath (" /foo/bar" ));
3248+ // ASSERT_EQUALS(true, simplecpp::isAbsolutePath("/")); // TODO
3249+ ASSERT_EQUALS (false , simplecpp::isAbsolutePath (" foo/bar" ));
3250+ ASSERT_EQUALS (false , simplecpp::isAbsolutePath (" foo.cpp" ));
3251+ #endif
3252+ }
3253+
32343254int main (int argc, char **argv)
32353255{
32363256 TEST_CASE (backslash);
@@ -3487,5 +3507,7 @@ int main(int argc, char **argv)
34873507
34883508 TEST_CASE (fuzz_crash);
34893509
3510+ TEST_CASE (isAbsolutePath);
3511+
34903512 return numberOfFailedAssertions > 0 ? EXIT_FAILURE : EXIT_SUCCESS;
34913513}
0 commit comments