Better tests
This commit is contained in:
parent
91bf5ecec0
commit
7226b7aea6
1 changed files with 13 additions and 8 deletions
|
@ -9,21 +9,26 @@ int main() {
|
|||
|
||||
Vec v;
|
||||
v.push_back(10);
|
||||
ASSERT_MSG(v[0] == 10, "10 should be present at index 0");
|
||||
int a = v[0];
|
||||
ASSERT_EQMSG(10, a, "10 should be present at index 0");
|
||||
|
||||
Vec v2{1, 2, 3};
|
||||
ASSERT_MSG(v2.size() == 3, "Size should be three");
|
||||
ASSERT_EQ(3, v2.size());
|
||||
ASSERT_EQMSG(v2.size(), 3, "Size should be three");
|
||||
v2.pop_back();
|
||||
ASSERT_EQ(2, v2.size());
|
||||
ASSERT_MSG(v2.size() == 2, "Size should be three");
|
||||
|
||||
// Triggers a reallocation (memcpy)
|
||||
Vec v3{1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12};
|
||||
ASSERT_MSG(v3[11] == 12, "Index 11 should hold 12");
|
||||
// ASSERT_MSG(v3[5] == 6, "Index 5 should hold 6"); // ???
|
||||
ASSERT_MSG(v3.size() == 12, "Size should be 12");
|
||||
ASSERT_MSG(v3.capacity() == 20, "Capacity should be 20");
|
||||
ASSERT_MSG(v3[5] == 6, "Index 5 should hold 6"); // ???
|
||||
ASSERT_EQ(12, v3.size());
|
||||
ASSERT_EQ(24, v3.capacity());
|
||||
|
||||
for (const auto &a : v3) {
|
||||
std::cout << a << std::endl;
|
||||
}
|
||||
Vec v_sized(40);
|
||||
v_sized.push_back(0);
|
||||
ASSERT_MSG(v_sized[0] == 0, "Well");
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue