From 702573b34d42f587a37f1e654d8b13a955fbc064 Mon Sep 17 00:00:00 2001 From: Gracjan Polak Date: Wed, 20 Jan 2016 00:04:19 +0100 Subject: [PATCH] Add string tests --- tests/haskell-string-tests.el | 37 +++++++++++++++++++++++++---------- 1 file changed, 27 insertions(+), 10 deletions(-) diff --git a/tests/haskell-string-tests.el b/tests/haskell-string-tests.el index 2e906c35b..2362fa39a 100644 --- a/tests/haskell-string-tests.el +++ b/tests/haskell-string-tests.el @@ -67,7 +67,18 @@ (cons "\\n" "\n") (cons "\\'" "'") (cons "\\\"" "\"") - (cons "\\SOH" "\x01"))) + (cons "\\SOH" "\x01") + (cons "\\1114111" "\x10ffff") + (cons "\\o4177777" "\x10ffff") + (cons "\\x10ffff" "\x10ffff") + (cons "\\^@" "\x00") + (cons "\\^A" "\x01") + (cons "\\^Z" "\x1A") + (cons "\\^[" "\x1B") + (cons "\\^\\" "\x1C") + (cons "\\^]" "\x1D") + (cons "\\^^" "\x1E") + (cons "\\^_" "\x1F"))) (should (string= (cdr cs) (haskell-string-literal-decode (concat "\"" (car cs) "\"")))) (should (string= (cdr cs) @@ -87,20 +98,20 @@ "\x01" ;; '\SOH' "\x00df\x30" ;; '\223' '0' "'" - "\'" + "\'" "\"" "\x0e&H" "\\" " \\ \\" "\\\\\"" - (string 40 945 8322 946 8323 8743 947 178 949 178 41) - "x" - "xy" - "\\x123" - "\\ \\x123" - " " - " " - "")) + (string 40 945 8322 946 8323 8743 947 178 949 178 41) + "x" + "xy" + "\\x123" + "\\ \\x123" + " " + " " + "")) ; (should (string= s0 (haskell-string-literal-decode (haskell-string-literal-encode s0)))) (should (string= s0 (haskell-string-literal-decode (haskell-string-literal-encode s0 t) t)))) @@ -112,3 +123,9 @@ (s2 (haskell-string-literal-decode (haskell-string-literal-encode s0 t) t))) (should (string= s0 s1)) (should (string= s0 s2)))))) + +(ert-deftest haskell-string-test-trim () + (should (equal "saf \t sdsaf" + (haskell-string-trim "\r\n saf \t sdsaf \t\v\n \f"))) + (should (haskell-string-only-spaces-p "\r\n \t \t\v\n \f")) + (should-not (haskell-string-only-spaces-p "\r\n \t x \t\v\n \f")))