add cow_ptr test

This commit is contained in:
邹晓航
2015-03-16 15:14:36 +08:00
parent 8e5f9a47af
commit 6b85b32575
6 changed files with 94 additions and 4 deletions

View File

@@ -0,0 +1,24 @@
#include "COWPtrTest.h"
#include "../String.h"
namespace TinySTL{
namespace COWPtrTest{
void testCase1(){
cow_ptr<string> cp1(new string("hello"));
assert(*cp1 == "hello");
cp1->append(" world");
auto cp2 = cp1;
assert(*cp2 == "hello world");
cow_ptr<string> cp3;
cp3 = cp1;
assert(*cp3 == "hello world");
}
void testAllCases(){
testCase1();
}
}
}