mirror of
https://github.com/NixOS/nix.git
synced 2024-11-22 06:42:28 +00:00
add tests for optionalValueAt
This commit is contained in:
parent
bb939d3772
commit
ff4c286e80
@ -160,4 +160,16 @@ TEST(getBoolean, wrongAssertions) {
|
||||
ASSERT_THROW(getBoolean(valueAt(json, "int")), Error);
|
||||
}
|
||||
|
||||
TEST(optionalValueAt, existing) {
|
||||
auto json = R"({ "string": "ssh-rsa" })"_json;
|
||||
|
||||
ASSERT_EQ(optionalValueAt(json, "string"), std::optional { "ssh-rsa" });
|
||||
}
|
||||
|
||||
TEST(optionalValueAt, empty) {
|
||||
auto json = R"({})"_json;
|
||||
|
||||
ASSERT_EQ(optionalValueAt(json, "string2"), std::nullopt);
|
||||
}
|
||||
|
||||
} /* namespace nix */
|
||||
|
Loading…
Reference in New Issue
Block a user