|
@@ -16,7 +16,7 @@
|
|
|
|
|
|
#include <gtest/gtest.h>
|
|
#include <gtest/gtest.h>
|
|
|
|
|
|
-#include <data_def.h>
|
|
|
|
|
|
+#include <module_spec.h>
|
|
|
|
|
|
#include <fstream>
|
|
#include <fstream>
|
|
|
|
|
|
@@ -30,7 +30,7 @@ std::string specfile(const std::string name) {
|
|
}
|
|
}
|
|
|
|
|
|
void
|
|
void
|
|
-data_def_error(const std::string& file,
|
|
|
|
|
|
+module_spec_error(const std::string& file,
|
|
const std::string& error1,
|
|
const std::string& error1,
|
|
const std::string& error2 = "",
|
|
const std::string& error2 = "",
|
|
const std::string& error3 = "")
|
|
const std::string& error3 = "")
|
|
@@ -54,7 +54,7 @@ TEST(ModuleSpec, ReadingSpecfiles) {
|
|
dd = moduleSpecFromFile(specfile("spec2.spec"));
|
|
dd = moduleSpecFromFile(specfile("spec2.spec"));
|
|
EXPECT_EQ(dd.getFullSpec()->get("module_spec")
|
|
EXPECT_EQ(dd.getFullSpec()->get("module_spec")
|
|
->get("config_data")->size(), 6);
|
|
->get("config_data")->size(), 6);
|
|
- data_def_error("doesnotexist",
|
|
|
|
|
|
+ module_spec_error("doesnotexist",
|
|
"Error opening ",
|
|
"Error opening ",
|
|
specfile("doesnotexist"),
|
|
specfile("doesnotexist"),
|
|
": No such file or directory");
|
|
": No such file or directory");
|
|
@@ -68,54 +68,54 @@ TEST(ModuleSpec, ReadingSpecfiles) {
|
|
}
|
|
}
|
|
|
|
|
|
TEST(ModuleSpec, SpecfileItems) {
|
|
TEST(ModuleSpec, SpecfileItems) {
|
|
- data_def_error("spec3.spec",
|
|
|
|
|
|
+ module_spec_error("spec3.spec",
|
|
"item_name missing in {\"item_default\": 1, \"item_optional\": False, \"item_type\": \"integer\"}");
|
|
"item_name missing in {\"item_default\": 1, \"item_optional\": False, \"item_type\": \"integer\"}");
|
|
- data_def_error("spec4.spec",
|
|
|
|
|
|
+ module_spec_error("spec4.spec",
|
|
"item_type missing in {\"item_default\": 1, \"item_name\": \"item1\", \"item_optional\": False}");
|
|
"item_type missing in {\"item_default\": 1, \"item_name\": \"item1\", \"item_optional\": False}");
|
|
- data_def_error("spec5.spec",
|
|
|
|
|
|
+ module_spec_error("spec5.spec",
|
|
"item_optional missing in {\"item_default\": 1, \"item_name\": \"item1\", \"item_type\": \"integer\"}");
|
|
"item_optional missing in {\"item_default\": 1, \"item_name\": \"item1\", \"item_type\": \"integer\"}");
|
|
- data_def_error("spec6.spec",
|
|
|
|
|
|
+ module_spec_error("spec6.spec",
|
|
"item_default missing in {\"item_name\": \"item1\", \"item_optional\": False, \"item_type\": \"integer\"}");
|
|
"item_default missing in {\"item_name\": \"item1\", \"item_optional\": False, \"item_type\": \"integer\"}");
|
|
- data_def_error("spec9.spec",
|
|
|
|
|
|
+ module_spec_error("spec9.spec",
|
|
"item_default not of type integer");
|
|
"item_default not of type integer");
|
|
- data_def_error("spec10.spec",
|
|
|
|
|
|
+ module_spec_error("spec10.spec",
|
|
"item_default not of type real");
|
|
"item_default not of type real");
|
|
- data_def_error("spec11.spec",
|
|
|
|
|
|
+ module_spec_error("spec11.spec",
|
|
"item_default not of type boolean");
|
|
"item_default not of type boolean");
|
|
- data_def_error("spec12.spec",
|
|
|
|
|
|
+ module_spec_error("spec12.spec",
|
|
"item_default not of type string");
|
|
"item_default not of type string");
|
|
- data_def_error("spec13.spec",
|
|
|
|
|
|
+ module_spec_error("spec13.spec",
|
|
"item_default not of type list");
|
|
"item_default not of type list");
|
|
- data_def_error("spec14.spec",
|
|
|
|
|
|
+ module_spec_error("spec14.spec",
|
|
"item_default not of type map");
|
|
"item_default not of type map");
|
|
- data_def_error("spec15.spec",
|
|
|
|
|
|
+ module_spec_error("spec15.spec",
|
|
"badname is not a valid type name");
|
|
"badname is not a valid type name");
|
|
}
|
|
}
|
|
|
|
|
|
TEST(ModuleSpec, SpecfileConfigData)
|
|
TEST(ModuleSpec, SpecfileConfigData)
|
|
{
|
|
{
|
|
- data_def_error("spec7.spec",
|
|
|
|
|
|
+ module_spec_error("spec7.spec",
|
|
"module_name missing in {}");
|
|
"module_name missing in {}");
|
|
- data_def_error("spec8.spec",
|
|
|
|
|
|
+ module_spec_error("spec8.spec",
|
|
"Data specification does not contain module_spec element");
|
|
"Data specification does not contain module_spec element");
|
|
- data_def_error("spec16.spec",
|
|
|
|
|
|
+ module_spec_error("spec16.spec",
|
|
"config_data is not a list of elements");
|
|
"config_data is not a list of elements");
|
|
- data_def_error("spec21.spec",
|
|
|
|
|
|
+ module_spec_error("spec21.spec",
|
|
"commands is not a list of elements");
|
|
"commands is not a list of elements");
|
|
}
|
|
}
|
|
|
|
|
|
TEST(ModuleSpec, SpecfileCommands)
|
|
TEST(ModuleSpec, SpecfileCommands)
|
|
{
|
|
{
|
|
- data_def_error("spec17.spec",
|
|
|
|
|
|
+ module_spec_error("spec17.spec",
|
|
"command_name missing in {\"command_args\": [ {\"item_default\": \"\", \"item_name\": \"message\", \"item_optional\": False, \"item_type\": \"string\"} ], \"command_description\": \"Print the given message to stdout\"}");
|
|
"command_name missing in {\"command_args\": [ {\"item_default\": \"\", \"item_name\": \"message\", \"item_optional\": False, \"item_type\": \"string\"} ], \"command_description\": \"Print the given message to stdout\"}");
|
|
- data_def_error("spec18.spec",
|
|
|
|
|
|
+ module_spec_error("spec18.spec",
|
|
"command_args missing in {\"command_description\": \"Print the given message to stdout\", \"command_name\": \"print_message\"}");
|
|
"command_args missing in {\"command_description\": \"Print the given message to stdout\", \"command_name\": \"print_message\"}");
|
|
- data_def_error("spec19.spec",
|
|
|
|
|
|
+ module_spec_error("spec19.spec",
|
|
"command_args not of type list");
|
|
"command_args not of type list");
|
|
- data_def_error("spec20.spec",
|
|
|
|
|
|
+ module_spec_error("spec20.spec",
|
|
"somethingbad is not a valid type name");
|
|
"somethingbad is not a valid type name");
|
|
/*
|
|
/*
|
|
- data_def_error("spec22.spec",
|
|
|
|
|
|
+ module_spec_error("spec22.spec",
|
|
"");
|
|
"");
|
|
*/
|
|
*/
|
|
}
|
|
}
|