3 exec ${MES-src/mes} --no-auto-compile -L ${0%/*} -L module -C module -e '(tests srfi-13)' -s "$0" "$@"
8 ;;; Mes --- Maxwell Equations of Software
9 ;;; Copyright © 2016,2017,2018 Jan (janneke) Nieuwenhuizen <janneke@gnu.org>
11 ;;; This file is part of Mes.
13 ;;; Mes is free software; you can redistribute it and/or modify it
14 ;;; under the terms of the GNU General Public License as published by
15 ;;; the Free Software Foundation; either version 3 of the License, or (at
16 ;;; your option) any later version.
18 ;;; Mes is distributed in the hope that it will be useful, but
19 ;;; WITHOUT ANY WARRANTY; without even the implied warranty of
20 ;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 ;;; GNU General Public License for more details.
23 ;;; You should have received a copy of the GNU General Public License
24 ;;; along with Mes. If not, see <http://www.gnu.org/licenses/>.
26 (define-module (tests srfi-13)
27 #:use-module (mes mes-0)
28 #:use-module (mes test))
30 (mes-use-module (srfi srfi-13))
31 (mes-use-module (mes test))
33 (pass-if "first dummy" #t)
34 (pass-if-not "second dummy" #f)
36 (pass-if-equal "string-join"
38 (string-join '("foo" "bar")))
40 (pass-if-equal "string-join infix"
42 (string-join '("foo" "bar") "+"))
44 (pass-if-equal "string-join prefix"
46 (string-join '("foo" "bar") "," 'prefix))
48 (pass-if-equal "string-join suffix"
50 (string-join '("foo" "bar") "," 'suffix))
52 (pass-if-equal "string-split"
54 (string-split "foo" #\:))
56 (pass-if-equal "string-split 2"
58 (string-split "foo:" #\:))
60 (pass-if-equal "string-split 3"
62 (string-split "foo:bar:baz" #\:))
64 (pass-if-equal "string-index"
66 (string-index "foo:bar" #\:))
68 (pass-if-equal "string->number" 42 (string->number "42"))
69 (pass-if-equal "string->number INT-MAX" 2147483647 (string->number "2147483647"))
70 (pass-if-equal "string->number INT-MIN" -2147483648 (string->number "-2147483648"))
71 (pass-if-equal "number->string" "16" (number->string 16))
72 (pass-if-equal "number->string INT-MAX" "2147483647" (number->string 2147483647))
73 (pass-if-equal "number->string INT-MIN" "-2147483648" (number->string -2147483648))
74 (pass-if-equal "number->string" "-4" (number->string -4))
76 (pass-if-equal "string-fold"
78 (list->string (string-fold cons '() "foo")))
80 (pass-if-equal "string-fold-right"
82 (list->string (string-fold-right (lambda (e p) (cons e (cons #\- p))) '(#\:) "foo")))
84 (pass-if-equal "string-drop" "bar"
85 (string-drop "foobar" 3))
87 (pass-if-equal "string-drop-right" "foo"
88 (string-drop-right "foobar" 3))
90 (pass-if-equal "string-contains" 3
91 (string-contains "foobar" "bar"))
93 (pass-if-not "string-contains not"
94 (string-contains "fuba" "bar"))
96 (pass-if-equal "string-trim" "foo "
97 (string-trim " foo "))
99 (pass-if-equal "string-trim-right" " foo"
100 (string-trim-right " foo "))
102 (pass-if-equal "string-trim-both" "foo"
103 (string-trim-both " foo "))
105 (pass-if-equal "string-map" "fuubar"
106 (string-map (lambda (c) (if (eq? c #\o) #\u c)) "foobar"))
108 (pass-if-equal "string-replace" "fubar"
109 (string-replace "foobar" "u" 1 3))