From cf7db48c261ee9c896c813a38ff8c59da5b8fe07 Mon Sep 17 00:00:00 2001 From: Steven Le Rouzic Date: Sun, 26 Jan 2025 00:40:51 +0100 Subject: Fix line endings --- asl/tests/box_tests.cpp | 156 ++++++++++++++++++++++++------------------------ 1 file changed, 78 insertions(+), 78 deletions(-) (limited to 'asl/tests/box_tests.cpp') diff --git a/asl/tests/box_tests.cpp b/asl/tests/box_tests.cpp index 0395e5f..edb574c 100644 --- a/asl/tests/box_tests.cpp +++ b/asl/tests/box_tests.cpp @@ -1,78 +1,78 @@ -#include "asl/box.hpp" -#include "asl/option.hpp" - -#include "asl/testing/testing.hpp" -#include "asl/tests/test_types.hpp" - -static_assert(sizeof(asl::box) == sizeof(int*)); -static_assert(!asl::copyable>); -static_assert(asl::moveable>); -static_assert(asl::has_niche>); -static_assert(sizeof(asl::option>) == sizeof(int*)); - -ASL_TEST(destructor) -{ - bool d = false; - - { - auto box = asl::make_box(&d); - ASL_TEST_ASSERT(!d); - - - auto box3 = ASL_MOVE(box); - ASL_TEST_ASSERT(!d); - } - - ASL_TEST_ASSERT(d); -} - -ASL_TEST(value) -{ - auto b = asl::make_box(24); - ASL_TEST_EXPECT(*b == 24); - - auto b2 = ASL_MOVE(b); - ASL_TEST_EXPECT(*b2 == 24); -} - -ASL_TEST(ptr) -{ - auto b = asl::make_box(24); - auto* ptr1 = b.get(); - - auto b2 = ASL_MOVE(b); - auto* ptr2 = b2.get(); - ASL_TEST_EXPECT(ptr1 == ptr2); -} - -struct Struct { int a; }; - -ASL_TEST(arrow) -{ - auto b = asl::make_box(45); - ASL_TEST_EXPECT(b->a == 45); -} - -ASL_TEST(niche) -{ - static_assert(sizeof(asl::box) == sizeof(asl::option>)); - - asl::option> opt; - ASL_TEST_EXPECT(!opt.has_value()); - - opt = asl::make_box(66); - ASL_TEST_EXPECT(opt.has_value()); - ASL_TEST_EXPECT(*opt.value() == 66); - - opt = asl::nullopt; - ASL_TEST_EXPECT(!opt.has_value()); - - bool destroyed = false; - asl::option opt2 = asl::make_box(&destroyed); - ASL_TEST_EXPECT(opt2.has_value()); - ASL_TEST_EXPECT(!destroyed); - - opt2.reset(); - ASL_TEST_EXPECT(!opt2.has_value()); - ASL_TEST_EXPECT(destroyed); -} +#include "asl/box.hpp" +#include "asl/option.hpp" + +#include "asl/testing/testing.hpp" +#include "asl/tests/test_types.hpp" + +static_assert(sizeof(asl::box) == sizeof(int*)); +static_assert(!asl::copyable>); +static_assert(asl::moveable>); +static_assert(asl::has_niche>); +static_assert(sizeof(asl::option>) == sizeof(int*)); + +ASL_TEST(destructor) +{ + bool d = false; + + { + auto box = asl::make_box(&d); + ASL_TEST_ASSERT(!d); + + + auto box3 = ASL_MOVE(box); + ASL_TEST_ASSERT(!d); + } + + ASL_TEST_ASSERT(d); +} + +ASL_TEST(value) +{ + auto b = asl::make_box(24); + ASL_TEST_EXPECT(*b == 24); + + auto b2 = ASL_MOVE(b); + ASL_TEST_EXPECT(*b2 == 24); +} + +ASL_TEST(ptr) +{ + auto b = asl::make_box(24); + auto* ptr1 = b.get(); + + auto b2 = ASL_MOVE(b); + auto* ptr2 = b2.get(); + ASL_TEST_EXPECT(ptr1 == ptr2); +} + +struct Struct { int a; }; + +ASL_TEST(arrow) +{ + auto b = asl::make_box(45); + ASL_TEST_EXPECT(b->a == 45); +} + +ASL_TEST(niche) +{ + static_assert(sizeof(asl::box) == sizeof(asl::option>)); + + asl::option> opt; + ASL_TEST_EXPECT(!opt.has_value()); + + opt = asl::make_box(66); + ASL_TEST_EXPECT(opt.has_value()); + ASL_TEST_EXPECT(*opt.value() == 66); + + opt = asl::nullopt; + ASL_TEST_EXPECT(!opt.has_value()); + + bool destroyed = false; + asl::option opt2 = asl::make_box(&destroyed); + ASL_TEST_EXPECT(opt2.has_value()); + ASL_TEST_EXPECT(!destroyed); + + opt2.reset(); + ASL_TEST_EXPECT(!opt2.has_value()); + ASL_TEST_EXPECT(destroyed); +} -- cgit