mirror of
https://github.com/privatevoid-net/nix-super.git
synced 2024-11-26 15:56:18 +02:00
Write more (extended) output spec tests
This commit is contained in:
parent
d29eb08563
commit
d8512653d4
1 changed files with 33 additions and 0 deletions
|
@ -1,5 +1,6 @@
|
||||||
#include "outputs-spec.hh"
|
#include "outputs-spec.hh"
|
||||||
|
|
||||||
|
#include <nlohmann/json.hpp>
|
||||||
#include <gtest/gtest.h>
|
#include <gtest/gtest.h>
|
||||||
|
|
||||||
namespace nix {
|
namespace nix {
|
||||||
|
@ -105,6 +106,10 @@ TEST(OutputsSpec, union_names_names) {
|
||||||
|
|
||||||
TEST_DONT_PARSE(carot_empty, "^")
|
TEST_DONT_PARSE(carot_empty, "^")
|
||||||
TEST_DONT_PARSE(prefix_carot_empty, "foo^")
|
TEST_DONT_PARSE(prefix_carot_empty, "foo^")
|
||||||
|
TEST_DONT_PARSE(garbage, "^&*()")
|
||||||
|
TEST_DONT_PARSE(double_star, "^**")
|
||||||
|
TEST_DONT_PARSE(star_first, "^*,foo")
|
||||||
|
TEST_DONT_PARSE(star_second, "^foo,*")
|
||||||
|
|
||||||
#undef TEST_DONT_PARSE
|
#undef TEST_DONT_PARSE
|
||||||
|
|
||||||
|
@ -151,4 +156,32 @@ TEST(ExtendedOutputsSpec, many_carrot) {
|
||||||
ASSERT_EQ(std::string { prefix } + expected.to_string(), "foo^bar^bin,out");
|
ASSERT_EQ(std::string { prefix } + expected.to_string(), "foo^bar^bin,out");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
#define TEST_JSON(TYPE, NAME, STR, VAL) \
|
||||||
|
\
|
||||||
|
TEST(TYPE, NAME ## _to_json) { \
|
||||||
|
using nlohmann::literals::operator "" _json; \
|
||||||
|
ASSERT_EQ( \
|
||||||
|
STR ## _json, \
|
||||||
|
((nlohmann::json) TYPE { VAL })); \
|
||||||
|
} \
|
||||||
|
\
|
||||||
|
TEST(TYPE, NAME ## _from_json) { \
|
||||||
|
using nlohmann::literals::operator "" _json; \
|
||||||
|
ASSERT_EQ( \
|
||||||
|
TYPE { VAL }, \
|
||||||
|
(STR ## _json).get<TYPE>()); \
|
||||||
|
}
|
||||||
|
|
||||||
|
TEST_JSON(OutputsSpec, all, R"(["*"])", OutputsSpec::All { })
|
||||||
|
TEST_JSON(OutputsSpec, name, R"(["a"])", OutputsSpec::Names { "a" })
|
||||||
|
TEST_JSON(OutputsSpec, names, R"(["a","b"])", (OutputsSpec::Names { "a", "b" }))
|
||||||
|
|
||||||
|
TEST_JSON(ExtendedOutputsSpec, def, R"(null)", ExtendedOutputsSpec::Default { })
|
||||||
|
TEST_JSON(ExtendedOutputsSpec, all, R"(["*"])", ExtendedOutputsSpec::Explicit { OutputsSpec::All { } })
|
||||||
|
TEST_JSON(ExtendedOutputsSpec, name, R"(["a"])", ExtendedOutputsSpec::Explicit { OutputsSpec::Names { "a" } })
|
||||||
|
TEST_JSON(ExtendedOutputsSpec, names, R"(["a","b"])", (ExtendedOutputsSpec::Explicit { OutputsSpec::Names { "a", "b" } }))
|
||||||
|
|
||||||
|
#undef TEST_JSON
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue