Nix 2.36.0
Nix, the purely functional package manager; unstable internal interfaces
Loading...
Searching...
No Matches
json-characterization.hh File Reference
#include <gtest/gtest.h>
#include <nlohmann/json.hpp>
#include "nix/util/types.hh"
#include "nix/util/ref.hh"
#include "nix/util/file-system.hh"
#include "nix/util/nar-accessor.hh"
#include "nix/util/tests/characterization.hh"

Go to the source code of this file.

Classes

struct  nix::JsonCharacterizationTest< T >

Functions

template<typename T>
void nix::readJsonTest (CharacterizationTest &test, std::string_view testStem, const T &expected, auto... args)
template<typename T>
void nix::writeJsonTest (CharacterizationTest &test, std::string_view testStem, const T &value)
template<typename T>
void nix::writeJsonTest (CharacterizationTest &test, std::string_view testStem, const ref< T > &value)
template<typename T>
void nix::checkpointJson (CharacterizationTest &test, std::string_view testStem, const T &got)
template<typename T>
void nix::checkpointJson (CharacterizationTest &test, std::string_view testStem, const ref< T > &got)

Function Documentation

◆ checkpointJson() [1/2]

template<typename T>
void nix::checkpointJson ( CharacterizationTest & test,
std::string_view testStem,
const ref< T > & got )

Specialization for when we need to do "JSON -> `ref<T>`" in one direction, but "`const T &` -> JSON" in the other direction.

◆ checkpointJson() [2/2]

template<typename T>
void nix::checkpointJson ( CharacterizationTest & test,
std::string_view testStem,
const T & got )

Golden test in the middle of something

◆ readJsonTest()

template<typename T>
void nix::readJsonTest ( CharacterizationTest & test,
std::string_view testStem,
const T & expected,
auto... args )

Golden test for JSON reading

◆ writeJsonTest() [1/2]

template<typename T>
void nix::writeJsonTest ( CharacterizationTest & test,
std::string_view testStem,
const ref< T > & value )

Specialization for when we need to do "JSON -> `ref<T>`" in one direction, but "`const T &` -> JSON" in the other direction.

We can't just return const T &, but it would be wasteful to requires a const ref<T> & double indirection (and mandatory shared pointer), so we break the symmetry as the best remaining option.

◆ writeJsonTest() [2/2]

template<typename T>
void nix::writeJsonTest ( CharacterizationTest & test,
std::string_view testStem,
const T & value )

Golden test for JSON writing