添加测试用例

This commit is contained in:
邹晓航
2014-12-24 12:16:33 +08:00
parent c21798c8c3
commit e61b591697
2 changed files with 32 additions and 7 deletions

View File

@@ -305,6 +305,29 @@ namespace TinySTL{
buffer[length] = '\0';
std::cout << "buffer contains: " << buffer << '\n';
}
void testCase19(){
tsStr str("There are two needles in this haystack with needles.");
tsStr str2("needle");
auto found = str.find(str2);
assert(found == 14);
found = str.find("needles are small", found + 1, 6);
assert(found == 44);
found = str.find(tsStr("wuhan"));
assert(found == tsStr::npos);
found = str.find("haystack");
assert(found == 30);
found = str.find('.');
assert(found == 51);
str.replace(str.find(str2), str2.length(), "preposition");
assert(TinySTL::Test::container_equal(str,
tsStr("There are two prepositions in this haystack with needles.")));
}
}
}
@@ -321,13 +344,14 @@ int main(){
//testCase9();
//testCase10();
//testCase11();
testCase12();
testCase13();
testCase14();
testCase15();
testCase16();
testCase17();
testCase18();
//testCase12();
//testCase13();
//testCase14();
//testCase15();
//testCase16();
//testCase17();
//testCase18();
//testCase19();
system("pause");
return 0;
}

View File

@@ -32,6 +32,7 @@ namespace TinySTL{
void testCase16();
void testCase17();
void testCase18();
void testCase19();
}
}