about summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorKartik K. Agaram <vc@akkartik.com>2021-12-22 11:54:54 -0800
committerKartik K. Agaram <vc@akkartik.com>2021-12-22 11:54:54 -0800
commite7a73626e826bad1a39dffdd8e8c47bd8b8d2d57 (patch)
tree572a588790b7e0d36272dfffbb049fad25e9b8cd
parent0a1d5d61cb31378552cd313da03cb3f1896d15f7 (diff)
downloadteliva-e7a73626e826bad1a39dffdd8e8c47bd8b8d2d57.tar.gz
toot-toot: a few more tests
..before a change in approach.
-rw-r--r--toot-toot.tlv17
1 files changed, 16 insertions, 1 deletions
diff --git a/toot-toot.tlv b/toot-toot.tlv
index 5c6f1fe..d943487 100644
--- a/toot-toot.tlv
+++ b/toot-toot.tlv
@@ -271,6 +271,16 @@
     >  end
     >  return newidx
     >end
+    >
+    >function test_cursor_down()
+    >  check_eq(cursor_down('abc\ndef', 1), 5, 'cursor_down: non-bottom line first char')
+    >  check_eq(cursor_down('abc\ndef', 2), 6, 'cursor_down: non-bottom line mid char')
+    >  check_eq(cursor_down('abc\ndef', 3), 7, 'cursor_down: non-bottom line final char')
+    >  check_eq(cursor_down('abc\ndef', 4), 8, 'cursor_down: non-bottom line end')
+    >  check_eq(cursor_down('abc\ndef', 5), 5, 'cursor_down: bottom line first char')
+    >  check_eq(cursor_down('abc\ndef', 6), 6, 'cursor_down: bottom line mid char')
+    >  check_eq(cursor_down('abc\ndef', 7), 7, 'cursor_down: bottom line final char')
+    >end
 - __teliva_timestamp: original
   skip_past_newline:
     >function skip_past_newline(s, idx)
@@ -376,7 +386,12 @@
     >  check_eq(cursor_up('abc\ndef', 2), 2, 'cursor_up: top line mid char')
     >  check_eq(cursor_up('abc\ndef', 3), 3, 'cursor_up: top line final char')
     >  check_eq(cursor_up('abc\ndef', 4), 4, 'cursor_up: top line end')
-    >  check_eq(cursor_up('abc\ndef', 5), 1, 'cursor_up: second line first char')
+    >  check_eq(cursor_up('abc\ndef', 5), 1, 'cursor_up: non-top line first char')
+    >  check_eq(cursor_up('abc\ndef', 6), 2, 'cursor_up: non-top line mid char')
+    >  check_eq(cursor_up('abc\ndef', 7), 3, 'cursor_up: non-top line final char')
+    >  check_eq(cursor_up('abc\ndef\n', 8), 4, 'cursor_up: non-top line end')
+    >  check_eq(cursor_up('ab\ndef\n', 7), 3, 'cursor_up: to shorter line')
+    >  -- idx that's too high for s not working; let's see if that matters
     >end
 - __teliva_timestamp: original
   render: