The test suite is extensive. Note that LLMs were used to aid in the development of the test suite. All LLM generated code was manually reviewed.
28 lines
1.4 KiB
C++
28 lines
1.4 KiB
C++
#include <filesystem>
|
|
#include <limits>
|
|
#include <print>
|
|
|
|
#include "serif/utils/serialize/archive.hpp"
|
|
|
|
/** @brief Produce independent C++ fixtures for the dependency-free Python data reader. */
|
|
int main(int argc, char** argv) {
|
|
namespace serialization = serif::utils::serialize;
|
|
if (argc != 2) {
|
|
return 2;
|
|
}
|
|
const auto contents = serialization::pack(serialization::named("values", std::vector<double>{-0.0, 1.2345678901234567,
|
|
std::numeric_limits<double>::denorm_min(), std::numeric_limits<double>::infinity(),
|
|
std::bit_cast<double>(0x7ff8123456789abcULL)}), serialization::named("empty", std::vector<double>{}),
|
|
serialization::named("integers", std::vector<std::int64_t>{std::numeric_limits<std::int64_t>::min(), std::numeric_limits<std::int64_t>::max()}),
|
|
serialization::named("label", std::string{"ξ\n\"quote\"\\end"}));
|
|
for (serialization::Format format : {serialization::Format::binary, serialization::Format::text}) {
|
|
const auto path = std::filesystem::path{argv[1]} / (format == serialization::Format::binary ? "binary.serif" : "text.serif");
|
|
const auto result = serialization::write(path, contents, {.format = format, .author = "Cross-language regression"});
|
|
if (!result) {
|
|
std::println(stderr, "{}: {}", result.error().path, result.error().message);
|
|
return 1;
|
|
}
|
|
}
|
|
return 0;
|
|
}
|