From 96e23a234ca110bcd454591cf9ff61584f3ef00b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=82=B9=E6=99=93=E8=88=AA?= <1210603696@qq.com> Date: Thu, 25 Dec 2014 10:43:28 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E6=B5=8B=E8=AF=95=E7=94=A8?= =?UTF-8?q?=E4=BE=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- TinySTL/Test/StringTest.cpp | 37 +++++++++++++++++++++++++++++++++++++ TinySTL/Test/StringTest.h | 2 ++ 2 files changed, 39 insertions(+) diff --git a/TinySTL/Test/StringTest.cpp b/TinySTL/Test/StringTest.cpp index 4396dd5..9ad547d 100644 --- a/TinySTL/Test/StringTest.cpp +++ b/TinySTL/Test/StringTest.cpp @@ -347,6 +347,41 @@ namespace TinySTL{ found = str.rfind("sick111", 10, 4); assert(found == 10); } + void testCase21(){ + tsStr str("Please, replace the vowels in this sentence by asterisks."); + tsStr key("aeiou"); + const char *arr = "aeiou"; + + auto found = str.find_first_of(arr); + assert(found == 2); + + found = str.find_first_of(arr, found + 1); + assert(found == 3); + + found = str.find_first_of(arr, found + 1, 1); + assert(found == 12); + + found = str.find_first_of(key, found + 1); + assert(found == 14); + + found = str.find_first_of('v', found + 1); + assert(found == 20); + } + void testCase22(){ + tsStr str("1234567890098765432112345678900"); + + auto found = str.find_last_of('6'); + assert(found == 25); + + found = str.find_last_of('6', found - 1); + assert(found == 14); + + found = str.find_last_of("01", 11, 2); + assert(found == 10); + + found = str.find_last_of(tsStr("#1"), 19); + assert(found == 19); + } } } @@ -372,6 +407,8 @@ int main(){ //testCase18(); //testCase19(); testCase20(); + testCase21(); + testCase22(); system("pause"); return 0; } \ No newline at end of file diff --git a/TinySTL/Test/StringTest.h b/TinySTL/Test/StringTest.h index b0096ec..6587378 100644 --- a/TinySTL/Test/StringTest.h +++ b/TinySTL/Test/StringTest.h @@ -34,6 +34,8 @@ namespace TinySTL{ void testCase18(); void testCase19(); void testCase20(); + void testCase21(); + void testCase22(); } }