@@ -57,6 +57,7 @@ class TestPath : public TestFixture {
5757 TEST_CASE (getAbsolutePath);
5858 TEST_CASE (exists);
5959 TEST_CASE (fromNativeSeparators);
60+ TEST_CASE (isRelative);
6061 }
6162
6263 void removeQuotationMarks () const {
@@ -618,6 +619,27 @@ class TestPath : public TestFixture {
618619 ASSERT_EQUALS (" //lib/file.c" , Path::fromNativeSeparators (" \\\\ lib\\ file.c" ));
619620 ASSERT_EQUALS (" ./lib/file.c" , Path::fromNativeSeparators (" .\\ lib\\ file.c" ));
620621 }
622+
623+ void isRelative () const {
624+ ASSERT_EQUALS (true , Path::isRelative (" dir/file" ));
625+ ASSERT_EQUALS (true , Path::isRelative (" dir\\ file" ));
626+
627+ // TODO: is this expected?
628+ ASSERT_EQUALS (true , Path::isRelative (" file/" ));
629+ ASSERT_EQUALS (true , Path::isRelative (" file\\ " ));
630+
631+ ASSERT_EQUALS (false , Path::isRelative (" file" ));
632+ ASSERT_EQUALS (false , Path::isRelative (" /dir/file" ));
633+
634+ // TODO: this is not detected as absolute path in _WIN32 builds
635+ #ifdef _WIN32
636+ ASSERT_EQUALS (false , Path::isRelative (" c:\\ dir\\ file" ));
637+ ASSERT_EQUALS (false , Path::isRelative (" c:/dir/file" ));
638+ #else
639+ ASSERT_EQUALS (true , Path::isRelative (" c:\\ dir\\ file" ));
640+ ASSERT_EQUALS (true , Path::isRelative (" c:/dir/file" ));
641+ #endif
642+ }
621643};
622644
623645REGISTER_TEST (TestPath)
0 commit comments