From 7226b7aea6acff914e365f103609bcd693607474 Mon Sep 17 00:00:00 2001 From: Imbus <> Date: Sat, 11 Jan 2025 17:33:21 +0100 Subject: [PATCH] Better tests --- vector/main.cc | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-) diff --git a/vector/main.cc b/vector/main.cc index 45717a2..7f63eb1 100644 --- a/vector/main.cc +++ b/vector/main.cc @@ -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; }