(use test) (use string-utils) (test-begin "String Utils") (test-group "Memoized" (test "a" (make-string* 1 #\a)) (define a5 (make-string* 5 #\a)) (test "aaaaa" a5) (define spc5 (make-string* 5)) (test " " spc5) (test-assert (eq? a5 (make-string* 5 #\a))) (test-assert (eq? spc5 (make-string* 5 #\space))) ) (test-group "Unicode" (test-assert (ascii-codepoint? #\a)) (test "abc" (unicode-string #\a #\b #\c)) (test "cebb" (string->hex (unicode-char->string #\U03BB))) (test "cebbcebbcebb" (string->hex (unicode-string #\U03BB #\U03BB #\U03BB))) (test "cebbcebb" (string->hex (unicode-make-string 2 #\U03BB))) ) (use to-hex) (use srfi-4) (test-group "To Hex" (let ((t (make-string (* 2 3)))) (blob_to_hex t (string->blob "12abc34") 2 5) (test "616263" t) ) (let ((t (make-string (* 2 3)))) (u8vec_to_hex t (u8vector 1 2 #x61 #x62 #x63 3 4) 2 5) (test "616263" t) ) (let ((t (make-string (* 2 2)))) (s8vec_to_hex t (s8vector 1 2 -45 -54 3 4) 2 4) (test "d3ca" t) ) ) (use string-hexadecimal) (test-group "String -> Hex" (test "616263" (string->hex "12abc34" 2 5)) (test "414243444546" (string->hex "ABCDEF")) (test "4243444546" (string->hex "ABCDEF" 1)) (test "4243" (string->hex "ABCDEF" 1 3)) ) (test-end) (test-exit)