mirror of
https://github.com/mawww/kakoune.git
synced 2024-12-19 17:31:44 +03:00
add basic unit tests run at startup
This commit is contained in:
parent
0748aa042b
commit
a555e28b4e
@ -903,6 +903,8 @@ void exec_string(const CommandParameters& params,
|
||||
exec_keys(keys, context);
|
||||
}
|
||||
|
||||
void run_unit_tests();
|
||||
|
||||
int main(int argc, char* argv[])
|
||||
{
|
||||
NCurses::init(prompt_func, get_key_func);
|
||||
@ -914,6 +916,8 @@ int main(int argc, char* argv[])
|
||||
FilterRegistry filter_registry;
|
||||
GlobalHooksManager hooks_manager;
|
||||
|
||||
run_unit_tests();
|
||||
|
||||
command_manager.register_commands({ "e", "edit" }, edit<false>,
|
||||
CommandManager::None,
|
||||
PerArgumentCommandCompleter({ complete_filename }));
|
||||
|
33
src/unit_tests.cc
Normal file
33
src/unit_tests.cc
Normal file
@ -0,0 +1,33 @@
|
||||
#include "buffer.hh"
|
||||
#include "assert.hh"
|
||||
|
||||
using namespace Kakoune;
|
||||
|
||||
int test_buffer()
|
||||
{
|
||||
Buffer buffer("test", Buffer::Type::Scratch, "allo ?\nmais que fais la police\n hein ?\n youpi\n");
|
||||
assert(buffer.line_count() == 4);
|
||||
|
||||
BufferIterator i = buffer.begin();
|
||||
assert(*i == 'a');
|
||||
i += 6;
|
||||
assert(buffer.line_and_column_at(i) == BufferCoord{0 COMMA 6});
|
||||
i += 1;
|
||||
assert(buffer.line_and_column_at(i) == BufferCoord{1 COMMA 0});
|
||||
--i;
|
||||
assert(buffer.line_and_column_at(i) == BufferCoord{0 COMMA 6});
|
||||
++i;
|
||||
assert(buffer.line_and_column_at(i) == BufferCoord{1 COMMA 0});
|
||||
buffer.modify(Modification::make_insert(i, "tchou kanaky\n"));
|
||||
assert(buffer.line_count() == 5);
|
||||
|
||||
BufferIterator begin = buffer.iterator_at({ 4, 1 });
|
||||
BufferIterator end = buffer.iterator_at({ 4, 5 }) + 1;
|
||||
String str = buffer.string(begin, end);
|
||||
assert(str == "youpi");
|
||||
}
|
||||
|
||||
void run_unit_tests()
|
||||
{
|
||||
test_buffer();
|
||||
}
|
Loading…
Reference in New Issue
Block a user