binarystore: Add std::optional for optional config options
The `maxSizeBytes` was using 0 size by default instead of skipping it.
Letting `config.maxSizeBytes` be std::optional allow us to have more
control to see if the 0 value is expected or nullopt.
Change-Id: I128216825609909c489cbd5471b324d88d3aa25b
Signed-off-by: Willy Tu <wltu@google.com>
diff --git a/test/parse_config_unittest.cpp b/test/parse_config_unittest.cpp
index b450477..772dcc8 100644
--- a/test/parse_config_unittest.cpp
+++ b/test/parse_config_unittest.cpp
@@ -51,6 +51,16 @@
{
"blobBaseId": "/test/",
"sysFilePath": "/another/path"
+ },
+ {
+ "blobBaseId": "/test/",
+ "sysFilePath": "/another/path",
+ "offsetBytes": 32
+ },
+ {
+ "blobBaseId": "/test/",
+ "sysFilePath": "/another/path",
+ "maxSizeBytes": 32
}]
)"_json;
@@ -60,7 +70,9 @@
EXPECT_NO_THROW(parseFromConfigFile(element, config));
EXPECT_EQ(config.blobBaseId, "/test/");
- EXPECT_TRUE(config.offsetBytes == 32 || config.offsetBytes == 0);
- EXPECT_TRUE(config.maxSizeBytes == 32 || config.maxSizeBytes == 0);
+ EXPECT_TRUE(config.offsetBytes == std::nullopt ||
+ *config.offsetBytes == 32);
+ EXPECT_TRUE(config.maxSizeBytes == std::nullopt ||
+ *config.maxSizeBytes == 32);
}
}