From 3d5a45b283d2a59211f9e24f100b95169375213d Mon Sep 17 00:00:00 2001 From: Steven Le Rouzic Date: Tue, 4 Feb 2025 00:37:08 +0100 Subject: Add deref utilities & use them for log writer --- asl/tests/meta_tests.cpp | 40 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) (limited to 'asl/tests') diff --git a/asl/tests/meta_tests.cpp b/asl/tests/meta_tests.cpp index f01258a..5026327 100644 --- a/asl/tests/meta_tests.cpp +++ b/asl/tests/meta_tests.cpp @@ -1,5 +1,7 @@ #include "asl/meta.hpp" #include "asl/tests/test_types.hpp" +#include "asl/testing/testing.hpp" +#include "asl/box.hpp" struct Struct {}; union Union {}; @@ -247,3 +249,41 @@ static_assert(!asl::is_enum); static_assert(asl::is_enum); static_assert(asl::is_enum); +static_assert(asl::derefs_as); +static_assert(asl::derefs_as); +static_assert(asl::derefs_as); +static_assert(asl::derefs_as, int>); + +static_assert(asl::derefs_as); +static_assert(asl::derefs_as); +static_assert(asl::derefs_as); +static_assert(asl::derefs_as, Base>); + +static void wants_int(int) {} +static void wants_base(Base&) {} +static void wants_base_ptr(Base*) {} + +ASL_TEST(deref) +{ + int a = 4; + auto b = asl::make_box(5); + + wants_int(asl::deref(5)); + wants_int(asl::deref(a)); + wants_int(asl::deref(&a)); + wants_int(asl::deref(b)); + + Derived c{}; + auto d = asl::make_box(); + + wants_base(asl::deref(Derived{})); + wants_base(asl::deref(c)); + wants_base(asl::deref(&c)); + wants_base(asl::deref(d)); + + wants_base_ptr(&asl::deref(Derived{})); + wants_base_ptr(&asl::deref(c)); + wants_base_ptr(&asl::deref(&c)); + wants_base_ptr(&asl::deref(d)); +} + -- cgit