xo-type: + DAtomicType [WIP]

This commit is contained in:
Roland Conybeare 2026-03-06 13:04:31 +11:00
commit c9944a27aa
31 changed files with 1262 additions and 0 deletions

16
utest/CMakeLists.txt Normal file
View file

@ -0,0 +1,16 @@
# built unittest xo-type/utest
set(UTEST_EXE utest.type)
set(UTEST_SRCS
type_utest_main.cpp
DAtomicType.test.cpp
# DString.test.cpp
# StringOps.test.cpp
# X1Collector.test.cpp
# Printable.test.cpp
)
xo_add_utest_executable(${UTEST_EXE} ${UTEST_SRCS})
xo_self_dependency(${UTEST_EXE} xo_type)
#xo_dependency(${UTEST_EXE} xo_alloc2)
xo_external_target_dependency(${UTEST_EXE} Catch2 Catch2::Catch2)

View file

@ -0,0 +1,40 @@
/** @file DAtomicType.test.cpp
*
* @author Roland Conybeare, Mar 2026
**/
#include "init_type.hpp"
#include "AtomicType.hpp"
#include <xo/alloc2/Allocator.hpp>
#include <xo/alloc2/Arena.hpp>
#include <xo/facet/obj.hpp>
#include <catch2/catch.hpp>
namespace xo {
using xo::scm::AType;
using xo::scm::DAtomicType;
using xo::scm::Metatype;
using xo::mm::AAllocator;
using xo::mm::DArena;
using xo::mm::ArenaConfig;
namespace ut {
static InitEvidence s_init = (InitSubsys<S_type_tag>::require());
TEST_CASE("DAtomicType-make", "[type][DAtomicType]")
{
ArenaConfig cfg { .name_ = "testarena",
.size_ = 4*1024 };
DArena arena = DArena::map(cfg);
auto alloc = obj<AAllocator,DArena>(&arena);
auto f64_type = obj<AType,DAtomicType>(DAtomicType::_make(alloc, Metatype::unit()));
REQUIRE(f64_type);
REQUIRE(f64_type.metatype().code() == Metatype::unit().code());
}
} /*namespace ut*/
} /*namespace xo*/
/* end DAtomicType.test.cpp */

24
utest/type_utest_main.cpp Normal file
View file

@ -0,0 +1,24 @@
/* file type_utest_main.cpp */
#include <xo/subsys/Subsystem.hpp>
#define CATCH_CONFIG_RUNNER
#include "catch2/catch.hpp"
int
main(int argc, char* argv[])
{
using xo::Subsystem;
// Your custom initialization code here
Subsystem::initialize_all();
// Run Catch2's test session
int result = Catch::Session().run(argc, argv);
// cleanup here, if any
return result;
}
/* end type_utest_main.cpp */