From 7f02ef334f00ef00afeef2ebd6e6d73f87d70d63 Mon Sep 17 00:00:00 2001 From: Maxime Coste Date: Wed, 30 Jan 2013 19:16:36 +0100 Subject: [PATCH] add some tests for Key functions --- src/unit_tests.cc | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/src/unit_tests.cc b/src/unit_tests.cc index 5e91de03..fe5247c5 100644 --- a/src/unit_tests.cc +++ b/src/unit_tests.cc @@ -2,6 +2,7 @@ #include "assert.hh" #include "editor.hh" #include "selectors.hh" +#include "keys.hh" using namespace Kakoune; @@ -104,10 +105,26 @@ void test_string() assert(splited[3] == "tchou"); } +void test_keys() +{ + std::vector keys{ + { ' ' }, + { 'c' }, + { Key::Modifiers::Alt, 'j' }, + { Key::Modifiers::Control, 'r' } + }; + String keys_as_str; + for (auto& key : keys) + keys_as_str += key_to_str(key); + auto parsed_keys = parse_keys(keys_as_str); + assert(keys == parsed_keys); +} + void run_unit_tests() { test_utf8(); test_string(); + test_keys(); test_buffer(); test_editor(); test_incremental_inserter();