diff options
author | Aqua-sama <aqua@iserlohn-fortress.net> | 2020-03-22 14:59:04 +0200 |
---|---|---|
committer | Aqua-sama <aqua@iserlohn-fortress.net> | 2020-03-22 14:59:04 +0200 |
commit | 74870600fa54a48d4c1ce4b19861a9b0ce027fee (patch) | |
tree | d79eb50c18f1f62e937a1d1fe2e7180c7c14d06a /test/conf | |
parent | Remove ProfileInterface (diff) | |
download | smolbote-74870600fa54a48d4c1ce4b19861a9b0ce027fee.tar.xz |
lib/configuration improvements
Configuration changes:
- Configuration::value return type is now [[nodiscard]]
- Configuration::value<T> is now a generic template that only works with
the exact types of the underlying std::variant
- Add Configuration::value<concept_value_t> for standard library types
compatible with the types of std::variant
- Add Configuration::shortcut<> placeholder, and QAction and
QKeySequence specializations as a convenient way to set up shortcuts
- Deprecate setShortcut
- Add Configuration::read_file convenience member that takes file path
as parameter
Format changes:
- Configuration files can now have sections, specified as [section
name]. Section names are prepended to keys. Section names cannot be
nested.
- Configuration files can now have @@include directives, causing another
file to be read as well. The included file is not treated as nested into
a section, and will overwrite values previously set.
Others:
- add some tests for libconfiguration. QAction/QKeySequence require a
QApplication be set up, so the test application may require running
xorg/wayland.
old coverage: lines: 15.6% (960 out of 6172) branches: 9.9% (1187 out of 12012)
new coverage: lines: 17.1% (1067 out of 6254) branches: 11.0% (1388 out of 12644)
Diffstat (limited to 'test/conf')
-rw-r--r-- | test/conf/main.cpp | 54 | ||||
-rw-r--r-- | test/conf/meson.build | 6 | ||||
-rw-r--r-- | test/conf/smolbote.cfg | 5 |
3 files changed, 0 insertions, 65 deletions
diff --git a/test/conf/main.cpp b/test/conf/main.cpp deleted file mode 100644 index e499a4d..0000000 --- a/test/conf/main.cpp +++ /dev/null @@ -1,54 +0,0 @@ -#include <fstream> -#include <iostream> -#include <string> -#include "configuration.h" -#include <cassert> - -int main(int, char**) -{ - std::fstream fs; - fs.open("smolbote.cfg", std::fstream::in); - assert(fs.is_open()); - - { - auto value_map = std::make_unique<Configuration, std::initializer_list<std::pair<std::string, conf_value_t>>>({ - { "test", std::string("unknown") }, - { "integer-1", 20 }, - { "integer-2", 30 } - }); - value_map->read(fs); - - Configuration::move_global(std::move(value_map)); - fs.close(); - } - - { - Configuration g; - assert(g.value<std::string>("test") == "value"); - assert(g.value<std::string>("plugins.path") == "/usr/local/lib/smolbote/plugins"); - assert(g.value<int>("integer-1") == 20); - assert(g.value<int>("integer-2") == 22); - } - -/* - { - const Configuration conf(std::move(value_map)); - - assert(conf.value<std::string>("test") == "value"); - assert(conf.value<std::string>("plugins.path") == "/usr/local/lib/smolbote/plugins"); - assert(conf.value<int>("integer-1") == 20); - assert(conf.value<int>("integer-2") == 22); - } -*/ - // Configuration is now destroyed - - - // This should be a compiler warning - //const Configuration c(std::move(value_map)); - //assert(c.value<std::string>("test") == "value"); - - // This should be a compiler warning and runtime error - //assert(value_map.value<std::string>("test").value() == "value"); - - return 0; -} diff --git a/test/conf/meson.build b/test/conf/meson.build deleted file mode 100644 index de67db7..0000000 --- a/test/conf/meson.build +++ /dev/null @@ -1,6 +0,0 @@ -e = executable('conf_test', - dependencies: [dep_qt5, dep_configuration], - sources: 'main.cpp' -) - -test('conf_test', e, workdir : meson.source_root()/'test/conf') diff --git a/test/conf/smolbote.cfg b/test/conf/smolbote.cfg deleted file mode 100644 index 25467ef..0000000 --- a/test/conf/smolbote.cfg +++ /dev/null @@ -1,5 +0,0 @@ -# this is a comment -test = value -plugins.path = /usr/local/lib/smolbote/plugins - -integer-2 = 22 |