From 36cdb4a544341e45155ff750c5f67ece71348a52 Mon Sep 17 00:00:00 2001 From: Niel Lebeck Date: Mon, 22 Apr 2024 21:51:09 -0700 Subject: Eliminate SettingsHandler's `SetBytes` and `Reset` methods Also make the `Decrypt` method private. As far as I can tell, the only motivation for exposing the `SetBytes` and `Reset` methods is to allow `CBoot::SetupWiiMemory` to use the same `SettingsHandler` instance to read settings data and then write it back. It seems cleaner to just use two separate instances, and require a given `SettingsHandler` instance to be used for either writing data to a buffer or reading data from a buffer, but not both. A natural next step is to split the `SettingsHandler` class into two classes, one for writing data and one for reading data. I've deferred that change for a future PR. --- Source/UnitTests/Common/SettingsHandlerTest.cpp | 24 ------------------------ 1 file changed, 24 deletions(-) (limited to 'Source/UnitTests/Common/SettingsHandlerTest.cpp') diff --git a/Source/UnitTests/Common/SettingsHandlerTest.cpp b/Source/UnitTests/Common/SettingsHandlerTest.cpp index e482531bfe..f480c0636e 100644 --- a/Source/UnitTests/Common/SettingsHandlerTest.cpp +++ b/Source/UnitTests/Common/SettingsHandlerTest.cpp @@ -75,35 +75,11 @@ TEST(SettingsHandlerTest, DecryptMultipleSettings) EXPECT_EQ(handler.GetValue("foo"), "bar"); } -TEST(SettingsHandlerTest, SetBytesOverwritesExistingBuffer) -{ - Common::SettingsHandler handler(BUFFER_A); - ASSERT_EQ(handler.GetValue("key"), "val"); - ASSERT_EQ(handler.GetValue("foo"), ""); - - handler.SetBytes(BUFFER_B); - EXPECT_EQ(handler.GetValue("foo"), "bar"); - EXPECT_EQ(handler.GetValue("key"), ""); -} - TEST(SettingsHandlerTest, GetValueOnSameInstance) { Common::SettingsHandler handler; handler.AddSetting("key", "val"); EXPECT_EQ(handler.GetValue("key"), ""); - - Common::SettingsHandler::Buffer buffer = handler.GetBytes(); - handler.SetBytes(buffer); - EXPECT_EQ(handler.GetValue("key"), "val"); -} - -TEST(SettingsHandlerTest, GetValueAfterReset) -{ - Common::SettingsHandler handler(BUFFER_A); - ASSERT_EQ(handler.GetValue("key"), "val"); - - handler.Reset(); - EXPECT_EQ(handler.GetValue("key"), ""); } TEST(SettingsHandlerTest, EncryptAddsLFOnNullChar) -- cgit v1.2.3