aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHugo Hörnquist <hugo@lysator.liu.se>2023-10-31 21:08:13 +0100
committerHugo Hörnquist <hugo@lysator.liu.se>2023-11-06 00:46:26 +0100
commit8d58b699137a4cf2c7614c0814c0d7d657926305 (patch)
tree6851500f1ad2091ed5de400fec714a9c0f439807
parentImprove <dl/> in (text markup) (diff)
downloadcalp-8d58b699137a4cf2c7614c0814c0d7d657926305.tar.gz
calp-8d58b699137a4cf2c7614c0814c0d7d657926305.tar.xz
Add tests for (text markup).
-rw-r--r--tests/unit/text/text-markup.scm96
1 files changed, 96 insertions, 0 deletions
diff --git a/tests/unit/text/text-markup.scm b/tests/unit/text/text-markup.scm
new file mode 100644
index 00000000..14b9f19b
--- /dev/null
+++ b/tests/unit/text/text-markup.scm
@@ -0,0 +1,96 @@
+(define-module (test text-markup)
+ :use-module (srfi srfi-64)
+ :use-module (text markup))
+
+(test-equal "Header"
+ " \x1b[1mHello\x1b[m \n"
+ (sxml->ansi-text
+ '(header (@ (width 20))
+ "Hello")))
+
+(test-equal "Center"
+ " . "
+ (sxml->ansi-text
+ '(center (@ (width 11)) ".")))
+
+(test-equal "Bold is NOT restored after a nested italic"
+ "\x1b[1mbold\x1b[3mitalic\x1b[mafter\x1b[m"
+ (sxml->ansi-text '(b (group "bold" (i "italic") "after"))))
+
+(test-equal "hr"
+ " ──────────────────────────────────────────────────────────── \n"
+ (sxml->ansi-text '(hr)))
+
+(test-group "Description list"
+ (test-equal
+ (string-append
+ " key │ value\n"
+ "key 2 │ value 2\n")
+ (sxml->ansi-text '(dl (dt "key")
+ (dd "value")
+ (dt "key 2")
+ (dd "value 2"))))
+
+(test-equal "Muliple dt to one dd"
+ (string-append
+ " key │ value\n"
+ "key 2 │ \n"
+ " key │ value\n")
+ (sxml->ansi-text '(dl (dt "key")
+ (dt "key 2")
+ (dd "value")
+ (dt "key")
+ (dd "value"))))
+
+ (test-equal "Muliple dd to one dt"
+ (string-append
+ " key │ value\n"
+ " │ value 2\n"
+ "key 2 │ \n")
+ (sxml->ansi-text '(dl (dt "key")
+ (dd "value")
+ (dd "value 2")
+ (dt "key 2")))))
+
+(test-equal "Scheme block"
+ "(sxml->ansi-text
+ '(dl (dt \"key\")
+ (dd \"value\")
+ (dd \"value 2\")
+ (dt \"key 2\")))"
+ (sxml->ansi-text
+ '(scheme (sxml->ansi-text '(dl (dt "key")
+ (dd "value")
+ (dd "value 2")
+ (dt "key 2"))))))
+
+(test-equal "Unknown tag"
+ "\x1b[1m??`\x1b[7m(\"Hello, \" (b \"nested\") \"after\")\x1b[m'\n"
+ (sxml->ansi-text '(block (err "Hello, " (b "nested") "after")
+ (br))))
+
+
+
+(test-equal "Empty document"
+ ""
+ (sxml->ansi-text '()))
+
+(test-equal "Paragraph text flowing + nested format"
+ ;; This also shows bad spacing
+ ;; second line is longer that the expected line width.
+ "A sentance \x1b[1mcontaining\x1b[m the word
+pneumonoultramicroscopicsilicovolcanoconiosis
+is rather hard to justify properly
+
+"
+ (sxml->ansi-text
+ '(p (@ (width 40)) "A sentance " (b "containing") " the word pneumonoultramicroscopicsilicovolcanoconiosis is rather hard to justify properly")))
+
+
+(test-equal "blockquote"
+ " Hello
+ -- Hugo
+" (sxml->ansi-text '(blockquote "Hello" (br) "-- Hugo")))
+
+
+'((text markup))