void configcontainer::register_commands(configparser& cfgparser) {
	// this registers the config options defined above in the configuration parser
	// -> if the resp. config option is encountered, it is passed to the configcontainer
	for (auto cfg : config_data) {
		cfgparser.register_handler(cfg.first, this);
	}
}
Beispiel #2
0
void colormanager::register_commands(configparser& cfgparser) {
	cfgparser.register_handler("color", this);
}
Beispiel #3
0
#include "catch.hpp"

#include <configcontainer.h>
#include <configparser.h>
#include <keymap.h>

using namespace newsbeuter;

TEST_CASE("ConfigContainer behaves correctly") {
	configcontainer * cfg = new configcontainer();
	configparser cfgparser;
	cfg->register_commands(cfgparser);
	keymap k(KM_NEWSBEUTER);
	cfgparser.register_handler("macro", &k);

	SECTION("Parses test config without exceptions") {
		REQUIRE_NOTHROW(cfgparser.parse("test-config.txt"));

		SECTION("bool value") {
			REQUIRE(cfg->get_configvalue("show-read-feeds") == "no");
			REQUIRE(cfg->get_configvalue_as_bool("show-read-feeds") == false);
		}

		SECTION("string value") {
			REQUIRE(cfg->get_configvalue("browser") == "firefox");
		}

		SECTION("integer value") {
			REQUIRE(cfg->get_configvalue("max-items") == "100");
			REQUIRE(cfg->get_configvalue_as_int("max-items") == 100);
		}