aboutsummaryrefslogtreecommitdiff
path: root/test/configparser.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'test/configparser.cpp')
-rw-r--r--test/configparser.cpp36
1 files changed, 21 insertions, 15 deletions
diff --git a/test/configparser.cpp b/test/configparser.cpp
index 65efbd63..78faac58 100644
--- a/test/configparser.cpp
+++ b/test/configparser.cpp
@@ -1,5 +1,3 @@
-#define ENABLE_IMPLICIT_FILEPATH_CONVERSIONS
-
#include "configparser.h"
#include <fstream>
@@ -184,7 +182,8 @@ TEST_CASE("evaluate_backticks replaces command in backticks with its output",
ConfigParser cfgparser;
KeyMap keys(KM_NEWSBOAT);
cfgparser.register_handler("bind-key", keys);
- REQUIRE_NOTHROW(cfgparser.parse_file("data/config-space-backticks"));
+ REQUIRE_NOTHROW(cfgparser.parse_file(
+ Filepath::from_locale_string("data/config-space-backticks")));
REQUIRE(keys.get_operation(KeyCombination("s"), "feedlist") == OP_SORT);
}
@@ -222,7 +221,7 @@ TEST_CASE("\"unbind-key -a\" removes all key bindings", "[ConfigParser]")
SECTION("In all contexts by default") {
KeyMap keys(KM_NEWSBOAT);
cfgparser.register_handler("unbind-key", keys);
- cfgparser.parse_file("data/config-unbind-all");
+ cfgparser.parse_file(Filepath::from_locale_string("data/config-unbind-all"));
for (int i = OP_QUIT; i < OP_NB_MAX; ++i) {
REQUIRE(keys.get_keys(static_cast<Operation>(i),
@@ -235,7 +234,7 @@ TEST_CASE("\"unbind-key -a\" removes all key bindings", "[ConfigParser]")
SECTION("For a specific context") {
KeyMap keys(KM_NEWSBOAT);
cfgparser.register_handler("unbind-key", keys);
- cfgparser.parse_file("data/config-unbind-all-context");
+ cfgparser.parse_file(Filepath::from_locale_string("data/config-unbind-all-context"));
INFO("it doesn't affect the help dialog");
KeyMap default_keys(KM_NEWSBOAT);
@@ -256,7 +255,8 @@ TEST_CASE("Concatenates lines that end with a backslash", "[ConfigParser]")
ConfigParser cfgparser;
KeyMap k(KM_NEWSBOAT);
cfgparser.register_handler("macro", k);
- REQUIRE_NOTHROW(cfgparser.parse_file("data/config-multi-line"));
+ REQUIRE_NOTHROW(cfgparser.parse_file(
+ Filepath::from_locale_string("data/config-multi-line")));
auto p_macro = k.get_macro(KeyCombination("p"));
REQUIRE(!p_macro.empty());
REQUIRE(p_macro[0].op == newsboat::OP_OPEN);
@@ -277,40 +277,46 @@ TEST_CASE("`include` directive includes other config files", "[ConfigParser]")
// TODO: error messages should be more descriptive than "file couldn't be opened"
ConfigParser cfgparser;
SECTION("Errors if file is not found") {
- REQUIRE_THROWS_AS(cfgparser.parse_file("data/config-missing-include"),
+ REQUIRE_THROWS_AS(cfgparser.parse_file(
+ Filepath::from_locale_string("data/config-missing-include")),
ConfigException);
}
SECTION("Errors on invalid UTF-8 in file") {
- REQUIRE_THROWS_AS(cfgparser.parse_file("data/config-invalid-utf-8"),
+ REQUIRE_THROWS_AS(cfgparser.parse_file(
+ Filepath::from_locale_string("data/config-invalid-utf-8")),
ConfigException);
}
SECTION("Terminates on recursive include") {
- REQUIRE_THROWS_AS(cfgparser.parse_file("data/config-recursive-include"),
+ REQUIRE_THROWS_AS(cfgparser.parse_file(
+ Filepath::from_locale_string("data/config-recursive-include")),
ConfigException);
}
SECTION("Successfully includes existing file") {
- REQUIRE_NOTHROW(cfgparser.parse_file("data/config-absolute-include"));
+ REQUIRE_NOTHROW(cfgparser.parse_file(
+ Filepath::from_locale_string("data/config-absolute-include")));
}
SECTION("Success on relative includes") {
- REQUIRE_NOTHROW(cfgparser.parse_file("data/config-relative-include"));
+ REQUIRE_NOTHROW(cfgparser.parse_file(
+ Filepath::from_locale_string("data/config-relative-include")));
}
SECTION("Diamond of death includes pass") {
- REQUIRE_NOTHROW(cfgparser.parse_file("data/diamond-of-death/A"));
+ REQUIRE_NOTHROW(cfgparser.parse_file(
+ Filepath::from_locale_string("data/diamond-of-death/A")));
}
SECTION("File including itself only gets evaluated once") {
test_helpers::TempFile testfile;
test_helpers::EnvVar tmpfile("TMPFILE"); // $TMPFILE used in conf file
- tmpfile.set(testfile.get_path());
+ tmpfile.set(testfile.get_path().to_locale_string());
// recursive includes don't fail
REQUIRE_NOTHROW(
- cfgparser.parse_file("data/recursive-include-side-effect"));
+ cfgparser.parse_file(Filepath::from_locale_string("data/recursive-include-side-effect")));
// I think it will never get below here and fail? If it recurses, the above fails
int line_count = 0;
{
// from https://stackoverflow.com/a/19140230
- std::ifstream in(testfile.get_path());
+ std::ifstream in(testfile.get_path().to_locale_string());
std::string line;
while (std::getline(in, line)) {
line_count++;