Blame


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