From 5a251cf812682b6251dc4628fac899993e01dfe9 Mon Sep 17 00:00:00 2001 From: Sanel Zukan Date: Tue, 8 Jul 2008 12:24:24 +0000 Subject: [PATCH] More tests --- tools/capone/test/string.ss | 68 ++++++++++++++++++++++++++++++++++++- 1 file changed, 67 insertions(+), 1 deletion(-) diff --git a/tools/capone/test/string.ss b/tools/capone/test/string.ss index 37c1384..411982b 100644 --- a/tools/capone/test/string.ss +++ b/tools/capone/test/string.ss @@ -21,13 +21,35 @@ ))) (ut-add-test - "Check 'string?' functions" (begin (and (string? "z" "aaaa") + (string>? "fooo" "foo") + (string>? "foo" "asdadad") + (string>? "fooooooooo" "ab") + ))) + +(ut-add-test + "Check 'string<=? and string>=?' functions" + (begin + (and + (string<=? "aaaa" "z") + (string<=? "aaaa" "aaaa") + (string<=? "" "") + (not (string<=? "foo" "asdadad")) + (not (string<=? "fooooooooo" "ab")) + + (string>=? "z" "aaaa") + (string>=? "aaaa" "aaaa") + (string>=? "" "") + (string>=? "foo" "asdadad") + (string>=? "fooooooooo" "ab") ))) (ut-add-test @@ -57,3 +79,47 @@ (= 0 (string-length "")) (= 1 (string-length "a")) ))) + +;; As I could find from chicken and guile, string-fill! should modify +;; any string, not only one given with (make-string) only, which creates immutable strings +;; +;; This behaviour should be somehow documented and here it is: +;; If we make a string like '(define s "foo")' it will be immutable by default and that +;; can't be changed. On other hand, if we do something like: +;; (define s (make-string 10)) +;; (set! s (string-copy "foo")) +;; 's' will have "foo" value, have length of 3 characters and _will_ be mutable, e.g. +;; '(string-set! s 0 #\m)' will not fail and result will be "moo". +;; +;; Should it be seen as bug? +(ut-add-test + "Check 'string-fill! and make-string' functions [!]" + (begin + (define s (make-string 11)) + (string-fill! s #\o) + (string=? s "ooooooooooo") + )) + +(ut-add-test + "Check 'string-set!' function" + (begin + (define s (make-string 10)) + (set! s (string-copy "abrakadabra abrakadabra")) + (string-set! s 0 #\A) + (string-set! s 1 #\B) + (string-set! s 2 #\A) + (string-set! s 11 #\|) + (string-set! s 22 #\A) + (string=? s "ABAakadabra|abrakadabrA") + ) +) + +(ut-add-test + "Check 'number->string' function" + (begin + (and + (string=? "33" (number->string 33)) + (string=? "1234" (number->string 1234)) + (string=? "0" (number->string 0)) + (string=? "-1234" (number->string -1234)) + )))