31 lines
1.2 KiB
C++
31 lines
1.2 KiB
C++
#include <iostream>
|
|
#include <filesystem>
|
|
#include <fstream>
|
|
|
|
#include "catch.hpp"
|
|
|
|
#include "daggy/Utilities.hpp"
|
|
|
|
namespace fs = std::filesystem;
|
|
|
|
TEST_CASE("Parameter Parsing", "[utilities_parse_parameters]") {
|
|
SECTION("Basic Parse") {
|
|
std::string testParams{R"({"DATE": ["2021-05-06", "2021-05-07" ], "SOURCE": "name"})"};
|
|
auto params = daggy::parseParameters(testParams);
|
|
REQUIRE(params.size() == 2);
|
|
REQUIRE(std::holds_alternative<std::vector<std::string>>(params["DATE"]));
|
|
REQUIRE(std::holds_alternative<std::string>(params["SOURCE"]));
|
|
}
|
|
SECTION("Invalid JSON") {
|
|
std::string testParams{R"({"DATE": ["2021-05-06", "2021-05-07" ], "SOURCE": "name")"};
|
|
REQUIRE_THROWS(daggy::parseParameters(testParams));
|
|
}
|
|
SECTION("Non-string Keys") {
|
|
std::string testParams{R"({"DATE": ["2021-05-06", "2021-05-07" ], 6: "name"})"};
|
|
REQUIRE_THROWS(daggy::parseParameters(testParams));
|
|
}
|
|
SECTION("Non-array/Non-string values") {
|
|
std::string testParams{R"({"DATE": ["2021-05-06", "2021-05-07" ], "SOURCE": {"name": "kevin"}})"};
|
|
REQUIRE_THROWS(daggy::parseParameters(testParams));
|
|
}
|
|
} |