diff --git a/TinySTL/Test/VectorTest.cpp b/TinySTL/Test/VectorTest.cpp index 23e1f0f..9dab7b5 100644 --- a/TinySTL/Test/VectorTest.cpp +++ b/TinySTL/Test/VectorTest.cpp @@ -77,6 +77,48 @@ namespace TinySTL{ std::cout << ' ' << *it; std::cout << '\n'; } + void testCase6(){ + tsVec v(11, 0); + assert(v.size() == 11); + + v.resize(5); + assert(v.size() == 5); + + v.resize(20); + assert(v.size() == 20); + } + void testCase7(){ + tsVec v; + v.reserve(20); + assert(v.capacity() == 20); + } + void testCase8(){ + stdVec v1(10); + tsVec v2(10); + for (unsigned i = 0; i < 10; i++){ + v1[i] = i; + v2[i] = i; + } + assert(TinySTL::Test::container_equal(v1, v2)); + + v1.front() = 99; + v2.front() = 99; + v1.back() = 100; + v2.back() = 100; + + assert(TinySTL::Test::container_equal(v1, v2)); + } + void testCase9(){ + stdVec v1(5); + tsVec v2(5); + + auto p1 = v1.data(); + auto p2 = v2.data(); + *p1 = 10; ++p1; *p1 = 20; p1[2] = 100; + *p2 = 10; ++p2; *p2 = 20; p2[2] = 100; + + assert(TinySTL::Test::container_equal(v1, v2)); + } } } @@ -87,6 +129,10 @@ int main(){ //testCase3(); //testCase4(); //testCase5(); + //testCase6(); + //testCase7(); + //testCase8(); + //testCase9(); system("pause"); return 0; } \ No newline at end of file diff --git a/TinySTL/Test/VectorTest.h b/TinySTL/Test/VectorTest.h index a2f9aee..b91ffa7 100644 --- a/TinySTL/Test/VectorTest.h +++ b/TinySTL/Test/VectorTest.h @@ -25,6 +25,10 @@ namespace TinySTL{ void testCase3(); void testCase4(); void testCase5(); + void testCase6(); + void testCase7(); + void testCase8(); + void testCase9(); } }