From 7f425c4467b723bd228b37890376e239ee55ed69 Mon Sep 17 00:00:00 2001 From: Maxime Coste Date: Sun, 1 Apr 2012 15:39:53 +0000 Subject: [PATCH] add an editor unit test --- src/unit_tests.cc | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) 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(); }