73 lines
2.3 KiB
Scheme
73 lines
2.3 KiB
Scheme
|
|
||
|
|
||
|
;; #+name: simple-string-test
|
||
|
|
||
|
;; [[file:../redis.org::simple-string-test][simple-string-test]]
|
||
|
(test-group "Simple strings"
|
||
|
(test "+this is a simple string."
|
||
|
"this is a simple string."
|
||
|
(with-input-from-string "this is a simple string.\r\n" read-redis-simple-string)))
|
||
|
;; simple-string-test ends here
|
||
|
|
||
|
;; [[file:../redis.org::*Blob Strings][Blob Strings:2]]
|
||
|
(test-group "Blob strings"
|
||
|
(test "$10\r\nhelloworld"
|
||
|
"helloworld"
|
||
|
(with-input-from-string "10\r\nhelloworld\r\n" read-redis-blob-string)))
|
||
|
;; Blob Strings:2 ends here
|
||
|
|
||
|
;; [[file:../redis.org::*Integers][Integers:2]]
|
||
|
(test-group "Integers"
|
||
|
(test ":180" 180
|
||
|
(with-input-from-string "180\r\n" read-redis-number)))
|
||
|
;; Integers:2 ends here
|
||
|
|
||
|
|
||
|
;; Bignums are prefixed with ~(~.
|
||
|
|
||
|
;; #+begin_example
|
||
|
;; (3492890328409238509324850943850943825024385
|
||
|
;; #+end_example
|
||
|
|
||
|
|
||
|
;; [[file:../redis.org::*Bignums][Bignums:1]]
|
||
|
(test-group "Bignums"
|
||
|
(test "(3492890328409238509324850943850943825024385" 3492890328409238509324850943850943825024385
|
||
|
(with-input-from-string "3492890328409238509324850943850943825024385\r\n" read-redis-number)))
|
||
|
;; Bignums:1 ends here
|
||
|
|
||
|
;; [[file:../redis.org::*Booleans][Booleans:2]]
|
||
|
(test-group "Booleans"
|
||
|
(test "#t" #t
|
||
|
(with-input-from-string "t" read-redis-bool))
|
||
|
(test "#f" #f
|
||
|
(with-input-from-string "f" read-redis-bool)))
|
||
|
;; Booleans:2 ends here
|
||
|
|
||
|
;; [[file:../redis.org::*Null][Null:2]]
|
||
|
(test-group "Null"
|
||
|
(test "_" '()
|
||
|
(with-input-from-string "" read-redis-null)))
|
||
|
;; Null:2 ends here
|
||
|
|
||
|
;; [[file:../redis.org::*Arrays][Arrays:2]]
|
||
|
(test-group "Arrays"
|
||
|
(test "*3:1:2:3" #(1 2 3)
|
||
|
(with-input-from-string "3\r\n:1\r\n:2\r\n:3\r\n" read-redis-array)))
|
||
|
;; Arrays:2 ends here
|
||
|
|
||
|
;; [[file:../redis.org::*Maps][Maps:2]]
|
||
|
(test-group "Maps"
|
||
|
(test "%2+first:1+second:2" '(("first" . 1)
|
||
|
("second" . 2))
|
||
|
(hash-table->alist
|
||
|
(with-input-from-string "2\r\n+first\r\n:1\r\n+second\r\n:2\r\n" read-redis-map))))
|
||
|
;; Maps:2 ends here
|
||
|
|
||
|
;; [[file:../redis.org::*Sets][Sets:2]]
|
||
|
(test-group "Sets"
|
||
|
(test-assert "~4+orange+apple#t#f"
|
||
|
(set=? (set (redis-set-comparator) "orange" "apple" #t #f)
|
||
|
(with-input-from-string "4\r\n+orange\r\n+apple\r\n#t\r\n#f\r\n" read-redis-set))))
|
||
|
;; Sets:2 ends here
|