summaryrefslogtreecommitdiff
path: root/tests/piece-table.scm
blob: b8b6ff1ab464f435491b0bbb8679d3272a00b933 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
(import (srfi 64)
        (scheme base)
        (par piece-table))

;; https://srfi.schemers.org/srfi-64/srfi-64.html


(test-begin "index")
  (define table (make-piece-table "HOLA"))
  (test-equal #\L (piece-table-index table 2))
(test-end "index")

(test-begin "insert")
  (define table (make-piece-table "HOLA"))
  (piece-table-insert! table 4 "9" 'normal)
  (piece-table-insert! table 5 "0" 'normal)
  (test-equal #\9 (piece-table-index table 4))
  (test-equal #\0 (piece-table-index table 5))
  (test-equal "HOLA90" (piece-table->string table))
  (piece-table-insert! table 5 "1" 'normal)
  (test-equal "HOLA910" (piece-table->string table))
(test-end "insert")

(test-begin "delete")
  (define table (make-piece-table "HOLA SOY EKAITZ"))
  (piece-table-delete! table 4)
  (test-equal "HOLASOY EKAITZ" (piece-table->string table))
  (piece-table-delete! table 0)
  (test-equal "OLA SOY EKAITZ" (piece-table->string table))
  (piece-table-delete! table 13)
  (test-equal "OLA SOY EKAIT" (piece-table->string table))
(test-end "delete")