From df86cef2b1f9dac5119f39884e97d6f5f83e8633 Mon Sep 17 00:00:00 2001 From: Roland Conybeare Date: Mon, 26 Jan 2026 16:56:35 -0500 Subject: [PATCH] xo-procedure2: + DSimpleRcx utest --- include/xo/procedure2/DSimpleRcx.hpp | 2 + utest/CMakeLists.txt | 1 + utest/DSimpleRcx.test.cpp | 60 ++++++++++++++++++++++++++++ 3 files changed, 63 insertions(+) create mode 100644 utest/DSimpleRcx.test.cpp diff --git a/include/xo/procedure2/DSimpleRcx.hpp b/include/xo/procedure2/DSimpleRcx.hpp index d5060bb..bd52dcc 100644 --- a/include/xo/procedure2/DSimpleRcx.hpp +++ b/include/xo/procedure2/DSimpleRcx.hpp @@ -3,6 +3,8 @@ * @author Roland Conybeare, Jan 2026 **/ +#pragma once + #include namespace xo { diff --git a/utest/CMakeLists.txt b/utest/CMakeLists.txt index 2e5f147..e758d28 100644 --- a/utest/CMakeLists.txt +++ b/utest/CMakeLists.txt @@ -4,6 +4,7 @@ set(UTEST_EXE utest.procedure2) set(UTEST_SRCS procedure2_utest_main.cpp DPrimitive.test.cpp + DSimpleRcx.test.cpp ) xo_add_utest_executable(${UTEST_EXE} ${UTEST_SRCS}) diff --git a/utest/DSimpleRcx.test.cpp b/utest/DSimpleRcx.test.cpp new file mode 100644 index 0000000..cab1362 --- /dev/null +++ b/utest/DSimpleRcx.test.cpp @@ -0,0 +1,60 @@ +/** @file DSimpleRcx.test.cpp + * + * @author Roland Conybeare, Jan 2026 + **/ + +#include +#include +#include +#include +#include + +namespace xo { + using xo::scm::DSimpleRcx; + using xo::scm::ARuntimeContext; + using xo::mm::AAllocator; + using xo::mm::DArena; + using xo::mm::ArenaConfig; + using xo::facet::with_facet; + using xo::facet::obj; + + namespace ut { + static InitEvidence s_init = InitSubsys::require(); + + TEST_CASE("DSimpleRcx-init", "[procedure2][DSimpleRcx]") + { + REQUIRE(s_init.evidence()); + } + + TEST_CASE("DSimpleRcx-construct", "[procedure2][DSimpleRcx]") + { + ArenaConfig cfg { .name_ = "testarena", + .size_ = 4*1024 }; + DArena arena = DArena::map(cfg); + auto alloc = with_facet::mkobj(&arena); + + DSimpleRcx rcx(alloc); + + REQUIRE((void*)rcx.allocator().data() == (void*)alloc.data()); + } + + TEST_CASE("DSimpleRcx-as-ARuntimeContext", "[procedure2][DSimpleRcx]") + { + ArenaConfig cfg { .name_ = "testarena", + .size_ = 4*1024 }; + DArena arena = DArena::map(cfg); + auto alloc = with_facet::mkobj(&arena); + + DSimpleRcx rcx(alloc); + obj rcx_obj = with_facet::mkobj(&rcx); + + // verify we can recover allocator from obj + obj recovered_alloc = rcx_obj.allocator(); + + REQUIRE((void*)recovered_alloc.data() == (void*)alloc.data()); + } + + } /*namespace ut*/ +} /*namespace xo*/ + +/* end DSimpleRcx.test.cpp */