#include #include TestResult test_vector_empty_capacity() { Vector v; validate(v.capacity() == 0); test_success; } TestResult test_vector_reserve_should_raise_capacity() { Vector v; validate(v.capacity() == 0); TRY(v.try_reserve(8)); validate(v.capacity() == 8); test_success; } TestResult test_vector_append_should_raise_capacity() { Vector v; TRY(v.try_append('c')); validate(v.capacity() > 0); validate(v.size() == 1); test_success; } TestResult test_vector_pop_should_remove_last_element() { Vector v; TRY(v.try_append('c')); validate(v.capacity() > 0); validate(v.size() == 1); auto value = v.try_pop(); validate(value.has_value()); validate(value.value() == 'c'); validate(v.size() == 0); test_success; } TestResult test_empty_vector_pop_should_not_remove_anything() { Vector v; validate(v.size() == 0); auto value = v.try_pop(); validate(!value.has_value()); validate(v.size() == 0); test_success; } TestResult test_vector_clear_should_free_memory() { Vector v; TRY(v.try_append('a')); TRY(v.try_append('b')); validate(v.size() == 2); v.clear(); validate(v.size() == 0); validate(v.capacity() == 0); test_success; } Result test_main() { test_prelude; run_test(test_vector_empty_capacity); run_test(test_vector_reserve_should_raise_capacity); run_test(test_vector_append_should_raise_capacity); run_test(test_vector_pop_should_remove_last_element); run_test(test_empty_vector_pop_should_not_remove_anything); run_test(test_vector_clear_should_free_memory); return {}; }