diff options
author | Brian Gianforcaro <bgianf@serenityos.org> | 2021-05-06 01:19:30 -0700 |
---|---|---|
committer | Andreas Kling <kling@serenityos.org> | 2021-05-06 17:54:28 +0200 |
commit | 67322b0702836807e29265e86556ebf43bb9d510 (patch) | |
tree | 86d2e2099ecc377cf11ddcf9106c500969b1afbb /AK/Tests/TestOptional.cpp | |
parent | fd0dbd1ebfbcbc29d46393061daa49dc7390caa7 (diff) | |
download | serenity-67322b0702836807e29265e86556ebf43bb9d510.zip |
Tests: Move AK tests to Tests/AK
Diffstat (limited to 'AK/Tests/TestOptional.cpp')
-rw-r--r-- | AK/Tests/TestOptional.cpp | 55 |
1 files changed, 0 insertions, 55 deletions
diff --git a/AK/Tests/TestOptional.cpp b/AK/Tests/TestOptional.cpp deleted file mode 100644 index 583d11f0eb..0000000000 --- a/AK/Tests/TestOptional.cpp +++ /dev/null @@ -1,55 +0,0 @@ -/* - * Copyright (c) 2018-2020, Andreas Kling <kling@serenityos.org> - * - * SPDX-License-Identifier: BSD-2-Clause - */ - -#include <LibTest/TestCase.h> - -#include <AK/Optional.h> -#include <AK/String.h> - -TEST_CASE(basic_optional) -{ - Optional<int> x; - EXPECT_EQ(x.has_value(), false); - x = 3; - EXPECT_EQ(x.has_value(), true); - EXPECT_EQ(x.value(), 3); -} - -TEST_CASE(move_optional) -{ - Optional<int> x; - EXPECT_EQ(x.has_value(), false); - x = 3; - EXPECT_EQ(x.has_value(), true); - EXPECT_EQ(x.value(), 3); - - Optional<int> y; - y = move(x); - EXPECT_EQ(y.has_value(), true); - EXPECT_EQ(y.value(), 3); - EXPECT_EQ(x.has_value(), false); -} - -TEST_CASE(optional_leak_1) -{ - struct Structure { - Optional<String> str; - }; - - // This used to leak, it does not anymore. - Vector<Structure> vec; - vec.append({ "foo" }); - EXPECT_EQ(vec[0].str.has_value(), true); - EXPECT_EQ(vec[0].str.value(), "foo"); -} - -TEST_CASE(short_notation) -{ - Optional<StringView> value = "foo"; - - EXPECT_EQ(value->length(), 3u); - EXPECT_EQ(*value, "foo"); -} |