Fix tests compilation
This commit is contained in:
parent
fcd0df2e96
commit
371f602100
5 changed files with 18 additions and 6 deletions
|
@ -101,6 +101,10 @@ public:
|
||||||
/// @param default_config Default config.
|
/// @param default_config Default config.
|
||||||
Hotkey(agi::fs::path const& file, std::pair<const char *, size_t> default_config);
|
Hotkey(agi::fs::path const& file, std::pair<const char *, size_t> default_config);
|
||||||
|
|
||||||
|
template<size_t N>
|
||||||
|
Hotkey(agi::fs::path const& file, const char (&default_config)[N])
|
||||||
|
: Hotkey(file, std::make_pair(default_config, N - 1)) { }
|
||||||
|
|
||||||
/// Scan for a matching key.
|
/// Scan for a matching key.
|
||||||
/// @param context Context requested.
|
/// @param context Context requested.
|
||||||
/// @param str Hyphen separated key sequence.
|
/// @param str Hyphen separated key sequence.
|
||||||
|
|
|
@ -56,6 +56,10 @@ public:
|
||||||
/// @param config File to load MRU values from
|
/// @param config File to load MRU values from
|
||||||
MRUManager(agi::fs::path const& config, std::pair<const char *, size_t> default_config, agi::Options *options = nullptr);
|
MRUManager(agi::fs::path const& config, std::pair<const char *, size_t> default_config, agi::Options *options = nullptr);
|
||||||
|
|
||||||
|
template<size_t N>
|
||||||
|
MRUManager(agi::fs::path const& file, const char (&default_config)[N])
|
||||||
|
: MRUManager(file, std::make_pair(default_config, N - 1)) { }
|
||||||
|
|
||||||
/// Destructor
|
/// Destructor
|
||||||
~MRUManager();
|
~MRUManager();
|
||||||
|
|
||||||
|
|
|
@ -76,6 +76,10 @@ public:
|
||||||
/// @param default_config Default configuration.
|
/// @param default_config Default configuration.
|
||||||
Options(agi::fs::path const& file, std::pair<const char *, size_t> default_config, const OptionSetting setting = NONE);
|
Options(agi::fs::path const& file, std::pair<const char *, size_t> default_config, const OptionSetting setting = NONE);
|
||||||
|
|
||||||
|
template<size_t N>
|
||||||
|
Options(agi::fs::path const& file, const char (&default_config)[N], const OptionSetting setting = NONE)
|
||||||
|
: Options(file, std::make_pair(default_config, N - 1), setting) { }
|
||||||
|
|
||||||
/// Destructor
|
/// Destructor
|
||||||
~Options();
|
~Options();
|
||||||
|
|
||||||
|
|
|
@ -17,13 +17,13 @@
|
||||||
|
|
||||||
#include "main.h"
|
#include "main.h"
|
||||||
|
|
||||||
|
static const char default_mru[] = "{\"Valid\" : []}";
|
||||||
|
|
||||||
class lagi_mru : public libagi {
|
class lagi_mru : public libagi {
|
||||||
protected:
|
protected:
|
||||||
std::string default_mru;
|
|
||||||
std::string conf_ok;
|
std::string conf_ok;
|
||||||
|
|
||||||
void SetUp() override {
|
void SetUp() override {
|
||||||
default_mru = "{\"Valid\" : []}";
|
|
||||||
conf_ok = "./data/mru_ok.json";
|
conf_ok = "./data/mru_ok.json";
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
|
@ -21,13 +21,13 @@
|
||||||
|
|
||||||
#include <fstream>
|
#include <fstream>
|
||||||
|
|
||||||
|
static const char default_opt[] = "{\"Valid\" : \"This is valid\"}";
|
||||||
|
|
||||||
class lagi_option : public libagi {
|
class lagi_option : public libagi {
|
||||||
protected:
|
protected:
|
||||||
std::string default_opt;
|
|
||||||
std::string conf_ok;
|
std::string conf_ok;
|
||||||
|
|
||||||
void SetUp() override {
|
void SetUp() override {
|
||||||
default_opt = "{\"Valid\" : \"This is valid\"}";
|
|
||||||
conf_ok = "data/options/string.json";
|
conf_ok = "data/options/string.json";
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
@ -107,7 +107,7 @@ TEST_F(lagi_option, bad_default_throws_and_null_is_rejected) {
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(lagi_option, nested_options) {
|
TEST_F(lagi_option, nested_options) {
|
||||||
const char *conf = "{ \"a\" : { \"b\" : { \"c\" : { \"c\" : \"value\" } } } }";
|
const char conf[] = "{ \"a\" : { \"b\" : { \"c\" : { \"c\" : \"value\" } } } }";
|
||||||
ASSERT_NO_THROW(agi::Options("", conf, agi::Options::FLUSH_SKIP));
|
ASSERT_NO_THROW(agi::Options("", conf, agi::Options::FLUSH_SKIP));
|
||||||
agi::Options opt("", conf, agi::Options::FLUSH_SKIP);
|
agi::Options opt("", conf, agi::Options::FLUSH_SKIP);
|
||||||
ASSERT_NO_THROW(opt.Get("a/b/c/c"));
|
ASSERT_NO_THROW(opt.Get("a/b/c/c"));
|
||||||
|
@ -169,7 +169,7 @@ TEST_F(lagi_option, flush_roundtrip) {
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(lagi_option, mixed_valid_and_invalid_in_user_conf_loads_all_valid) {
|
TEST_F(lagi_option, mixed_valid_and_invalid_in_user_conf_loads_all_valid) {
|
||||||
const char *def = "{\"1\" : false, \"2\" : 1, \"3\" : false }";
|
const char def[] = "{\"1\" : false, \"2\" : 1, \"3\" : false }";
|
||||||
agi::Options opt("data/options/all_bool.json", def, agi::Options::FLUSH_SKIP);
|
agi::Options opt("data/options/all_bool.json", def, agi::Options::FLUSH_SKIP);
|
||||||
ASSERT_NO_THROW(opt.ConfigUser());
|
ASSERT_NO_THROW(opt.ConfigUser());
|
||||||
EXPECT_EQ(true, opt.Get("1")->GetBool());
|
EXPECT_EQ(true, opt.Get("1")->GetBool());
|
||||||
|
|
Loading…
Reference in a new issue