kakoune

Fork of kakoune, an acceptable text editor
git clone git://git.laack.co/kakoune.git
Log | Files | Refs

option_types.cc (805B)


      1 #include "option_types.hh"
      2 #include "debug.hh"
      3 #include "unit_tests.hh"
      4 
      5 namespace Kakoune
      6 {
      7 
      8 UnitTest test_option_parsing{[]{
      9     auto check = [](auto&& value, ConstArrayView<String> strs)
     10     {
     11         auto repr = option_to_strings(value);
     12         kak_assert(strs == ConstArrayView<String>{repr});
     13         auto parsed = option_from_strings(Meta::Type<std::remove_cvref_t<decltype(value)>>{}, strs);
     14         kak_assert(parsed == value);
     15     };
     16 
     17     check(123, {"123"});
     18     check(true, {"true"});
     19     check(Vector<String>{"foo", "bar:", "baz"}, {"foo", "bar:", "baz"});
     20     check(Vector<int>{10, 20, 30}, {"10", "20", "30"});
     21     check(HashMap<String, int>{{"foo", 10}, {"b=r", 20}, {"b:z", 30}}, {"foo=10", "b\\=r=20", "b:z=30"});
     22     check(DebugFlags::Keys | DebugFlags::Hooks, {"hooks|keys"});
     23 }};
     24 
     25 }