Blob


1 (in-package :gemtext-tests)
3 (defsuite gemtext-suite (all-suite))
5 (defun cmp-lines (xs ys)
6 (cond ((and (null xs) (null ys)) t)
7 ((and (null xs) ys) nil)
8 ((and xs (null ys)) nil)
9 ((not (gemtext:line-eq (car xs) (car ys))) nil)
10 (t (cmp-lines (cdr xs) (cdr ys)))))
12 (deftest test-parse-elements (gemtext-suite)
13 (loop with suite = `(("# title" . ,(make-instance 'gemtext:title
14 :text "title"
15 :level 1))
16 ("#title" . ,(make-instance 'gemtext:title
17 :text "title"
18 :level 1))
19 ("## title" . ,(make-instance 'gemtext:title
20 :text "title"
21 :level 2))
22 ("###title" . ,(make-instance 'gemtext:title
23 :text "title"
24 :level 3))
25 ("=>/foo" . ,(make-instance 'gemtext:link
26 :url (quri:uri "/foo")))
27 ("=> /foo bar" . ,(make-instance 'gemtext:link
28 :url (quri:uri "/foo")
29 :text "bar"))
30 ("* list item " . ,(make-instance 'gemtext:item
31 :text "list item"))
32 ("*text" . ,(make-instance 'gemtext:paragraph
33 :text "*text"))
34 (">cit" . ,(make-instance 'gemtext:blockquote
35 :text "cit")))
36 for (str . exp) in suite
37 do (assert-true (cmp-lines (gemtext:parse-string str)
38 (list exp)))))