Fix PathIterator to allow paths that don't start with /

This commit is contained in:
2017-04-22 14:34:20 -05:00
parent f9634a2f3a
commit c3fe5e9cc2
3 changed files with 50 additions and 18 deletions
+1
View File
@@ -31,3 +31,4 @@ add_test("FileStoreIO" FileStoreIO)
add_test("Test\\ PathIterator1" FSTests PathIterator1)
add_test("Test\\ PathIterator2" FSTests PathIterator2)
add_test("Test\\ PathIterator3" FSTests PathIterator3)
add_test("Test\\ PathIterator4" FSTests PathIterator4)
+32 -3
View File
@@ -19,7 +19,7 @@ using namespace ox::std;
map<string, int(*)(string)> tests = {
{
{
{
"PathIterator1",
[](string) {
int retval = 0;
@@ -34,7 +34,7 @@ map<string, int(*)(string)> tests = {
return retval;
}
},
{
{
"PathIterator2",
[](string) {
int retval = 0;
@@ -48,7 +48,7 @@ map<string, int(*)(string)> tests = {
return retval;
}
},
{
{
"PathIterator3",
[](string) {
int retval = 0;
@@ -61,6 +61,35 @@ map<string, int(*)(string)> tests = {
return retval;
}
},
{
"PathIterator4",
[](string) {
int retval = 0;
string path = "usr/share/charset.gbag";
PathIterator it(path.c_str(), path.size());
const auto buffSize = 1024;
char buff[buffSize];
assert(buffSize >= path.size());
retval |= !(it.next(buff, path.size()) == 0 && ox_strcmp(buff, "usr") == 0);
retval |= !(it.next(buff, path.size()) == 0 && ox_strcmp(buff, "share") == 0);
retval |= !(it.next(buff, path.size()) == 0 && ox_strcmp(buff, "charset.gbag") == 0);
return retval;
}
},
{
"PathIterator5",
[](string) {
int retval = 0;
string path = "usr/share/";
PathIterator it(path.c_str(), path.size());
const auto buffSize = 1024;
char buff[buffSize];
assert(buffSize >= path.size());
retval |= !(it.next(buff, path.size()) == 0 && ox_strcmp(buff, "usr") == 0);
retval |= !(it.next(buff, path.size()) == 0 && ox_strcmp(buff, "share") == 0);
return retval;
}
},
},
};