summaryrefslogtreecommitdiff
path: root/test/buffer.c
diff options
context:
space:
mode:
authorAlbert Cervin <albert@acervin.com>2023-04-06 23:23:46 +0200
committerAlbert Cervin <albert@acervin.com>2023-05-01 22:19:14 +0200
commita123725a12e948d78badb2cb686d38548f1c633b (patch)
treec92c46134ef5536fbbf3bf08983c4f0dea1aaf58 /test/buffer.c
parentb5ed4cf757afc50afb6ac499eee7b87a2648fa4c (diff)
downloaddged-a123725a12e948d78badb2cb686d38548f1c633b.tar.gz
dged-a123725a12e948d78badb2cb686d38548f1c633b.tar.xz
dged-a123725a12e948d78badb2cb686d38548f1c633b.zip
Implement window handling
Also implement searching. fix undo boundaries when it checked for other save point, it used && instead of == which caused it to overwrite other types. Fix bytes vs chars bug in text_get_region
Diffstat (limited to 'test/buffer.c')
-rw-r--r--test/buffer.c43
1 files changed, 22 insertions, 21 deletions
diff --git a/test/buffer.c b/test/buffer.c
index 38ce468..a4ac754 100644
--- a/test/buffer.c
+++ b/test/buffer.c
@@ -1,45 +1,46 @@
-#include "assert.h"
-#include "test.h"
+#include <string.h>
-#include "buffer.h"
+#include "dged/buffer.h"
-#include <string.h>
+#include "assert.h"
+#include "test.h"
void test_move() {
- struct buffer b = buffer_create("test-buffer", false);
- ASSERT(b.dot.col == 0 && b.dot.line == 0,
+ struct buffer b = buffer_create("test-buffer");
+ struct buffer_view v = buffer_view_create(&b, false, false);
+ ASSERT(v.dot.col == 0 && v.dot.line == 0,
"Expected dot to be at buffer start");
// make sure we cannot move now
- buffer_backward_char(&b);
- buffer_backward_line(&b);
- ASSERT(b.dot.col == 0 && b.dot.line == 0,
+ buffer_backward_char(&v);
+ buffer_backward_line(&v);
+ ASSERT(v.dot.col == 0 && v.dot.line == 0,
"Expected to not be able to move backward in empty buffer");
- buffer_forward_char(&b);
- buffer_forward_line(&b);
- ASSERT(b.dot.col == 0 && b.dot.line == 0,
+ buffer_forward_char(&v);
+ buffer_forward_line(&v);
+ ASSERT(v.dot.col == 0 && v.dot.line == 0,
"Expected to not be able to move forward in empty buffer");
// add some text and try again
const char *txt = "testing movement";
- int lineindex = buffer_add_text(&b, (uint8_t *)txt, strlen(txt));
+ int lineindex = buffer_add_text(&v, (uint8_t *)txt, strlen(txt));
ASSERT(lineindex + 1 == 1, "Expected buffer to have one line");
- buffer_beginning_of_line(&b);
- buffer_forward_char(&b);
- ASSERT(b.dot.col == 1 && b.dot.line == 0,
+ buffer_beginning_of_line(&v);
+ buffer_forward_char(&v);
+ ASSERT(v.dot.col == 1 && v.dot.line == 0,
"Expected to be able to move forward by one char");
// now we have two lines
const char *txt2 = "\n";
- int lineindex2 = buffer_add_text(&b, (uint8_t *)txt2, strlen(txt2));
+ int lineindex2 = buffer_add_text(&v, (uint8_t *)txt2, strlen(txt2));
ASSERT(lineindex2 + 1 == 2, "Expected buffer to have two lines");
- buffer_backward_line(&b);
- buffer_beginning_of_line(&b);
- buffer_backward_char(&b);
+ buffer_backward_line(&v);
+ buffer_beginning_of_line(&v);
+ buffer_backward_char(&v);
ASSERT(
- b.dot.col == 0 && b.dot.line == 0,
+ v.dot.col == 0 && v.dot.line == 0,
"Expected to not be able to move backwards when at beginning of buffer");
buffer_destroy(&b);