diff --git a/sourcehook/sh_vector.h b/sourcehook/sh_vector.h index 361cdd2..2575735 100755 --- a/sourcehook/sh_vector.h +++ b/sourcehook/sh_vector.h @@ -277,7 +277,8 @@ public: CVector & operator =(const CVector & other) { clear(); - resize(other.size()); + ChangeSize(other.size()); + m_CurrentUsedSize = other.size(); for (size_t i=0; i IntVector; + IntVector vec1; + IntVector::iterator iter; + int i; + + CHECK_COND(vec1.size() == 0 && vec1.empty(), "V1"); + for (i = 0; i < 500; ++i) + vec1.push_back(i); + + CHECK_COND(vec1.size() == 500 && !vec1.empty(), "V2"); + + for (i = 0; i < 500; ++i) + CHECK_COND(vec1[i] == i, "V3"); + + for (i = 0, iter = vec1.begin(); iter != vec1.end(); ++iter, ++i) + CHECK_COND(*iter == i, "V4"); + + vec1.resize(1000); + for (i = 0; i < 500; ++i) + CHECK_COND(vec1[i] == i, "V5.1"); + for (i = 500; i < 1000; ++i) + CHECK_COND(vec1[i] == 0, "V5.2"); + + vec1.resize(200); + for (i = 0; i < 200; ++i) + CHECK_COND(vec1[i] == i, "V6"); + + vec1.resize(500, 0x12345678); + for (i = 0; i < 200; ++i) + CHECK_COND(vec1[i] == i, "V7.1"); + for (i = 200; i < 500; ++i) + CHECK_COND(vec1[i] == 0x12345678, "V7.2"); + + IntVector vec2(vec1); + CHECK_COND(vec2.size() == vec1.size() && vec2.empty() == vec1.empty(), "V8.0"); + for (i = 0; i < 200; ++i) + CHECK_COND(vec2[i] == i, "V8.1"); + for (i = 200; i < 500; ++i) + CHECK_COND(vec2[i] == 0x12345678, "V8.2"); + + + vec1.clear(); + CHECK_COND(vec1.size() == 0 && vec1.empty() && vec1.begin() == vec1.end(), "V9"); + vec2 = vec1; + CHECK_COND(vec2.size() == 0 && vec2.empty() && vec2.begin() == vec2.end(), "V9"); + + return true; + } } bool TestList(std::string &error) @@ -223,5 +275,8 @@ bool TestList(std::string &error) if (!DoTestStack(error)) return false; + if (!DoTestVec(error)) + return false; + return true; }