From fa0d298afafdc81d00164765903161205cf09a7e Mon Sep 17 00:00:00 2001 From: Loek Le Blansch Date: Sat, 14 Dec 2024 16:24:08 +0100 Subject: move DB fix from `loek/doxygen` to `loek/savemgr` --- src/test/DBTest.cpp | 9 +++++++++ src/test/SaveManagerTest.cpp | 17 ++++++++++++++--- src/test/main.cpp | 3 ++- 3 files changed, 25 insertions(+), 4 deletions(-) (limited to 'src/test') diff --git a/src/test/DBTest.cpp b/src/test/DBTest.cpp index 99dedff..0c98e10 100644 --- a/src/test/DBTest.cpp +++ b/src/test/DBTest.cpp @@ -27,3 +27,12 @@ TEST_F(DBTest, Has) { db.set("foo", "bar"); EXPECT_EQ(db.has("foo"), true); } + +TEST_F(DBTest, MultipleKeys) { + db.set("foo", "foo"); + db.set("bar", "bar"); + + EXPECT_EQ(db.get("foo"), "foo"); + EXPECT_EQ(db.get("bar"), "bar"); +} + diff --git a/src/test/SaveManagerTest.cpp b/src/test/SaveManagerTest.cpp index e9b0c29..7609e69 100644 --- a/src/test/SaveManagerTest.cpp +++ b/src/test/SaveManagerTest.cpp @@ -27,8 +27,8 @@ TEST_F(SaveManagerTest, ReadWrite) { mgr.set("foo", "bar"); ASSERT_TRUE(mgr.has("foo")); - ValueBroker value = mgr.get("foo"); - EXPECT_EQ(value.get(), "bar"); + string value = mgr.get("foo"); + EXPECT_EQ(value, "bar"); } TEST_F(SaveManagerTest, DefaultValue) { @@ -36,5 +36,16 @@ TEST_F(SaveManagerTest, DefaultValue) { ASSERT_EQ(value.get(), 3); value.set(5); - ASSERT_EQ(value.get(), 5); + EXPECT_EQ(value.get(), 5); +} + +TEST_F(SaveManagerTest, MultipleKeys) { + ValueBroker foo = mgr.get("foo", 1); + ValueBroker bar = mgr.get("bar", 2); + + EXPECT_EQ(foo.get(), 1); + EXPECT_EQ(bar.get(), 2); + + EXPECT_EQ(mgr.get("foo"), 1); + EXPECT_EQ(mgr.get("bar"), 2); } diff --git a/src/test/main.cpp b/src/test/main.cpp index ed2aed5..0e1bc75 100644 --- a/src/test/main.cpp +++ b/src/test/main.cpp @@ -1,6 +1,7 @@ -#include #include +#include + using namespace crepe; using namespace testing; -- cgit v1.2.3 From 154ed5353ef18eb46cc31744e8bf1bc54afd5acc Mon Sep 17 00:00:00 2001 From: Loek Le Blansch Date: Sat, 14 Dec 2024 16:24:25 +0100 Subject: `make format` --- src/crepe/facade/DB.cpp | 1 - src/test/DBTest.cpp | 1 - 2 files changed, 2 deletions(-) (limited to 'src/test') diff --git a/src/crepe/facade/DB.cpp b/src/crepe/facade/DB.cpp index 2232a21..ae2d4bc 100644 --- a/src/crepe/facade/DB.cpp +++ b/src/crepe/facade/DB.cpp @@ -59,4 +59,3 @@ bool DB::has(const std::string & key) { } return true; } - diff --git a/src/test/DBTest.cpp b/src/test/DBTest.cpp index 0c98e10..7f2c339 100644 --- a/src/test/DBTest.cpp +++ b/src/test/DBTest.cpp @@ -35,4 +35,3 @@ TEST_F(DBTest, MultipleKeys) { EXPECT_EQ(db.get("foo"), "foo"); EXPECT_EQ(db.get("bar"), "bar"); } - -- cgit v1.2.3