From 8459c883f13074cb9ef3cb53f1120c10e5d49321 Mon Sep 17 00:00:00 2001 From: Roland Conybeare Date: Fri, 8 May 2026 08:19:31 -0400 Subject: [PATCH] xo-alloc2: tidy for ++ utest coverage --- .../include/xo/alloc2/alloc/AAllocator.hpp | 2 ++ .../xo/alloc2/alloc/IAllocator_Any.hpp | 2 ++ .../xo/alloc2/alloc/IAllocator_Xfer.hpp | 2 ++ xo-alloc2/utest/CMakeLists.txt | 1 + xo-alloc2/utest/VisitReason.test.cpp | 26 +++++++++++++++++++ xo-gc/src/gc/DX1Collector.cpp | 3 ++- xo-gc/utest/Collector.test.cpp | 2 ++ xo-gc/utest/DX1CollectorIterator.test.cpp | 2 ++ 8 files changed, 39 insertions(+), 1 deletion(-) create mode 100644 xo-alloc2/utest/VisitReason.test.cpp diff --git a/xo-alloc2/include/xo/alloc2/alloc/AAllocator.hpp b/xo-alloc2/include/xo/alloc2/alloc/AAllocator.hpp index 9d0966c7..7a940beb 100644 --- a/xo-alloc2/include/xo/alloc2/alloc/AAllocator.hpp +++ b/xo-alloc2/include/xo/alloc2/alloc/AAllocator.hpp @@ -159,11 +159,13 @@ namespace xo { * zero @p z. **/ virtual value_type sub_alloc(Opaque d, size_type z, bool complete_flag) const = 0; +#ifdef OBSOLETE /** Allocate copy of an existing object @p src. * Existing object must be contained in @p d. * NOTE: load bearing for copying garbage collector. **/ virtual value_type alloc_copy(Opaque d, value_type src) const = 0; +#endif /** reset allocator @p d to empty state. **/ virtual void clear(Opaque d) const = 0; /** assign helper for allocator that may require a write barrier diff --git a/xo-alloc2/include/xo/alloc2/alloc/IAllocator_Any.hpp b/xo-alloc2/include/xo/alloc2/alloc/IAllocator_Any.hpp index 0aafca45..06e7e584 100644 --- a/xo-alloc2/include/xo/alloc2/alloc/IAllocator_Any.hpp +++ b/xo-alloc2/include/xo/alloc2/alloc/IAllocator_Any.hpp @@ -58,7 +58,9 @@ namespace xo { [[noreturn]] value_type alloc(Opaque, typeseq, std::size_t) const override { _fatal(); } [[noreturn]] value_type super_alloc(Opaque, typeseq, std::size_t) const override { _fatal(); } [[noreturn]] value_type sub_alloc(Opaque, std::size_t, bool) const override { _fatal(); } +#ifdef OBSOLETE [[noreturn]] value_type alloc_copy(Opaque, value_type) const override { _fatal(); } +#endif [[noreturn]] void clear(Opaque) const override { _fatal(); } [[noreturn]] void barrier_assign_aux(Opaque, void *, diff --git a/xo-alloc2/include/xo/alloc2/alloc/IAllocator_Xfer.hpp b/xo-alloc2/include/xo/alloc2/alloc/IAllocator_Xfer.hpp index 3343559b..d2cd9504 100644 --- a/xo-alloc2/include/xo/alloc2/alloc/IAllocator_Xfer.hpp +++ b/xo-alloc2/include/xo/alloc2/alloc/IAllocator_Xfer.hpp @@ -75,8 +75,10 @@ namespace xo { bool complete_flag) const override { return I::sub_alloc(_dcast(d), z, complete_flag); } +#ifdef OBSOLETE value_type alloc_copy(Opaque d, value_type src) const override { return I::alloc_copy(_dcast(d), src); } +#endif void clear(Opaque d) const override { return I::clear(_dcast(d)); } void barrier_assign_aux(Opaque d, void * parent, diff --git a/xo-alloc2/utest/CMakeLists.txt b/xo-alloc2/utest/CMakeLists.txt index 33822241..9f9ece5f 100644 --- a/xo-alloc2/utest/CMakeLists.txt +++ b/xo-alloc2/utest/CMakeLists.txt @@ -10,6 +10,7 @@ set(UTEST_SRCS # Collector.test.cpp # DX1CollectorIterator.test.cpp Generation.test.cpp + VisitReason.test.cpp dp.test.cpp random_allocs.cpp ) diff --git a/xo-alloc2/utest/VisitReason.test.cpp b/xo-alloc2/utest/VisitReason.test.cpp new file mode 100644 index 00000000..ceef9a06 --- /dev/null +++ b/xo-alloc2/utest/VisitReason.test.cpp @@ -0,0 +1,26 @@ +/** @file VisitReason.test.cpp + * + * @author Roland Conybeare, May 2026 + **/ + +#include +#include + +namespace xo { + using xo::mm::VisitReason; + + namespace ut { + + TEST_CASE("visitreason-1", "[visitreason]") + { + REQUIRE(VisitReason::unspecified() == VisitReason::unspecified()); + + REQUIRE(VisitReason::unspecified() != VisitReason::forward()); + REQUIRE(VisitReason::unspecified() != VisitReason::verify()); + REQUIRE(VisitReason::forward() != VisitReason::verify()); + } + + } /*namespace ut*/ +} /*namespace xo*/ + +/* end VisitReason.test.cpp */ diff --git a/xo-gc/src/gc/DX1Collector.cpp b/xo-gc/src/gc/DX1Collector.cpp index 7ea97982..3eec1a71 100644 --- a/xo-gc/src/gc/DX1Collector.cpp +++ b/xo-gc/src/gc/DX1Collector.cpp @@ -607,7 +607,8 @@ namespace xo { auto DX1Collector::alloc_copy(value_type src) noexcept -> value_type { - return with_facet::mkobj(this->new_space()).alloc_copy(src); + return this->new_space()->alloc_copy(src); + //return with_facet::mkobj(this->new_space()).alloc_copy(src); } bool diff --git a/xo-gc/utest/Collector.test.cpp b/xo-gc/utest/Collector.test.cpp index ceb277b4..9141b576 100644 --- a/xo-gc/utest/Collector.test.cpp +++ b/xo-gc/utest/Collector.test.cpp @@ -29,6 +29,7 @@ namespace xo { using xo::mm::CollectorTypeRegistry; using xo::mm::AAllocator; using xo::mm::ACollector; + using xo::mm::ICollector_Any; using xo::mm::AGCObject; using xo::mm::X1CollectorConfig; using xo::mm::DX1Collector; @@ -59,6 +60,7 @@ namespace xo { REQUIRE(!gc1); REQUIRE(gc1.iface() != nullptr); REQUIRE(gc1.data() == nullptr); + REQUIRE(gc1._typeseq() == typeseq::id()); } TEST_CASE("DX1Collector-1", "[alloc2][gc][DX1Collector]") diff --git a/xo-gc/utest/DX1CollectorIterator.test.cpp b/xo-gc/utest/DX1CollectorIterator.test.cpp index 4d3ca6c2..e61c6a99 100644 --- a/xo-gc/utest/DX1CollectorIterator.test.cpp +++ b/xo-gc/utest/DX1CollectorIterator.test.cpp @@ -179,6 +179,8 @@ namespace xo { obj ix = range.begin(); obj end_ix = range.end(); + REQUIRE(ix._typeseq() == typeseq::id()); + REQUIRE(end_ix._typeseq() == typeseq::id()); REQUIRE(ix.iface()); REQUIRE(ix.data()); REQUIRE(end_ix.iface());