From afd8e711ab35e8d21bc9c8397f31dcf7ecdec2e3 Mon Sep 17 00:00:00 2001 From: Steven Le Rouzic Date: Sat, 2 Nov 2024 18:25:11 +0100 Subject: Add value_or on option --- asl/tests/option_tests.cpp | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'asl/tests') diff --git a/asl/tests/option_tests.cpp b/asl/tests/option_tests.cpp index dea046e..ec6e957 100644 --- a/asl/tests/option_tests.cpp +++ b/asl/tests/option_tests.cpp @@ -189,3 +189,12 @@ ASL_TEST(convert_move) ASL_TEST_EXPECT(opt16.has_value()); ASL_TEST_EXPECT(opt16.value() == 10); } + +ASL_TEST(value_or) +{ + asl::option a = asl::nullopt; + asl::option b = 2; + + ASL_TEST_EXPECT(a.value_or(5) == 5); + ASL_TEST_EXPECT(b.value_or(5) == 2); +} -- cgit