diff options
| author | Albert Cervin <albert@acervin.com> | 2025-11-26 20:07:43 +0100 |
|---|---|---|
| committer | Albert Cervin <albert@acervin.com> | 2025-11-26 20:07:43 +0100 |
| commit | 8de2328d2e712fc892d6f02d92feb88fa857e85b (patch) | |
| tree | 22a710957ed42cee9bb3afef93f42d2e72106d9f /test | |
| parent | a4056eb9de575463ccc9f53db8952e49801a8cf3 (diff) | |
| download | dged-8de2328d2e712fc892d6f02d92feb88fa857e85b.tar.gz dged-8de2328d2e712fc892d6f02d92feb88fa857e85b.tar.xz dged-8de2328d2e712fc892d6f02d92feb88fa857e85b.zip | |
Fix find_prev_in_line
It did not consider the starting location which made it
not find the char it was standing on. This resulted in buffer_word_at
returning the wrong thing.
Diffstat (limited to 'test')
| -rw-r--r-- | test/buffer.c | 11 |
1 files changed, 8 insertions, 3 deletions
diff --git a/test/buffer.c b/test/buffer.c index a8268da..7fc60b7 100644 --- a/test/buffer.c +++ b/test/buffer.c @@ -113,7 +113,7 @@ static void test_word_at(void) { ASSERT(word1.begin.col == 0 && word1.end.col == 5, "Expected only word to end at col 5"); - const char *txt2 = " (word2). Another"; + const char *txt2 = " (word2). word3. Another"; buffer_add(&b, at, (uint8_t *)txt2, strlen(txt2)); word1 = buffer_word_at(&b, (struct location){.line = 0, .col = 0}); ASSERT(region_has_size(word1), "expected 0,0 to be a word"); @@ -131,8 +131,13 @@ static void test_word_at(void) { // test that clamping works correctly struct region word3 = buffer_word_at(&b, buffer_clamp(&b, 0, 100)); ASSERT(region_has_size(word3), "expected 0,100 to be in the last word"); - ASSERT(word3.begin.col == 15 && word3.end.col == 22, - "Expected word to span cols 15..22"); + ASSERT(word3.begin.col == 22 && word3.end.col == 29, + "Expected word to span cols 22..29"); + + // test that the dot is not considered a word + struct region word4 = + buffer_word_at(&b, (struct location){.line = 0, .col = 20}); + ASSERT(!region_has_size(word4), "dot should not be a word"); buffer_destroy(&b); } |
