moar tests
This commit is contained in:
parent
938e557caa
commit
d5974bb824
2 changed files with 104 additions and 3 deletions
|
|
@ -185,6 +185,38 @@ namespace UnitTest1
|
|||
}
|
||||
}
|
||||
}
|
||||
TEST_METHOD(EqualOperatorTests) {
|
||||
CMyString preps[]{
|
||||
CMyString(),
|
||||
CMyString("testtesttest"),
|
||||
};
|
||||
CMyString strs[]{
|
||||
CMyString("test"),
|
||||
CMyString("test"),
|
||||
};
|
||||
int expected[][2] = {
|
||||
{ 4, 10 },
|
||||
{ 4, 13 },
|
||||
};
|
||||
int testcount = sizeof(expected) / (sizeof(int) * 2);
|
||||
for (size_t i = 0; i < testcount; i++)
|
||||
{
|
||||
try
|
||||
{
|
||||
CMyString res = preps[i];
|
||||
res = strs[i];
|
||||
Assert::AreEqual(expected[i][0], (int)res.size());
|
||||
Assert::AreEqual(expected[i][1], (int)res.capacity());
|
||||
Assert::AreEqual(strs[i].c_str(), res.c_str());
|
||||
}
|
||||
catch (...)
|
||||
{
|
||||
Assert::IsTrue(false);
|
||||
}
|
||||
}
|
||||
CMyString str1 = CMyString("test");
|
||||
CMyString str2 = str1;
|
||||
}
|
||||
|
||||
TEST_METHOD(GetAtTests) {
|
||||
CMyString str[]{
|
||||
|
|
@ -308,7 +340,65 @@ namespace UnitTest1
|
|||
}
|
||||
|
||||
TEST_METHOD(EraseTests) {
|
||||
//TODO
|
||||
CMyString str[]{
|
||||
CMyString(),
|
||||
CMyString("test"),
|
||||
CMyString("test"),
|
||||
CMyString("test"),
|
||||
CMyString("test"),
|
||||
CMyString('a', 10),
|
||||
};
|
||||
int pos[] = {
|
||||
0,
|
||||
4,
|
||||
-1,
|
||||
3,
|
||||
3,
|
||||
3,
|
||||
};
|
||||
int cnt[] = {
|
||||
1,
|
||||
1,
|
||||
1,
|
||||
0,
|
||||
1,
|
||||
1,
|
||||
};
|
||||
char* text[] = {
|
||||
'\0',
|
||||
'\0',
|
||||
'\0',
|
||||
"test",
|
||||
"tes",
|
||||
"aaaaaaaaa",
|
||||
};
|
||||
int testcount = sizeof(pos) / sizeof(int);
|
||||
for (size_t i = 0; i < testcount; i++)
|
||||
{
|
||||
try
|
||||
{
|
||||
str[i].erase(pos[i], cnt[i]);
|
||||
Assert::AreEqual(text[i], str[i].c_str());
|
||||
}
|
||||
catch (const CMyStringException& e)
|
||||
{
|
||||
if (i < 3)
|
||||
{
|
||||
Assert::AreEqual(CMyStringException::ErrOutOfRange, e.what());
|
||||
}
|
||||
else
|
||||
{
|
||||
Assert::IsTrue(false);
|
||||
}
|
||||
}
|
||||
catch (...)
|
||||
{
|
||||
Assert::IsTrue(false);
|
||||
}
|
||||
}
|
||||
}
|
||||
TEST_METHOD(ShrinkToFitTests) {
|
||||
|
||||
}
|
||||
};
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue