summaryrefslogtreecommitdiff
path: root/src/option_types.cc
blob: f32e361f2d806f8007b5b9231ddda1d241988d54 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
#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);
        auto parsed = option_from_string(Meta::Type<std::decay_t<decltype(value)>>{}, str);
        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");
}};

}