4#include <nlohmann/json.hpp>
5#include <gtest/gtest.h>
13template<
class Proto, const
char * protocolDir>
16 std::filesystem::path unitTestData = getUnitTestData() / protocolDir;
18 std::filesystem::path goldenMaster(std::string_view testStem)
const override
20 return unitTestData / testStem;
24 std::string storeDir =
"/nix/store";
46template<
class Proto, const
char * protocolDir>
54 void readProtoTest(std::string_view testStem,
typename Proto::Version version, T expected)
59 Proto::template Serialise<T>::read(
61 typename Proto::ReadConn{
67 ASSERT_EQ(got, expected);
75 void writeProtoTest(std::string_view testStem,
typename Proto::Version version,
const T & decoded)
79 Proto::template Serialise<T>::write(
81 typename Proto::WriteConn{
86 return std::move(to.s);
91#define VERSIONED_READ_CHARACTERIZATION_TEST_NO_JSON(FIXTURE, NAME, STEM, VERSION, VALUE) \
92 TEST_F(FIXTURE, NAME##_read) \
94 readProtoTest(STEM, VERSION, VALUE); \
97#define VERSIONED_WRITE_CHARACTERIZATION_TEST_NO_JSON(FIXTURE, NAME, STEM, VERSION, VALUE) \
98 TEST_F(FIXTURE, NAME##_write) \
100 writeProtoTest(STEM, VERSION, VALUE); \
103#define VERSIONED_CHARACTERIZATION_TEST_NO_JSON(FIXTURE, NAME, STEM, VERSION, VALUE) \
104 VERSIONED_READ_CHARACTERIZATION_TEST_NO_JSON(FIXTURE, NAME, STEM, (VERSION), VALUE) \
105 VERSIONED_WRITE_CHARACTERIZATION_TEST_NO_JSON(FIXTURE, NAME, STEM, (VERSION), VALUE)
107#define VERSIONED_READ_CHARACTERIZATION_TEST(FIXTURE, NAME, STEM, VERSION, VALUE) \
108 VERSIONED_READ_CHARACTERIZATION_TEST_NO_JSON(FIXTURE, NAME, STEM, (VERSION), VALUE) \
109 TEST_F(FIXTURE, NAME##_json_read) \
111 readJsonTest(STEM, VALUE); \
114#define VERSIONED_WRITE_CHARACTERIZATION_TEST(FIXTURE, NAME, STEM, VERSION, VALUE) \
115 VERSIONED_WRITE_CHARACTERIZATION_TEST_NO_JSON(FIXTURE, NAME, STEM, (VERSION), VALUE) \
116 TEST_F(FIXTURE, NAME##_json_write) \
118 writeJsonTest(STEM, VALUE); \
121#define VERSIONED_CHARACTERIZATION_TEST(FIXTURE, NAME, STEM, VERSION, VALUE) \
122 VERSIONED_READ_CHARACTERIZATION_TEST(FIXTURE, NAME, STEM, (VERSION), VALUE) \
123 VERSIONED_WRITE_CHARACTERIZATION_TEST(FIXTURE, NAME, STEM, (VERSION), VALUE)
128 void writeUnbuffered(std::string_view data)
override {}
Definition protocol.hh:15
void writeJsonTest(std::string_view testStem, const T &decoded)
Definition protocol.hh:40
void readJsonTest(std::string_view testStem, const T &expected)
Definition protocol.hh:31
Definition serialise.hh:293
Definition serialise.hh:315
Definition protocol.hh:48
void readProtoTest(std::string_view testStem, typename Proto::Version version, T expected)
Definition protocol.hh:54
void writeProtoTest(std::string_view testStem, typename Proto::Version version, const T &decoded)
Definition protocol.hh:75
void readJsonTest(CharacterizationTest &test, std::string_view testStem, const T &expected, auto... args)
Definition json-characterization.hh:20
void writeJsonTest(CharacterizationTest &test, std::string_view testStem, const T &value)
Definition json-characterization.hh:34
Definition characterization.hh:26
void readTest(std::string_view testStem, auto &&test)
Definition characterization.hh:39
void writeTest(std::string_view testStem, auto &&test, auto &&readFile2, auto &&writeFile2)
Definition characterization.hh:56
Has to be a BufferedSink for handshake.
Definition protocol.hh:127
Definition store-dir-config.hh:29