diff options
| author | Maxime Coste <frrrwww@gmail.com> | 2012-04-01 15:39:53 +0000 |
|---|---|---|
| committer | Maxime Coste <frrrwww@gmail.com> | 2012-04-01 15:39:53 +0000 |
| commit | 7f425c4467b723bd228b37890376e239ee55ed69 (patch) | |
| tree | bdca9da00ddb938650838d76e325b2ea75bedb90 /src | |
| parent | 07e1fcf67b830a22a59eb61671a7ba603954a2a9 (diff) | |
add an editor unit test
Diffstat (limited to 'src')
| -rw-r--r-- | src/unit_tests.cc | 21 |
1 files changed, 20 insertions, 1 deletions
diff --git a/src/unit_tests.cc b/src/unit_tests.cc index 3cb7598c..8fee1000 100644 --- a/src/unit_tests.cc +++ b/src/unit_tests.cc @@ -1,9 +1,11 @@ #include "buffer.hh" #include "assert.hh" +#include "editor.hh" +#include "selectors.hh" using namespace Kakoune; -int test_buffer() +void test_buffer() { Buffer buffer("test", Buffer::Type::Scratch, "allo ?\nmais que fais la police\n hein ?\n youpi\n"); assert(buffer.line_count() == 4); @@ -27,7 +29,24 @@ int test_buffer() assert(str == "youpi"); } +void test_editor() +{ + Buffer buffer("test", Buffer::Type::Scratch, "test\n\nyoupi\n"); + Editor editor(buffer); + + using namespace std::placeholders; + + editor.select(select_whole_buffer); + editor.multi_select(std::bind(select_all_matches, _1, "\n\\h*")); + for (auto& sel : editor.selections()) + { + assert(*sel.begin() == '\n'); + editor.buffer().modify(Modification::make_erase(sel.begin(), sel.end())); + } +} + void run_unit_tests() { test_buffer(); + test_editor(); } |
