Add unit test for option parsing
This commit is contained in:
parent
a9193840ad
commit
2617f5e022
24
src/option_types.cc
Normal file
24
src/option_types.cc
Normal file
|
@ -0,0 +1,24 @@
|
|||
#include "option_types.hh"
|
||||
#include "unit_tests.hh"
|
||||
|
||||
namespace Kakoune
|
||||
{
|
||||
|
||||
UnitTest test_option_parsing{[]{
|
||||
auto check = [](auto&& value, StringView str)
|
||||
{
|
||||
auto repr = option_to_string(value);
|
||||
kak_assert(repr == str);
|
||||
std::decay_t<decltype(value)> parsed;
|
||||
option_from_string(str, parsed);
|
||||
kak_assert(parsed == value);
|
||||
};
|
||||
|
||||
check(123, "123");
|
||||
check(true, "true");
|
||||
check(Vector<String>{"foo", "bar:", "baz"}, "foo:bar\\::baz");
|
||||
check(HashMap<String, int>{{"foo", 10}, {"b=r", 20}, {"b:z", 30}}, "foo=10:b\\=r=20:b\\:z=30");
|
||||
check(DebugFlags::Keys | DebugFlags::Hooks, "hooks|keys");
|
||||
}};
|
||||
|
||||
}
|
Loading…
Reference in New Issue
Block a user