2023-01-10 16:27:19 +00:00
|
|
|
#include "outputs-spec.hh"
|
2022-04-22 13:17:01 +00:00
|
|
|
|
|
|
|
#include <gtest/gtest.h>
|
|
|
|
|
|
|
|
namespace nix {
|
|
|
|
|
2023-01-11 06:51:14 +00:00
|
|
|
TEST(OutputsSpec_parse, basic)
|
2022-04-22 13:17:01 +00:00
|
|
|
{
|
|
|
|
{
|
2023-01-11 06:51:14 +00:00
|
|
|
auto [prefix, outputsSpec] = OutputsSpec::parse("foo");
|
2022-04-22 13:17:01 +00:00
|
|
|
ASSERT_EQ(prefix, "foo");
|
|
|
|
ASSERT_TRUE(std::get_if<DefaultOutputs>(&outputsSpec));
|
|
|
|
}
|
|
|
|
|
|
|
|
{
|
2023-01-11 06:51:14 +00:00
|
|
|
auto [prefix, outputsSpec] = OutputsSpec::parse("foo^*");
|
2022-04-22 13:17:01 +00:00
|
|
|
ASSERT_EQ(prefix, "foo");
|
|
|
|
ASSERT_TRUE(std::get_if<AllOutputs>(&outputsSpec));
|
|
|
|
}
|
|
|
|
|
|
|
|
{
|
2023-01-11 06:51:14 +00:00
|
|
|
auto [prefix, outputsSpec] = OutputsSpec::parse("foo^out");
|
2022-04-22 13:17:01 +00:00
|
|
|
ASSERT_EQ(prefix, "foo");
|
|
|
|
ASSERT_TRUE(std::get<OutputNames>(outputsSpec) == OutputNames({"out"}));
|
|
|
|
}
|
|
|
|
|
|
|
|
{
|
2023-01-11 06:51:14 +00:00
|
|
|
auto [prefix, outputsSpec] = OutputsSpec::parse("foo^out,bin");
|
2022-04-22 13:17:01 +00:00
|
|
|
ASSERT_EQ(prefix, "foo");
|
|
|
|
ASSERT_TRUE(std::get<OutputNames>(outputsSpec) == OutputNames({"out", "bin"}));
|
|
|
|
}
|
|
|
|
|
|
|
|
{
|
2023-01-11 06:51:14 +00:00
|
|
|
auto [prefix, outputsSpec] = OutputsSpec::parse("foo^bar^out,bin");
|
2022-04-22 13:17:01 +00:00
|
|
|
ASSERT_EQ(prefix, "foo^bar");
|
|
|
|
ASSERT_TRUE(std::get<OutputNames>(outputsSpec) == OutputNames({"out", "bin"}));
|
|
|
|
}
|
|
|
|
|
|
|
|
{
|
2023-01-11 06:51:14 +00:00
|
|
|
auto [prefix, outputsSpec] = OutputsSpec::parse("foo^&*()");
|
2022-04-22 13:17:01 +00:00
|
|
|
ASSERT_EQ(prefix, "foo^&*()");
|
|
|
|
ASSERT_TRUE(std::get_if<DefaultOutputs>(&outputsSpec));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|