2018-05-27 02:41:02 +02:00
|
|
|
#include "option_types.hh"
|
|
|
|
#include "unit_tests.hh"
|
|
|
|
|
|
|
|
namespace Kakoune
|
|
|
|
{
|
|
|
|
|
|
|
|
UnitTest test_option_parsing{[]{
|
2018-05-30 15:23:38 +02:00
|
|
|
auto check = [](auto&& value, ConstArrayView<String> strs)
|
2018-05-27 02:41:02 +02:00
|
|
|
{
|
2018-05-30 15:23:38 +02:00
|
|
|
auto repr = option_to_strings(value);
|
|
|
|
kak_assert(strs == ConstArrayView<String>{repr});
|
2020-11-16 21:02:40 +01:00
|
|
|
auto parsed = option_from_strings(Meta::Type<std::remove_cvref_t<decltype(value)>>{}, strs);
|
2018-05-27 02:41:02 +02:00
|
|
|
kak_assert(parsed == value);
|
|
|
|
};
|
|
|
|
|
2018-05-30 15:23:38 +02:00
|
|
|
check(123, {"123"});
|
|
|
|
check(true, {"true"});
|
|
|
|
check(Vector<String>{"foo", "bar:", "baz"}, {"foo", "bar:", "baz"});
|
|
|
|
check(Vector<int>{10, 20, 30}, {"10", "20", "30"});
|
|
|
|
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"});
|
2018-05-27 02:41:02 +02:00
|
|
|
}};
|
|
|
|
|
|
|
|
}
|