mirror of
https://github.com/falk-werner/webfused
synced 2026-03-02 04:09:19 +00:00
added skeleton of config
This commit is contained in:
@@ -1,13 +1,57 @@
|
||||
#include <gtest/gtest.h>
|
||||
#include <libconfig.h>
|
||||
|
||||
#include "webfused/config/factory.h"
|
||||
#include "webfused/config/config.h"
|
||||
|
||||
TEST(config, is_loadable)
|
||||
{
|
||||
config_t config;
|
||||
config_init(&config);
|
||||
struct wfd_config * config = wfd_config_load_file("webfused.conf");
|
||||
ASSERT_NE(nullptr, config);
|
||||
|
||||
int result = config_read_file(&config, "webfused.conf");
|
||||
ASSERT_EQ(CONFIG_TRUE, result);
|
||||
wfd_config_dispose(config);
|
||||
}
|
||||
|
||||
config_destroy(&config);
|
||||
TEST(config, minimal_config)
|
||||
{
|
||||
char const minimal[] = "version = { major = 1, minor = 0 }\n";
|
||||
struct wfd_config * config = wfd_config_load_string(minimal);
|
||||
ASSERT_NE(nullptr, config);
|
||||
|
||||
wfd_config_dispose(config);
|
||||
}
|
||||
|
||||
TEST(config, invalid_major_version_too_low)
|
||||
{
|
||||
char const too_low[] = "version = { major = 0, minor = 0 }\n";
|
||||
|
||||
struct wfd_config * config = wfd_config_load_string(too_low);
|
||||
ASSERT_EQ(nullptr, config);
|
||||
}
|
||||
|
||||
TEST(config, invalid_major_version_too_high)
|
||||
{
|
||||
char const too_high[] = "version = { major = 2, minor = 0 }\n";
|
||||
|
||||
struct wfd_config * config = wfd_config_load_string(too_high);
|
||||
ASSERT_EQ(nullptr, config);
|
||||
}
|
||||
|
||||
TEST(config, valid_older_minor)
|
||||
{
|
||||
char const valid[] = "version = { major = 1, minor = -1 }\n";
|
||||
|
||||
struct wfd_config * config = wfd_config_load_string(valid);
|
||||
ASSERT_NE(nullptr, config);
|
||||
|
||||
wfd_config_dispose(config);
|
||||
}
|
||||
|
||||
TEST(config, valid_newer_minor)
|
||||
{
|
||||
char const valid[] = "version = { major = 1, minor = 1 }\n";
|
||||
|
||||
struct wfd_config * config = wfd_config_load_string(valid);
|
||||
ASSERT_NE(nullptr, config);
|
||||
|
||||
wfd_config_dispose(config);
|
||||
}
|
||||
Reference in New Issue
Block a user