source: project/release/4/html-parser/tags/0.3/test.scm @ 14751

Last change on this file since 14751 was 14751, checked in by Alex Shinn, 11 years ago

tagging new release

File size: 1.8 KB
Line 
1
2(use test html-parser)
3
4(test-begin "html-parser")
5
6(define (string-scan str pat)
7  (string-length ((make-string-reader/ci pat) (open-input-string str))))
8
9(test-group "utilities"
10
11(test "string-scan (basic)" 3 (string-scan "abcdefghi" "def"))
12
13(test "string-scan (case-insensitive)" 3 (string-scan "abcdEfghi" "deF"))
14
15(test "string-scan (single char)" 4 (string-scan "abcdefghi" "e"))
16
17(test "string-scan (overlap)" 12
18  (string-scan "salkabcdabghabcdabdef" "abcdabd"))
19
20(test "string-scan (boyer-moore)" 216
21       (string-scan "abracadababrabrabrabracadababrabrabrabracadababrabrabrabracadababrabrabrabracadababrabrabrabracadababrabrabrabracadababrabrabrabracadababrabrabrabracadababrabrabrabracadababrabrabrabracadababrabrabrabracadababrabrabrabracadabrabracadababrabrabrabracadababrabrabrabracadababrabrabrabracadababrabrabrabracadababrabrabrabracadababrabrabrabracadababrabrabrabracadababrabrabr"
22                    "abracadabra"))
23
24(test "string-scan (empty pattern)" 0
25       (string-scan "abakjrgaker" ""))
26
27)
28
29(test-group "parsing"
30
31(test '((a (@ (href "http://foo.scm/")) "foo"))
32    (html->sxml "<a href=\"http://foo.scm/\">foo</a>"))
33
34(test '((a "a" (b "ab") "a" (c "ac")) "x")
35    (html->sxml "<a>a<b>ab</b>a<c>ac</c></a>x"))
36
37(test '((p "p1") (p "p2") (p "p3"))
38    (html->sxml "<p>p1<p>p2</p><p>p3"))
39
40(test '((i "italic" (b "bold italic")) (b "bold"))
41    (html->sxml "<i>italic<b>bold italic</i>bold</b>"))
42
43(test '((*PI* xml "blah blah"))
44    (html->sxml "<?xml blah blah?>"))
45
46(test '("abc" (*COMMENT* "def") "ghi")
47    (html->sxml "abc<!--def-->ghi"))
48
49(test '((pre "<a>&amp;<!--foo-->"))
50    (html->sxml "<pre><![CDATA[<a>&amp;<!--foo-->]]></pre>"))
51
52(test '((xmp "<a>&amp;<!--foo--><![CDATA[...]]></a>"))
53    (html->sxml "<xmp><a>&amp;<!--foo--><![CDATA[...]]></a></xmp>"))
54
55)
56
57(test-end)
Note: See TracBrowser for help on using the repository browser.