From 55e49a0b73622e2a2aa171f12f9c25b3d7df805b Mon Sep 17 00:00:00 2001 From: Arendelle Date: Thu, 9 Apr 2026 23:18:44 +0800 Subject: [PATCH 1/8] add constexpr to tests for vector(recursive.cc) - which matches production situation better. --- tests/0026.container/0001.vector/recursive.cc | 26 ++++++++++++++----- 1 file changed, 20 insertions(+), 6 deletions(-) diff --git a/tests/0026.container/0001.vector/recursive.cc b/tests/0026.container/0001.vector/recursive.cc index b23df0d2..bcedaf05 100644 --- a/tests/0026.container/0001.vector/recursive.cc +++ b/tests/0026.container/0001.vector/recursive.cc @@ -12,9 +12,12 @@ struct Node2 { fast_io::vector subast; - Node2(); - Node2(fast_io::vector sub); - ~Node2(); + constexpr Node2(); + constexpr Node2(fast_io::vector sub); + constexpr ~Node2(); + + template + constexpr int a_method(int) const noexcept; }; struct Base @@ -30,10 +33,16 @@ struct Base {} }; -Node2::Node2() = default; -Node2::Node2(fast_io::vector sub) : subast(std::move(sub)) +constexpr Node2::Node2() = default; +constexpr Node2::Node2(fast_io::vector sub) : subast(std::move(sub)) {} -Node2::~Node2() = default; +constexpr Node2::~Node2() = default; + +template +constexpr int Node2::a_method(int) const noexcept +{ + return 42; +} using Ast = fast_io::vector; @@ -58,6 +67,11 @@ int main() } else if constexpr (std::is_same_v) { + int const v{n.template a_method(0)}; + if (v != 42) + { + ::fast_io::fast_terminate(); + } } else if constexpr (std::is_same_v) { From 0305fd686bd6a5fcdab7eb3a538e4badbf659a37 Mon Sep 17 00:00:00 2001 From: Arendelle Date: Fri, 10 Apr 2026 00:17:46 +0800 Subject: [PATCH 2/8] Avoid disable all tests for fast_io::vector - fix test vector/reserve.cc --- tests/0026.container/.test_prop.toml | 2 - .../0001.vector/append_range.cc | 2 + tests/0026.container/0001.vector/assign.cc | 4 +- .../0001.vector/assign_range.cc | 2 + tests/0026.container/0001.vector/insert.cc | 3 +- .../0001.vector/insert_range.cc | 2 + tests/0026.container/0001.vector/max_size.cc | 4 +- tests/0026.container/0001.vector/reserve.cc | 40 +++++++++++++------ tests/0026.container/0001.vector/vector.cc | 7 ++-- 9 files changed, 45 insertions(+), 21 deletions(-) delete mode 100644 tests/0026.container/.test_prop.toml diff --git a/tests/0026.container/.test_prop.toml b/tests/0026.container/.test_prop.toml deleted file mode 100644 index d35a4c16..00000000 --- a/tests/0026.container/.test_prop.toml +++ /dev/null @@ -1,2 +0,0 @@ -["0001.vector"] # TODO: vector no longer available -ignore = true diff --git a/tests/0026.container/0001.vector/append_range.cc b/tests/0026.container/0001.vector/append_range.cc index b15b08c2..a71a49dc 100644 --- a/tests/0026.container/0001.vector/append_range.cc +++ b/tests/0026.container/0001.vector/append_range.cc @@ -8,8 +8,10 @@ using namespace fast_io::mnp; int main() { +#if 0 auto head = fast_io::vector{1, 2, 3, 4}; auto const tail = std::list{-5, -6, -7}; head.append_range(tail); assert(std::ranges::equal(head, fast_io::vector{1, 2, 3, 4, -5, -6, -7})); +#endif } \ No newline at end of file diff --git a/tests/0026.container/0001.vector/assign.cc b/tests/0026.container/0001.vector/assign.cc index c993ce2e..8a182fa3 100644 --- a/tests/0026.container/0001.vector/assign.cc +++ b/tests/0026.container/0001.vector/assign.cc @@ -20,10 +20,12 @@ int main() characters.assign(5, 'a'); print_vector(); +#if 0 std::string const extra(6, 'b'); characters.assign(extra.begin(), extra.end()); print_vector(); characters.assign({'C', '+', '+', '1', '1'}); print_vector(); -} \ No newline at end of file +#endif +} diff --git a/tests/0026.container/0001.vector/assign_range.cc b/tests/0026.container/0001.vector/assign_range.cc index 3a637275..7366eb68 100644 --- a/tests/0026.container/0001.vector/assign_range.cc +++ b/tests/0026.container/0001.vector/assign_range.cc @@ -6,8 +6,10 @@ int main() { +#if 0 auto const source = std::list{2, 7, 1}; auto destination = fast_io::vector{3, 1, 4}; destination.assign_range(source); assert(std::ranges::equal(source, destination)); +#endif } \ No newline at end of file diff --git a/tests/0026.container/0001.vector/insert.cc b/tests/0026.container/0001.vector/insert.cc index e4ed7e23..c7b1864a 100644 --- a/tests/0026.container/0001.vector/insert.cc +++ b/tests/0026.container/0001.vector/insert.cc @@ -17,7 +17,7 @@ int main() auto it = c1.begin(); it = c1.insert(it, 200); print_info(2, c1); - +#if 0 c1.insert(it, 2, 300); print_info(3, c1); @@ -34,4 +34,5 @@ int main() c1.insert(c1.end(), {601, 602, 603}); print_info(6, c1); +#endif } \ No newline at end of file diff --git a/tests/0026.container/0001.vector/insert_range.cc b/tests/0026.container/0001.vector/insert_range.cc index a3eec701..105c8781 100644 --- a/tests/0026.container/0001.vector/insert_range.cc +++ b/tests/0026.container/0001.vector/insert_range.cc @@ -9,6 +9,7 @@ using namespace fast_io::mnp; int main() { +#if 0 auto container = fast_io::vector{1, 2, 3, 4}; auto pos = std::next(container.begin(), 2); assert(*pos == 3); @@ -16,4 +17,5 @@ int main() container.insert_range(pos, rg); assert(std::ranges::equal(container, fast_io::vector{1, 2, -1, -2, -3, 3, 4})); +#endif } \ No newline at end of file diff --git a/tests/0026.container/0001.vector/max_size.cc b/tests/0026.container/0001.vector/max_size.cc index fe044304..f6a00710 100644 --- a/tests/0026.container/0001.vector/max_size.cc +++ b/tests/0026.container/0001.vector/max_size.cc @@ -1,12 +1,14 @@ #include -#include +// #include #include using namespace fast_io::io; using namespace fast_io::mnp; int main() { +#if 0 fast_io::vector q; fast_io::native_l10n l10n{"en_US.UTF-8"}; println(imbue(l10n, fast_io::c_stdout()), "Maximum size of a std::vector is ", q.max_size()); +#endif } \ No newline at end of file diff --git a/tests/0026.container/0001.vector/reserve.cc b/tests/0026.container/0001.vector/reserve.cc index 34dd17ce..79249a81 100644 --- a/tests/0026.container/0001.vector/reserve.cc +++ b/tests/0026.container/0001.vector/reserve.cc @@ -11,43 +11,57 @@ struct NAlloc static void *allocate(std::size_t n) { void *p = ::operator new(n); - println("allocating ", n, " bytes @ ", pointervw(p)); return p; } - static void deallocate_n(void *p, std::size_t n) + static void deallocate_n(void *p, std::size_t) { - print("deallocating ", n, " bytes @ ", pointervw(p), "\n\n"); ::operator delete(p); } - constexpr bool operator==(NAlloc const &) const noexcept = default; + static void deallocate(void *p) + { + ::operator delete(p); + } + constexpr bool operator==(::NAlloc const &) const noexcept = default; }; +using NAllocAdapter = fast_io::generic_allocator_adapter; + int main() { constexpr int max_elements = 32; - print("using reserve: \n"); + // using reserve { - fast_io::vector v1; + fast_io::vector v1; v1.reserve(max_elements); // reserves at least max_elements * sizeof(int) bytes for (int n = 0; n < max_elements; ++n) { v1.push_back(n); } + for (int n = 0; n < max_elements; ++n) + { + int v{v1[n]}; + if (v != n) { + ::fast_io::fast_terminate(); + } + } } - print("not using reserve: \n"); + // not using reserve { - fast_io::vector v1; + fast_io::vector v1; for (int n = 0; n < max_elements; ++n) { - if (v1.size() == v1.capacity()) - { - println("size() == capacity() == ", v1.size()); - } v1.push_back(n); } + for (int n = 0; n < max_elements; ++n) + { + int v{v1[n]}; + if (v != n) { + ::fast_io::fast_terminate(); + } + } } -} \ No newline at end of file +} diff --git a/tests/0026.container/0001.vector/vector.cc b/tests/0026.container/0001.vector/vector.cc index b9d7f9e5..c2063d94 100644 --- a/tests/0026.container/0001.vector/vector.cc +++ b/tests/0026.container/0001.vector/vector.cc @@ -9,11 +9,11 @@ int main() // C++11 initializer list syntax: fast_io::vector words1{"the", "frogurt", "is", "also", "cursed"}; print("1: {", rgvw(words1, ", "), "}\n"); - +#if 0 // words2 == words1 fast_io::vector words2(::std::from_range, words1); print("2: {", rgvw(words2, ", "), "}\n"); - +#endif // words3 == words1 fast_io::vector words3(words1); print("3: {", rgvw(words3, ", "), "}\n"); @@ -21,8 +21,9 @@ int main() // words4 is {"Mo", "Mo", "Mo", "Mo", "Mo"} fast_io::vector words4(5, "Mo"); print("4: {", rgvw(words4, ", "), "}\n"); - +#if 0 auto const rg = {"cat", "cow", "crow"}; fast_io::vector words5(::std::from_range, rg); // overload (11) print("5: {", rgvw(words5, ", "), "}\n"); +#endif } \ No newline at end of file From 7442740494920561574451f1630adf86692cbdf7 Mon Sep 17 00:00:00 2001 From: Arendelle Date: Fri, 10 Apr 2026 00:25:38 +0800 Subject: [PATCH 3/8] Disable operator_assign --- tests/0026.container/0001.vector/operator_assign.cc | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/tests/0026.container/0001.vector/operator_assign.cc b/tests/0026.container/0001.vector/operator_assign.cc index 171a62cb..1839fda7 100644 --- a/tests/0026.container/0001.vector/operator_assign.cc +++ b/tests/0026.container/0001.vector/operator_assign.cc @@ -8,7 +8,6 @@ using namespace fast_io::mnp; int main() { fast_io::vector x{1, 2, 3}, y, z; - auto const w = {4, 5, 6, 7}; print("Initially:\n"); print("x = {", rgvw(x, ", "), "}\ny = {", rgvw(y, ", "), "}\nz = {", rgvw(z, ", "), "}\n"); @@ -21,7 +20,11 @@ int main() z = std::move(x); print("x = {", rgvw(x, ", "), "}\nz = {", rgvw(z, ", "), "}\n"); +#if 0 + auto const w = {4, 5, 6, 7}; + print("Assignment of initializer_list w to z:\n"); z = w; print("w = {", rgvw(w, ", "), "}\nz = {", rgvw(z, ", "), "}\n"); +#endif } From 70a678a29fe37d3c134d74ddf98fb6920d5bc7ac Mon Sep 17 00:00:00 2001 From: Arendelle Date: Fri, 10 Apr 2026 00:27:03 +0800 Subject: [PATCH 4/8] add missing noexcept for NAlloc in test reserve.cc --- tests/0026.container/0001.vector/reserve.cc | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/tests/0026.container/0001.vector/reserve.cc b/tests/0026.container/0001.vector/reserve.cc index 79249a81..6433cd66 100644 --- a/tests/0026.container/0001.vector/reserve.cc +++ b/tests/0026.container/0001.vector/reserve.cc @@ -8,16 +8,16 @@ using namespace fast_io::mnp; // minimal allocator with debug output struct NAlloc { - static void *allocate(std::size_t n) + static void *allocate(std::size_t n) noexcept { void *p = ::operator new(n); return p; } - static void deallocate_n(void *p, std::size_t) + static void deallocate_n(void *p, std::size_t) noexcept { ::operator delete(p); } - static void deallocate(void *p) + static void deallocate(void *p) noexcept { ::operator delete(p); } From abc9722e5c5b4f565aac33679255b4c3691d9c56 Mon Sep 17 00:00:00 2001 From: Arendelle Date: Fri, 10 Apr 2026 00:33:32 +0800 Subject: [PATCH 5/8] fix implicit conversion issue inside capacity.cc --- tests/0026.container/0001.vector/capacity.cc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/0026.container/0001.vector/capacity.cc b/tests/0026.container/0001.vector/capacity.cc index b1241510..969b289d 100644 --- a/tests/0026.container/0001.vector/capacity.cc +++ b/tests/0026.container/0001.vector/capacity.cc @@ -18,10 +18,10 @@ int main() v.push_back(sz); if (cap != v.capacity()) { - println(left(v.size(), 7), left(v.capacity(), 11), left(v.capacity() / static_cast(cap), 10)); + println(left(v.size(), 7), left(v.capacity(), 11), left(float(v.capacity()) / static_cast(cap), 10)); cap = v.capacity(); } } println("\nFinal size: ", v.size(), ", capacity: ", v.capacity()); -} \ No newline at end of file +} From c0d83ecb52c542be5fc92b0931972970306dd3fa Mon Sep 17 00:00:00 2001 From: Arendelle Date: Fri, 10 Apr 2026 00:39:34 +0800 Subject: [PATCH 6/8] fix test resize.cc --- tests/0026.container/0001.vector/resize.cc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/0026.container/0001.vector/resize.cc b/tests/0026.container/0001.vector/resize.cc index fd5224c3..2e233b86 100644 --- a/tests/0026.container/0001.vector/resize.cc +++ b/tests/0026.container/0001.vector/resize.cc @@ -10,7 +10,7 @@ void print_info(auto rem, fast_io::vector const &c) int main() { - fast_io::vector c = {1, 2, 3}; + fast_io::vector c{1, 2, 3}; print_info("The vector holds: ", c); c.resize(5); @@ -21,4 +21,4 @@ int main() c.resize(6, 4); print_info("After resize up to 6 (initializer = 4): ", c); -} \ No newline at end of file +} From 82004d9c24dfac7a8d666bf068ff147ee3c8c4c3 Mon Sep 17 00:00:00 2001 From: Arendelle Date: Fri, 10 Apr 2026 00:46:22 +0800 Subject: [PATCH 7/8] fix unused variable --- tests/0026.container/0001.vector/emplace_back.cc | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/tests/0026.container/0001.vector/emplace_back.cc b/tests/0026.container/0001.vector/emplace_back.cc index 89e2607f..11ad7a89 100644 --- a/tests/0026.container/0001.vector/emplace_back.cc +++ b/tests/0026.container/0001.vector/emplace_back.cc @@ -1,5 +1,4 @@ -#include -#include +#include #include #include using namespace fast_io::io; @@ -31,7 +30,11 @@ int main() fast_io::vector elections; print("emplace_back:\n"); auto &ref = elections.emplace_back("Nelson Mandela", "South Africa", 1994); - assert(ref.year == 1994 && "uses a reference to the created object (C++17)"); + // assert(ref.year == 1994 && "uses a reference to the created object (C++17)"); + if (ref.year != 1994) + { + ::fast_io::fast_terminate(); + } fast_io::vector reElections; print("\npush_back:\n"); From fe539aa196f6db1527367a92b2f0bc5f84145c0c Mon Sep 17 00:00:00 2001 From: Arendelle Date: Fri, 10 Apr 2026 00:46:39 +0800 Subject: [PATCH 8/8] remove notes --- tests/0026.container/0001.vector/emplace_back.cc | 1 - 1 file changed, 1 deletion(-) diff --git a/tests/0026.container/0001.vector/emplace_back.cc b/tests/0026.container/0001.vector/emplace_back.cc index 11ad7a89..c8595eac 100644 --- a/tests/0026.container/0001.vector/emplace_back.cc +++ b/tests/0026.container/0001.vector/emplace_back.cc @@ -30,7 +30,6 @@ int main() fast_io::vector elections; print("emplace_back:\n"); auto &ref = elections.emplace_back("Nelson Mandela", "South Africa", 1994); - // assert(ref.year == 1994 && "uses a reference to the created object (C++17)"); if (ref.year != 1994) { ::fast_io::fast_terminate();