mirror of
https://github.com/privatevoid-net/nix-super.git
synced 2025-02-18 08:07:17 +02:00
add tests for optionalValueAt
This commit is contained in:
parent
bb939d3772
commit
ff4c286e80
1 changed files with 12 additions and 0 deletions
|
@ -160,4 +160,16 @@ TEST(getBoolean, wrongAssertions) {
|
||||||
ASSERT_THROW(getBoolean(valueAt(json, "int")), Error);
|
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 */
|
} /* namespace nix */
|
||||||
|
|
Loading…
Add table
Reference in a new issue