From 72f6ed789b500da93f1f9c603697438efa6eff97 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:12:11 +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 | 20 ++++++++++++++++++++ TinySTL/Test/StringTest.h | 1 + 2 files changed, 21 insertions(+) diff --git a/TinySTL/Test/StringTest.cpp b/TinySTL/Test/StringTest.cpp index 73b9acf..4396dd5 100644 --- a/TinySTL/Test/StringTest.cpp +++ b/TinySTL/Test/StringTest.cpp @@ -328,6 +328,25 @@ namespace TinySTL{ assert(TinySTL::Test::container_equal(str, tsStr("There are two prepositions in this haystack with needles."))); } + void testCase20(){ + tsStr str("The sixth sick sheik's sixth sheep's sick."); + tsStr key("sixth"); + + auto found = str.rfind(key); + assert(found == 23); + + found = str.rfind(key, 24); + assert(found == 23); + + found = str.rfind('.'); + assert(found == str.size() - 1); + + found = str.rfind("The"); + assert(found == 0); + + found = str.rfind("sick111", 10, 4); + assert(found == 10); + } } } @@ -352,6 +371,7 @@ int main(){ //testCase17(); //testCase18(); //testCase19(); + testCase20(); system("pause"); return 0; } \ No newline at end of file diff --git a/TinySTL/Test/StringTest.h b/TinySTL/Test/StringTest.h index 3b09e18..b0096ec 100644 --- a/TinySTL/Test/StringTest.h +++ b/TinySTL/Test/StringTest.h @@ -33,6 +33,7 @@ namespace TinySTL{ void testCase17(); void testCase18(); void testCase19(); + void testCase20(); } }