aboutsummaryrefslogtreecommitdiff
path: root/tests/src/confTest
diff options
context:
space:
mode:
Diffstat (limited to 'tests/src/confTest')
-rw-r--r--tests/src/confTest/confTest.cpp18
-rw-r--r--tests/src/confTest/invalidField.conf10
-rw-r--r--tests/src/confTest/invalidObject.conf12
-rw-r--r--tests/src/confTest/validProject.conf (renamed from tests/src/confTest/project.conf)0
4 files changed, 39 insertions, 1 deletions
diff --git a/tests/src/confTest/confTest.cpp b/tests/src/confTest/confTest.cpp
index 5bab144..17b5995 100644
--- a/tests/src/confTest/confTest.cpp
+++ b/tests/src/confTest/confTest.cpp
@@ -6,7 +6,7 @@ using namespace sibs;
TEST_CASE("parse config")
{
SibsConfig sibsConfig(Compiler::GCC, TINYDIR_STRING("tests/src/confTest"));
- Result<bool> result = Config::readFromFile(TINYDIR_STRING("tests/src/confTest/project.conf"), sibsConfig);
+ Result<bool> result = Config::readFromFile(TINYDIR_STRING("tests/src/confTest/validProject.conf"), sibsConfig);
if(result.isErr())
{
fprintf(stderr, "%s", result.getErrMsg().c_str());
@@ -28,3 +28,19 @@ TEST_CASE("parse config")
REQUIRE(catch2Dependency.name == "catch2");
REQUIRE(catch2Dependency.version == "1.0.0");
}
+
+TEST_CASE("parse config - invalid object")
+{
+ SibsConfig sibsConfig(Compiler::GCC, TINYDIR_STRING("tests/src/confTest"));
+ Result<bool> result = Config::readFromFile(TINYDIR_STRING("tests/src/confTest/invalidObject.conf"), sibsConfig);
+ REQUIRE(result.isErr());
+ REQUIRE(result.getErrMsg() == "Invalid config object \"invalidObj\"");
+}
+
+TEST_CASE("parse config - invalid field")
+{
+ SibsConfig sibsConfig(Compiler::GCC, TINYDIR_STRING("tests/src/confTest"));
+ Result<bool> result = Config::readFromFile(TINYDIR_STRING("tests/src/confTest/invalidField.conf"), sibsConfig);
+ REQUIRE(result.isErr());
+ REQUIRE(result.getErrMsg() == "Invalid field \"invalidField\" under object \"package\"");
+}
diff --git a/tests/src/confTest/invalidField.conf b/tests/src/confTest/invalidField.conf
new file mode 100644
index 0000000..c0f5892
--- /dev/null
+++ b/tests/src/confTest/invalidField.conf
@@ -0,0 +1,10 @@
+[package]
+name = "confTest"
+version = "0.1.0"
+type = "library"
+platforms = ["linux64", "win64"]
+invalidField = "value"
+
+[dependencies]
+xxhash = "0.1.0"
+catch2 = "1.0.0"
diff --git a/tests/src/confTest/invalidObject.conf b/tests/src/confTest/invalidObject.conf
new file mode 100644
index 0000000..fe9fc86
--- /dev/null
+++ b/tests/src/confTest/invalidObject.conf
@@ -0,0 +1,12 @@
+[package]
+name = "confTest"
+version = "0.1.0"
+type = "library"
+platforms = ["linux64", "win64"]
+
+[dependencies]
+xxhash = "0.1.0"
+catch2 = "1.0.0"
+
+[invalidObj]
+field = "value"
diff --git a/tests/src/confTest/project.conf b/tests/src/confTest/validProject.conf
index de5112d..de5112d 100644
--- a/tests/src/confTest/project.conf
+++ b/tests/src/confTest/validProject.conf