File: view.cpp

package info (click to toggle)
newsboat 2.38-0.1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 7,540 kB
  • sloc: cpp: 90,216; xml: 606; sh: 429; makefile: 369; ruby: 258; python: 239; ansic: 211; php: 63; awk: 59; perl: 38
file content (43 lines) | stat: -rw-r--r-- 1,170 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
#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]")
{

	const std::string example_ru("Инженеры из MIT");
	const std::string example_fr("Les mathématiques");

	const std::string example_en("Comparing Visual");

	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("Comparing_Visual.txt") ==
		0);

	REQUIRE(v.get_filename_suggestion(
			example_ru).compare("Инженеры_из_MIT.txt") != 0);
	REQUIRE(v.get_filename_suggestion(example_fr).compare("Les_mathématiques.txt") != 0);

	cfg.toggle("restrict-filename");

	REQUIRE(v.get_filename_suggestion(
			example_ru).compare("Инженеры из MIT.txt") == 0);
	REQUIRE(v.get_filename_suggestion(example_fr).compare("Les mathématiques.txt") == 0);
}