aboutsummaryrefslogtreecommitdiff
path: root/src/test/OptionalRefTest.cpp
diff options
context:
space:
mode:
authorLoek Le Blansch <loek@pipeframe.xyz>2024-11-14 19:57:45 +0100
committerLoek Le Blansch <loek@pipeframe.xyz>2024-11-14 19:57:45 +0100
commitadd8724446fdeae1aaec9b07544cf7a5475a9bfe (patch)
tree7c51cf0d65f8f0d906a0abe2b29bad916dcf83e8 /src/test/OptionalRefTest.cpp
parentab0b4923c4f49e7a28f6d17e994d3e013ca344bb (diff)
ResourceManager working + tested
Diffstat (limited to 'src/test/OptionalRefTest.cpp')
-rw-r--r--src/test/OptionalRefTest.cpp24
1 files changed, 23 insertions, 1 deletions
diff --git a/src/test/OptionalRefTest.cpp b/src/test/OptionalRefTest.cpp
index 65bd816..219ccca 100644
--- a/src/test/OptionalRefTest.cpp
+++ b/src/test/OptionalRefTest.cpp
@@ -9,8 +9,30 @@ using namespace testing;
TEST(OptionalRefTest, Explicit) {
string value = "foo";
OptionalRef<string> ref;
+ EXPECT_FALSE(ref);
+ ASSERT_THROW(ref.get(), runtime_error);
+
+ ref.set(value);
+ EXPECT_TRUE(ref);
+ ASSERT_NO_THROW(ref.get());
+
+ ref.clear();
+ EXPECT_FALSE(ref);
+ ASSERT_THROW(ref.get(), runtime_error);
+}
+
+TEST(OptionalRefTest, Implicit) {
+ string value = "foo";
+ OptionalRef<string> ref = value;
+ EXPECT_TRUE(ref);
+ ASSERT_NO_THROW(ref.get());
- EXPECT_FALSE(bool(ref));
+ ref.clear();
+ EXPECT_FALSE(ref);
ASSERT_THROW(ref.get(), runtime_error);
+
+ ref = value;
+ EXPECT_TRUE(ref);
+ ASSERT_NO_THROW(ref.get());
}