libi2ncommon: (tomj) unit tests for normalize_path() corner cases
authorThomas Jarosch <thomas.jarosch@intra2net.com>
Wed, 6 Aug 2008 16:11:50 +0000 (16:11 +0000)
committerThomas Jarosch <thomas.jarosch@intra2net.com>
Wed, 6 Aug 2008 16:11:50 +0000 (16:11 +0000)
test/test_filefunc.cpp

index 862f926..0acdca3 100644 (file)
@@ -51,6 +51,7 @@ class TestFileFunc : public TestFixture
    CPPUNIT_TEST(DirTest1);
    CPPUNIT_TEST(PathCuts1);
    CPPUNIT_TEST(NormalizePath1);
+   CPPUNIT_TEST(NormalizePath2);
    CPPUNIT_TEST(TestUserAndGroupStuff1);
    CPPUNIT_TEST(TestFileModes1);
    CPPUNIT_TEST(TestPidOf1);
@@ -197,7 +198,34 @@ public:
 
    } // eo NormalizePath1
 
+   void NormalizePath2()
+   {
+      std::string path;
+
+      path= normalize_path("/");
+      CPPUNIT_ASSERT_EQUAL( std::string("/"), path );
+
+      path= normalize_path("//");
+      CPPUNIT_ASSERT_EQUAL( std::string("/"), path );
+
+      path= normalize_path("/.//");
+      CPPUNIT_ASSERT_EQUAL( std::string("/"), path );
+
+      path= normalize_path(".");
+      CPPUNIT_ASSERT_EQUAL( std::string(""), path );
+
+      path= normalize_path("./");
+      CPPUNIT_ASSERT_EQUAL( std::string(""), path );
+
+      path= normalize_path(".///");
+      CPPUNIT_ASSERT_EQUAL( std::string(""), path );
+
+      path= normalize_path("/./data/files");
+      CPPUNIT_ASSERT_EQUAL( std::string("/data/files"), path );
 
+      path= normalize_path("./data/files/");
+      CPPUNIT_ASSERT_EQUAL( std::string("data/files"), path );
+   } // eo NormalizePath2
 
    void TestUserAndGroupStuff1()
    {