mirror of
https://github.com/red0124/ssp.git
synced 2025-01-23 13:05:20 +01:00
merge with master
This commit is contained in:
commit
4de7063708
1
.github/workflows/ci.yml
vendored
1
.github/workflows/ci.yml
vendored
@ -4,6 +4,7 @@ on:
|
||||
push:
|
||||
branches:
|
||||
- master
|
||||
- testing
|
||||
|
||||
pull_request:
|
||||
branches:
|
||||
|
@ -1,19 +1,18 @@
|
||||
#include <ss/converter.hpp>
|
||||
#include <doctest/doctest.h>
|
||||
#include <algorithm>
|
||||
#include <doctest/doctest.h>
|
||||
#include <ss/converter.hpp>
|
||||
|
||||
TEST_CASE("testing split") {
|
||||
ss::converter c;
|
||||
|
||||
for (const auto& [s, expected, delim] :
|
||||
// clang-format off
|
||||
{std::tuple{"a,b,c,d", std::vector{"a", "b", "c", "d"}, ","},
|
||||
{"", {}, " "},
|
||||
{"a,b,c", {"a", "b", "c"}, ""},
|
||||
{" x x x x | x ", {" x x x x ", " x "}, "|"},
|
||||
{"a::b::c::d", {"a", "b", "c", "d"}, "::"},
|
||||
{"x\t-\ty", {"x", "y"}, "\t-\t"},
|
||||
{"x", {"x"}, ","}} // clang-format on
|
||||
) {
|
||||
{std::make_tuple("a,b,c,d", std::vector{"a", "b", "c", "d"}, ","),
|
||||
{"", {}, " "},
|
||||
{"a,b,c", {"a", "b", "c"}, ""},
|
||||
{" x x x x | x ", {" x x x x ", " x "}, "|"},
|
||||
{"a::b::c::d", {"a", "b", "c", "d"}, "::"},
|
||||
{"x\t-\ty", {"x", "y"}, "\t-\t"},
|
||||
{"x", {"x"}, ","}}) {
|
||||
auto split = c.split(s, delim);
|
||||
CHECK(split.size() == expected.size());
|
||||
for (size_t i = 0; i < split.size(); ++i) {
|
||||
@ -66,31 +65,31 @@ TEST_CASE("testing valid conversions") {
|
||||
{
|
||||
auto tup = c.convert<int, double, void>("5,6.6,junk");
|
||||
REQUIRE(c.valid());
|
||||
CHECK(tup == std::tuple{5, 6.6});
|
||||
CHECK(tup == std::make_tuple(5, 6.6));
|
||||
}
|
||||
{
|
||||
auto tup = c.convert<int, void, double>("5,junk,6.6");
|
||||
REQUIRE(c.valid());
|
||||
CHECK(tup == std::tuple{5, 6.6});
|
||||
CHECK(tup == std::make_tuple(5, 6.6));
|
||||
}
|
||||
{
|
||||
auto tup = c.convert<void, int, double>("junk;5;6.6", ";");
|
||||
REQUIRE(c.valid());
|
||||
CHECK(tup == std::tuple{5, 6.6});
|
||||
CHECK(tup == std::make_tuple(5, 6.6));
|
||||
}
|
||||
{
|
||||
auto tup =
|
||||
c.convert<void, std::optional<int>, double>("junk;5;6.6", ";");
|
||||
REQUIRE(c.valid());
|
||||
REQUIRE(std::get<0>(tup).has_value());
|
||||
CHECK(tup == std::tuple{5, 6.6});
|
||||
CHECK(tup == std::make_tuple(5, 6.6));
|
||||
}
|
||||
{
|
||||
auto tup =
|
||||
c.convert<void, std::optional<int>, double>("junk;5.4;6.6", ";");
|
||||
REQUIRE(c.valid());
|
||||
REQUIRE(!std::get<0>(tup).has_value());
|
||||
CHECK(tup == std::tuple{std::nullopt, 6.6});
|
||||
CHECK(tup == std::make_tuple(std::optional<int>{}, 6.6));
|
||||
}
|
||||
{
|
||||
auto tup =
|
||||
@ -98,7 +97,7 @@ TEST_CASE("testing valid conversions") {
|
||||
";");
|
||||
REQUIRE(c.valid());
|
||||
REQUIRE(std::holds_alternative<int>(std::get<0>(tup)));
|
||||
CHECK(tup == std::tuple{std::variant<int, double>{5}, 6.6});
|
||||
CHECK(tup == std::make_tuple(std::variant<int, double>{5}, 6.6));
|
||||
}
|
||||
{
|
||||
auto tup =
|
||||
@ -106,7 +105,7 @@ TEST_CASE("testing valid conversions") {
|
||||
";");
|
||||
REQUIRE(c.valid());
|
||||
REQUIRE(std::holds_alternative<double>(std::get<0>(tup)));
|
||||
CHECK(tup == std::tuple{std::variant<int, double>{5.5}, 6.6});
|
||||
CHECK(tup == std::make_tuple(std::variant<int, double>{5.5}, 6.6));
|
||||
}
|
||||
}
|
||||
|
||||
@ -163,12 +162,12 @@ TEST_CASE("testing ss:ax restriction (all except)") {
|
||||
{
|
||||
std::tuple<char, int> tup = c.convert<char, ss::ax<int, 1>>("c,3");
|
||||
REQUIRE(c.valid());
|
||||
CHECK(tup == std::tuple{'c', 3});
|
||||
CHECK(tup == std::make_tuple('c', 3));
|
||||
}
|
||||
{
|
||||
std::tuple<int, char> tup = c.convert<ss::ax<int, 1>, char>("3,c");
|
||||
REQUIRE(c.valid());
|
||||
CHECK(tup == std::tuple{3, 'c'});
|
||||
CHECK(tup == std::make_tuple(3, 'c'));
|
||||
}
|
||||
}
|
||||
|
||||
@ -197,12 +196,12 @@ TEST_CASE("testing ss:nx restriction (none except)") {
|
||||
{
|
||||
auto tup = c.convert<char, void, ss::nx<int, 0, 1, 2>>("c,junk,1");
|
||||
REQUIRE(c.valid());
|
||||
CHECK(tup == std::tuple{'c', 1});
|
||||
CHECK(tup == std::make_tuple('c', 1));
|
||||
}
|
||||
{
|
||||
auto tup = c.convert<ss::nx<int, 1>, char>("1,c");
|
||||
REQUIRE(c.valid());
|
||||
CHECK(tup == std::tuple{1, 'c'});
|
||||
CHECK(tup == std::make_tuple(1, 'c'));
|
||||
}
|
||||
}
|
||||
|
||||
@ -231,12 +230,12 @@ TEST_CASE("testing ss:ir restriction (in range)") {
|
||||
{
|
||||
auto tup = c.convert<char, void, ss::ir<int, 0, 1>>("c,junk,1");
|
||||
REQUIRE(c.valid());
|
||||
CHECK(tup == std::tuple{'c', 1});
|
||||
CHECK(tup == std::make_tuple('c', 1));
|
||||
}
|
||||
{
|
||||
auto tup = c.convert<ss::ir<int, 1, 20>, char>("1,c");
|
||||
REQUIRE(c.valid());
|
||||
CHECK(tup == std::tuple{1, 'c'});
|
||||
CHECK(tup == std::make_tuple(1, 'c'));
|
||||
}
|
||||
}
|
||||
|
||||
@ -264,13 +263,13 @@ TEST_CASE("testing ss:oor restriction (out of range)") {
|
||||
{
|
||||
auto tup = c.convert<char, void, ss::oor<int, 4, 69>>("c,junk,3");
|
||||
REQUIRE(c.valid());
|
||||
CHECK(tup == std::tuple{'c', 3});
|
||||
CHECK(tup == std::make_tuple('c', 3));
|
||||
}
|
||||
|
||||
{
|
||||
auto tup = c.convert<ss::oor<int, 1, 2>, char>("3,c");
|
||||
REQUIRE(c.valid());
|
||||
CHECK(tup == std::tuple{3, 'c'});
|
||||
CHECK(tup == std::make_tuple(3, 'c'));
|
||||
}
|
||||
}
|
||||
|
||||
@ -313,7 +312,7 @@ TEST_CASE("testing ss:ne restriction (not empty)") {
|
||||
{
|
||||
auto tup = c.convert<std::optional<int>, ss::ne<std::string>>("1,s");
|
||||
REQUIRE(c.valid());
|
||||
CHECK(tup == std::tuple{1, "s"});
|
||||
CHECK(tup == std::make_tuple(1, "s"));
|
||||
}
|
||||
{
|
||||
auto tup = c.convert<ss::ne<std::vector<int>>>("{1 2 3}");
|
||||
|
Loading…
Reference in New Issue
Block a user