From 9e0da1e121f329ba9a6798115173d8c59136ee9c 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 11:00:40 +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 | 27 ++++++++++++++++++++++----- TinySTL/Test/StringTest.h | 2 ++ 2 files changed, 24 insertions(+), 5 deletions(-) diff --git a/TinySTL/Test/StringTest.cpp b/TinySTL/Test/StringTest.cpp index 1fa0572..9498ae4 100644 --- a/TinySTL/Test/StringTest.cpp +++ b/TinySTL/Test/StringTest.cpp @@ -394,6 +394,21 @@ namespace TinySTL{ auto found = str.find_last_not_of("023456789", str.size() - 2); assert(found == 0); } + void testCase25(){ + tsStr str = "We think in generalities, but we live in details."; + + auto s = str.substr(3, 5); + assert(TinySTL::Test::container_equal(s, tsStr("think"))); + } + void testCase26(){ + tsStr str1("green apple"); + tsStr str2("red apple"); + + assert(str1.compare(str2) != 0); + assert(str1.compare(6, 5, "apple") == 0); + assert(str2.compare(str2.size() - 5, 5, "apple") == 0); + assert(str1.compare(6, 5, str2, 4, 5) == 0); + } } } @@ -418,11 +433,13 @@ int main(){ //testCase17(); //testCase18(); //testCase19(); - testCase20(); - testCase21(); - testCase22(); - testCase23(); - testCase24(); + //testCase20(); + //testCase21(); + //testCase22(); + //testCase23(); + //testCase24(); + //testCase25(); + //testCase26(); system("pause"); return 0; } \ No newline at end of file diff --git a/TinySTL/Test/StringTest.h b/TinySTL/Test/StringTest.h index 4c332ec..8353cd7 100644 --- a/TinySTL/Test/StringTest.h +++ b/TinySTL/Test/StringTest.h @@ -38,6 +38,8 @@ namespace TinySTL{ void testCase22(); void testCase23(); void testCase24(); + void testCase25(); + void testCase26(); } }