1
1
Fork 0
mirror of https://github.com/NixOS/nix.git synced 2025-11-21 17:59:36 +01:00

Allow for standard nlohmann JSON serializers to take separate XP features

I realized that we can actually do this thing, even though it is not
what nlohmann expects at all, because the extra parameter has a default
argument so nlohmann doesn't need to care. Sneaky!
This commit is contained in:
John Ericson 2025-10-16 15:49:47 -04:00
parent d87a06af7a
commit 1c02dd5b9c
5 changed files with 35 additions and 32 deletions

View file

@ -24,12 +24,12 @@ struct JsonCharacterizationTest : virtual CharacterizationTest
* @param test hook that takes the contents of the file and does the
* actual work
*/
void readJsonTest(PathView testStem, const T & expected)
void readJsonTest(PathView testStem, const T & expected, auto... args)
{
using namespace nlohmann;
readTest(Path{testStem} + ".json", [&](const auto & encodedRaw) {
auto encoded = json::parse(encodedRaw);
T decoded = adl_serializer<T>::from_json(encoded);
T decoded = adl_serializer<T>::from_json(encoded, args...);
ASSERT_EQ(decoded, expected);
});
}