diff --git a/TinySTL/Test/VectorTest.cpp b/TinySTL/Test/VectorTest.cpp index e69de29..2c69908 100644 --- a/TinySTL/Test/VectorTest.cpp +++ b/TinySTL/Test/VectorTest.cpp @@ -0,0 +1,49 @@ +#include "VectorTest.h" + +namespace TinySTL{ + namespace VectorTest{ + + void testCase1(){ + stdVec v1(10, "zxh"); + tsVec v2(10, "zxh"); + assert(TinySTL::Test::container_equal(v1, v2)); + + stdVec v3(10); + tsVec v4(10); + assert(TinySTL::Test::container_equal(v3, v4)); + + std::array arr = { "abc", "def", "ghi" }; + stdVec v5(std::begin(arr), std::end(arr)); + tsVec v6(std::begin(arr), std::end(arr)); + assert(TinySTL::Test::container_equal(v5, v6)); + } + void testCase2(){ + stdVec temp1(10, 0); + tsVec temp2(10, 0); + + auto v1(temp1); + auto v2(temp2); + assert(TinySTL::Test::container_equal(v1, v2)); + + auto v3(std::move(temp1)); + auto v4(std::move(temp2)); + assert(TinySTL::Test::container_equal(v3, v4)); + + auto v5 = v1; + auto v6 = v2; + assert(TinySTL::Test::container_equal(v5, v6)); + + auto v7 = std::move(v3); + auto v8 = std::move(v4); + assert(TinySTL::Test::container_equal(v7, v8)); + } + } +} + +using namespace TinySTL::VectorTest; +int main(){ + testCase1(); + testCase2(); + system("pause"); + return 0; +} \ No newline at end of file diff --git a/TinySTL/Test/VectorTest.h b/TinySTL/Test/VectorTest.h index e69de29..2fea093 100644 --- a/TinySTL/Test/VectorTest.h +++ b/TinySTL/Test/VectorTest.h @@ -0,0 +1,27 @@ +#ifndef _VECTOR_TEST_H_ +#define _VECTOR_TEST_H_ + +#include "../Vector.h" +#include "TestUtil.h" + +#include + +#include +#include +#include +#include + +template +using stdVec = std::vector < T > ; + +template +using tsVec = TinySTL::vector < T > ; + +namespace TinySTL{ + namespace VectorTest{ + void testCase1(); + void testCase2(); + } +} + +#endif \ No newline at end of file