aboutsummaryrefslogtreecommitdiff
path: root/tests/src/v2script/Parser.cpp
diff options
context:
space:
mode:
author George L. Albany <Megacake1234@gmail.com>2024-08-04 22:17:07 +0200
committer GitHub <noreply@github.com>2024-08-04 22:17:07 +0200
commitefcc544bb36c80efb911390855c0123d5d11f742 (patch)
tree210f992e56a32a832bc775a5b2c73f032bb3aca0 /tests/src/v2script/Parser.cpp
parent2addc7763556ff76809f14e2063d1452aa9d6275 (diff)
parentdf819d120610b7d3737f8b8e2ad03b7e88fb924c (diff)
Merge pull request #55 from OpenVicProject/fixup/errors
Add error kind and error message checks to empty tests
Diffstat (limited to 'tests/src/v2script/Parser.cpp')
-rw-r--r--tests/src/v2script/Parser.cpp31
1 files changed, 30 insertions, 1 deletions
diff --git a/tests/src/v2script/Parser.cpp b/tests/src/v2script/Parser.cpp
index 856e5fb..45d9f44 100644
--- a/tests/src/v2script/Parser.cpp
+++ b/tests/src/v2script/Parser.cpp
@@ -7,6 +7,8 @@
#include <dryad/node.hpp>
+#include <fmt/core.h>
+
#include "Helper.hpp"
#include <detail/NullBuff.hpp>
#include <range/v3/iterator/operations.hpp>
@@ -99,19 +101,46 @@ TEST_CASE("V2Script File (HasCstr) Simple Parse", "[v2script-file-simple-parse][
}
TEST_CASE("V2Script File (const char*) Handle Empty Path String Parse", "[v2script-file-parse][handle-string][char-ptr][empty-path]") {
+ static constexpr auto error_fmt =
+#ifdef __APPLE__
+ "error: OS file error for '{}'.";
+#elif defined(_WIN32)
+ "error: OS file error for '{}'.";
+#else
+ "error: File '{}' not found.";
+#endif
+ std::error_code fs_err;
+ const auto fs_path = std::filesystem::weakly_canonical("", fs_err);
+
Parser parser(ovdl::detail::cnull);
parser.load_from_file("");
CHECK_OR_RETURN(!parser.get_errors().empty());
+
+ auto error = parser.get_errors().front();
+ CHECK_OR_RETURN(error != nullptr);
+
+ CHECK_OR_RETURN(error->kind() == ovdl::error::ErrorKind::BufferError);
+ CHECK_OR_RETURN(parser.error(error) == fmt::format(error_fmt, fs_path.string()));
}
TEST_CASE("V2Script File (const char*) Handle Non-existent Path String Parse", "[v2script-file-parse][handle-string][char-ptr][nonexistent-path]") {
+ static constexpr auto path = "./Idontexist";
+ std::error_code fs_err;
+ const auto fs_path = std::filesystem::weakly_canonical(path, fs_err);
+
Parser parser(ovdl::detail::cnull);
- parser.load_from_file("./Idontexist");
+ parser.load_from_file(path);
CHECK_OR_RETURN(!parser.get_errors().empty());
+
+ auto error = parser.get_errors().front();
+ CHECK_OR_RETURN(error != nullptr);
+
+ CHECK_OR_RETURN(error->kind() == ovdl::error::ErrorKind::BufferError);
+ CHECK_OR_RETURN(parser.error(error) == fmt::format("error: File '{}' not found.", fs_path.string()));
}
TEST_CASE("V2Script Identifier Simple Parse", "[v2script-id-simple-parse]") {