From 09fcbcf4aa417de98630084b6f8d9e0af2b935f0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=82=B9=E6=99=93=E8=88=AA?= <1210603696@qq.com> Date: Wed, 24 Dec 2014 10:31:06 +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 | 26 ++++++++++++++++++++++++++ TinySTL/Test/StringTest.h | 2 ++ 2 files changed, 28 insertions(+) diff --git a/TinySTL/Test/StringTest.cpp b/TinySTL/Test/StringTest.cpp index 54316e0..7ee7267 100644 --- a/TinySTL/Test/StringTest.cpp +++ b/TinySTL/Test/StringTest.cpp @@ -222,6 +222,30 @@ namespace TinySTL{ s2 += tsStr("world"); assert(TinySTL::Test::container_equal(s1, s2)); } + void testCase14(){ + stdStr s1("hello world"); + tsStr s2("hello world"); + + s1.pop_back(); + s2.pop_back(); + assert(TinySTL::Test::container_equal(s1, s2)); + } + void testCase15(){ + stdStr s1("hello world"); + tsStr s2("hello world"); + + s1.erase(s1.begin() + 1); + s2.erase(s2.begin() + 1); + assert(TinySTL::Test::container_equal(s1, s2)); + + s1.erase(2, s1.size() - 4); + s2.erase(2, s2.size() - 4); + assert(TinySTL::Test::container_equal(s1, s2)); + + s1.erase(s1.begin(), s1.end()); + s2.erase(s2.begin(), s2.end()); + assert(TinySTL::Test::container_equal(s1, s2)); + } } } @@ -240,6 +264,8 @@ int main(){ //testCase11(); testCase12(); testCase13(); + testCase14(); + testCase15(); system("pause"); return 0; } \ No newline at end of file diff --git a/TinySTL/Test/StringTest.h b/TinySTL/Test/StringTest.h index 56a3c41..e778a6c 100644 --- a/TinySTL/Test/StringTest.h +++ b/TinySTL/Test/StringTest.h @@ -27,6 +27,8 @@ namespace TinySTL{ void testCase11(); void testCase12(); void testCase13(); + void testCase14(); + void testCase15(); } }