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/status_or_tests.cpp | 168 +++++++++++++++++++++--------------------- 1 file changed, 84 insertions(+), 84 deletions(-) (limited to 'asl/tests/status_or_tests.cpp') diff --git a/asl/tests/status_or_tests.cpp b/asl/tests/status_or_tests.cpp index e792270..2f3f475 100644 --- a/asl/tests/status_or_tests.cpp +++ b/asl/tests/status_or_tests.cpp @@ -1,84 +1,84 @@ -#include "asl/status_or.hpp" -#include "asl/testing/testing.hpp" -#include "asl/tests/test_types.hpp" - -static_assert(asl::copyable>); -static_assert(asl::moveable>); - -static_assert(asl::copyable>); -static_assert(asl::moveable>); - -static_assert(!asl::copyable>); -static_assert(asl::moveable>); - -static_assert(!asl::copyable>); -static_assert(!asl::moveable>); - -ASL_TEST(ok) -{ - asl::status_or s = 6; - ASL_TEST_EXPECT(s.ok()); - ASL_TEST_EXPECT(s.code() == asl::status_code::ok); -} - -ASL_TEST(from_status) -{ - asl::status_or s = asl::internal_error(); - ASL_TEST_EXPECT(!s.ok()); - ASL_TEST_EXPECT(s.code() == asl::status_code::internal); - ASL_TEST_EXPECT(s.message() == ""_sv); - - asl::status_or s2 = asl::internal_error("oh no"); - ASL_TEST_EXPECT(!s2.ok()); - ASL_TEST_EXPECT(s2.code() == asl::status_code::internal); - ASL_TEST_EXPECT(s2.message() == "oh no"_sv); - - asl::status_or s3 = asl::internal_error("{} {}", 1, 2); - ASL_TEST_EXPECT(!s3.ok()); - ASL_TEST_EXPECT(s3.code() == asl::status_code::internal); - ASL_TEST_EXPECT(s3.message() == "1 2"_sv); -} - -ASL_TEST(destructor) -{ - bool d = false; - - { - asl::status_or s{&d}; - ASL_TEST_EXPECT(s.ok()); - ASL_TEST_EXPECT(!d); - - asl::status_or s2 = ASL_MOVE(s); - ASL_TEST_EXPECT(s.ok()); - ASL_TEST_EXPECT(!d); - - s = ASL_MOVE(s2); - ASL_TEST_EXPECT(s.ok()); - ASL_TEST_EXPECT(!d); - } - - ASL_TEST_EXPECT(d); -} - -ASL_TEST(copy) -{ - asl::status_or s = 7; - asl::status_or s2 = s; - s = s2; - - ASL_TEST_EXPECT(s.ok()); - ASL_TEST_EXPECT(s2.ok()); - - ASL_TEST_EXPECT(s.value() == 7); - ASL_TEST_EXPECT(s2.value() == 7); -} - -ASL_TEST(value_or) -{ - asl::status_or s = 7; - asl::status_or s2 = asl::internal_error(); - - ASL_TEST_EXPECT(s.value_or(45) == 7); - ASL_TEST_EXPECT(s2.value_or(45) == 45); -} - +#include "asl/status_or.hpp" +#include "asl/testing/testing.hpp" +#include "asl/tests/test_types.hpp" + +static_assert(asl::copyable>); +static_assert(asl::moveable>); + +static_assert(asl::copyable>); +static_assert(asl::moveable>); + +static_assert(!asl::copyable>); +static_assert(asl::moveable>); + +static_assert(!asl::copyable>); +static_assert(!asl::moveable>); + +ASL_TEST(ok) +{ + asl::status_or s = 6; + ASL_TEST_EXPECT(s.ok()); + ASL_TEST_EXPECT(s.code() == asl::status_code::ok); +} + +ASL_TEST(from_status) +{ + asl::status_or s = asl::internal_error(); + ASL_TEST_EXPECT(!s.ok()); + ASL_TEST_EXPECT(s.code() == asl::status_code::internal); + ASL_TEST_EXPECT(s.message() == ""_sv); + + asl::status_or s2 = asl::internal_error("oh no"); + ASL_TEST_EXPECT(!s2.ok()); + ASL_TEST_EXPECT(s2.code() == asl::status_code::internal); + ASL_TEST_EXPECT(s2.message() == "oh no"_sv); + + asl::status_or s3 = asl::internal_error("{} {}", 1, 2); + ASL_TEST_EXPECT(!s3.ok()); + ASL_TEST_EXPECT(s3.code() == asl::status_code::internal); + ASL_TEST_EXPECT(s3.message() == "1 2"_sv); +} + +ASL_TEST(destructor) +{ + bool d = false; + + { + asl::status_or s{&d}; + ASL_TEST_EXPECT(s.ok()); + ASL_TEST_EXPECT(!d); + + asl::status_or s2 = ASL_MOVE(s); + ASL_TEST_EXPECT(s.ok()); + ASL_TEST_EXPECT(!d); + + s = ASL_MOVE(s2); + ASL_TEST_EXPECT(s.ok()); + ASL_TEST_EXPECT(!d); + } + + ASL_TEST_EXPECT(d); +} + +ASL_TEST(copy) +{ + asl::status_or s = 7; + asl::status_or s2 = s; + s = s2; + + ASL_TEST_EXPECT(s.ok()); + ASL_TEST_EXPECT(s2.ok()); + + ASL_TEST_EXPECT(s.value() == 7); + ASL_TEST_EXPECT(s2.value() == 7); +} + +ASL_TEST(value_or) +{ + asl::status_or s = 7; + asl::status_or s2 = asl::internal_error(); + + ASL_TEST_EXPECT(s.value_or(45) == 7); + ASL_TEST_EXPECT(s2.value_or(45) == 45); +} + -- cgit