From 19166500ef88981775d4988f9fc98367c23ebbac Mon Sep 17 00:00:00 2001 From: Thomas Jarosch Date: Wed, 6 Aug 2008 16:11:50 +0000 Subject: [PATCH] libi2ncommon: (tomj) unit tests for normalize_path() corner cases --- test/test_filefunc.cpp | 28 ++++++++++++++++++++++++++++ 1 files changed, 28 insertions(+), 0 deletions(-) diff --git a/test/test_filefunc.cpp b/test/test_filefunc.cpp index 862f926..0acdca3 100644 --- a/test/test_filefunc.cpp +++ b/test/test_filefunc.cpp @@ -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() { -- 1.7.1