Enable some new path unit tests

This commit is contained in:
Brian Cox 2017-09-13 23:01:22 -07:00
parent 769874d34b
commit f67c370f29
2 changed files with 9 additions and 13 deletions

View File

@ -527,7 +527,7 @@ bool cArosPath::IsAbsolutePath(const TSTRING& in)
if (in[0] == '/')
return true;
if (in.find(":/") != std::string::npos)
if (in.find(":") != std::string::npos)
return true;
return false;
@ -554,12 +554,13 @@ TSTRING cArosPath::AsNative( const TSTRING& in )
return in;
}
int x = 1;
for ( x; in[x] == '/' && x<in.length(); x++);
TSTRING out = in.substr(x);
std::string::size_type drive = in.find_first_not_of("/");
TSTRING out = (drive != std::string::npos) ? in.substr(drive) : in;
TSTRING::size_type t = out.find_first_of('/');
out[t] = ':';
if(t != std::string::npos)
out[t] = ':';
else
out.append(":");
return out;
}

View File

@ -118,8 +118,6 @@ void TestDosIsAbsolute()
void testDosBackupName(const std::string& in, const std::string& expected)
{
TCERR << "In: " << in << " | Expected: " << expected << " | Observed: " << cDosPath::BackupName(in) << std::endl;
TEST( expected == cDosPath::BackupName(in) );
}
@ -136,13 +134,12 @@ void TestDosBackupName()
void testArosAsPosix(const std::string& in, const std::string& expected)
{
TCERR << "In: " << in << " | Expected: " << expected << " | Observed: " << cArosPath::AsPosix(in) << std::endl ;
TEST( expected == cArosPath::AsPosix(in) );
}
void TestArosAsPosix()
{
// testArosAsPosix("DH0:", "/DH0/");
testArosAsPosix("DH0:", "/DH0/");
testArosAsPosix("DH0:Foo", "/DH0/Foo");
testArosAsPosix("DH0:Foo/Bar", "/DH0/Foo/Bar");
@ -194,10 +191,8 @@ void RegisterSuite_File()
RegisterTest("File", "DosAsNative", TestDosAsNative);
RegisterTest("File", "DosIsAbsolute", TestDosIsAbsolute);
RegisterTest("File", "DosBackupName", TestDosBackupName);
// TODO: Finish these
/*
RegisterTest("File", "ArosAsPosix", TestArosAsPosix);
RegisterTest("File", "ArosAsNative", TestArosAsNative);
RegisterTest("File", "ArosIsAbsolute", TestArosIsAbsolute);
*/
}