add unit tests for getNullable

This commit is contained in:
HaeNoe 2024-04-16 13:37:39 +02:00
parent 4ff7f5aa9c
commit c73172e986
No known key found for this signature in database

View File

@ -169,7 +169,19 @@ TEST(optionalValueAt, existing) {
TEST(optionalValueAt, empty) {
auto json = R"({})"_json;
ASSERT_EQ(optionalValueAt(json, "string2"), std::nullopt);
ASSERT_EQ(optionalValueAt(json, "string"), std::nullopt);
}
TEST(getNullable, null) {
auto json = R"(null)"_json;
ASSERT_EQ(getNullable(json), std::nullopt);
}
TEST(getNullable, empty) {
auto json = R"({})"_json;
ASSERT_EQ(getNullable(json), std::optional { R"({})"_json });
}
} /* namespace nix */