Commits

Anonymous committed 4044b90

Fixed a bug on ntpath

Comments (0)

Files changed (2)

neglect/cpplib/src/ntpath.cpp

         rv.resize(rv.size() - 1);
     if (rv.size() == 2 && rv[1] == ':')
         rv += "\\";
+    if (rv.empty() && !filename.empty() && is_slash(filename[0]))
+        return filename.substr(0, 1);
     return rv;
 }
 

neglect/tests/src/test_path.cpp

         NUT_CHECK_EQUAL(ntpath::dirname("C:\\\\broken.txt"), "C:\\");
         NUT_CHECK_EQUAL(ntpath::dirname("C:\\more\\\\/broken.txt"), "C:\\more");
         NUT_CHECK_EQUAL(ntpath::dirname("C:/more/broken.txt"), "C:/more");
+        NUT_CHECK_EQUAL(ntpath::dirname("\\test"), "\\");
     }
 
     NUT_TESTCASE(basename)