16 #include <catch2/catch.hpp>
20 struct CreateOpGraphFromConfigTest {
21 std::string input_description;
27 template<
typename Test>
28 void run_createOpGraphFromConfig_test(
const Test& test);
33 const CreateOpGraphFromConfigTest tests[] = {
37 cg.
insert(
"a", {{
"opcode",
"add"}});
49 cg.
insert(
"a", {{
"opcode",
"add"}});
50 cg.
insert(
"b", {{
"opcode",
"add"}});
64 cg.
insert(
"a", {{
"opcode",
"add"}}).first,
65 cg.insert(
"b", {{
"opcode",
"add"}}).first,
81 cg.
insert(
"a", {{
"opcode",
"const"}, {
"constVal",
"4"}});
93 const auto& test_it = GENERATE_REF(range((std::ptrdiff_t)0, std::distance(
begin(tests),
end(tests))));
94 run_createOpGraphFromConfig_test(tests[test_it]);
100 OpGraph do_createOpGraphFromConfig(
const T& input) {
103 }
catch (
const std::exception& e) {
104 std::ostringstream s;
105 s <<
"Exception when creating from configuration: " << e.what()
106 <<
"\nInput was:\n" << input;
107 std::throw_with_nested(std::logic_error(s.str()));
111 template<
typename Test>
112 void run_createOpGraphFromConfig_test(
const Test& test) {
113 GIVEN(
"A '" << test.input_description <<
"' configuration") {
114 WHEN(
"Creating an OpGraph from it") {
115 THEN(
"The result should " << (test.expect_to_parse ?
"be as expected" :
"fail to parse")) {
116 if (test.expect_to_parse) {
117 const auto actual = do_createOpGraphFromConfig(test.input);
118 CHECK(actual == test.expected);
120 REQUIRE_THROWS(do_createOpGraphFromConfig(test.input));