diff options
author | crimsonskylark <47747084+crimsonskylark@users.noreply.github.com> | 2021-04-30 12:42:24 -0300 |
---|---|---|
committer | crimsonskylark <47747084+crimsonskylark@users.noreply.github.com> | 2021-04-30 12:42:24 -0300 |
commit | 6fc04e2e4c3d0d0c80832519962db9660955b5b8 (patch) | |
tree | 29fd78400b24f9b558e439d0b514312c23554374 /test | |
parent | a7b84c0bb5e19c379f8174df3964f127b2d7c08e (diff) |
Rename `ascii-only-filename` to `restrict-filename`
This commit renames the recently introduced setting, updates its documentation and adds testing to `get_filename_suggestion()`.
Diffstat (limited to 'test')
-rw-r--r-- | test/view.cpp | 40 |
1 files changed, 40 insertions, 0 deletions
diff --git a/test/view.cpp b/test/view.cpp new file mode 100644 index 00000000..3a28807e --- /dev/null +++ b/test/view.cpp @@ -0,0 +1,40 @@ +#include "view.h" + +#include <string> + +#include "3rd-party/catch.hpp" +#include "controller.h" +#include "configpaths.h" +#include "cache.h" + +using namespace newsboat; + +TEST_CASE("get_filename_suggestion() normalizes filenames for saving articles", "[View]") { + + std::string example_ru("Инженеры из MIT придумали остроумный способ очистки металлов от соли и грязи"); + std::string example_fr("Les mathématiques ont-elles pris le pouvoir sur le réel ?"); + + std::string example_en("Comparing Visual Reasoning in Humans and AI"); + std::string example_en_default("Comparing_Visual_Reasoning_in_Humans_and_AI.txt"); + + ConfigPaths paths{}; + Controller c(paths); + newsboat::View v(&c); + + ConfigContainer cfg{}; + Cache rsscache(":memory:", &cfg); + + v.set_config_container(&cfg); + c.set_view(&v); + + // Default case is exclusively ASCII characters. Should never fail. + REQUIRE(v.get_filename_suggestion(example_en).compare(example_en_default) == 0); + + REQUIRE(v.get_filename_suggestion(example_ru).compare(example_ru.append(".txt")) != 0); + REQUIRE(v.get_filename_suggestion(example_fr).compare(example_fr.append(".txt")) != 0); + + cfg.toggle("restrict-filename"); + + REQUIRE(v.get_filename_suggestion(example_ru).compare(example_ru.append(".txt")) == 0); + REQUIRE(v.get_filename_suggestion(example_fr).compare(example_fr.append(".txt")) == 0); +}
\ No newline at end of file |