aboutsummaryrefslogtreecommitdiff
path: root/tests/guile
diff options
context:
space:
mode:
authorW. Kosior <koszko@koszko.org>2024-07-23 23:17:50 +0200
committerW. Kosior <koszko@koszko.org>2024-07-23 23:17:50 +0200
commit1f5b6185b628a5582b6873ef4668111aad220b02 (patch)
tree085556d0b1e72a5e75795e50d506091c1c83f95c /tests/guile
parent6fc5e5fa1990d07de1b44fd4ac50cb388b3da480 (diff)
downloadcantius-apprentice.tar.gz
cantius-apprentice.zip
Write tests for `parse-cookies' procedure.HEADapprentice
Diffstat (limited to 'tests/guile')
-rw-r--r--tests/guile/cantius-test.scm24
1 files changed, 24 insertions, 0 deletions
diff --git a/tests/guile/cantius-test.scm b/tests/guile/cantius-test.scm
index 3591b64..c00977c 100644
--- a/tests/guile/cantius-test.scm
+++ b/tests/guile/cantius-test.scm
@@ -111,6 +111,30 @@ value
%form-boundary-1
(bv:string->utf8 %form-data-unsupported-encoding))))
+(tu:test-group "parse-cookies"
+ (tu:test-equal '(("name" . "val"))
+ (cant:parse-cookies "name=val;"))
+
+ (tu:test-equal '(("ses sion" . "fargtrg34")
+ ("s" . "f")
+ ("forms-session2" . "")
+ ("forms-sessio n3" . "f4 3433=g = 4"))
+ (cant:parse-cookies
+ (string-append "\t\tses sion =fargtrg34;"
+ " s = f;"
+ "forms-session2=\n;"
+ " forms-sessio n3=f4 3433=g = 4")))
+
+ (tu:test-equal '() (cant:parse-cookies ""))
+
+ (for-each (lambda (bad-cookies)
+ (tu:test-error (cut condition-has-type? <> cant:&bad-request)
+ (cant:parse-cookies bad-cookies)))
+ '(";"
+ "c1=v1;c2=v2;c3;c4=v4"
+ "something"
+ "k=v;;")))
+
(define (make-env)
(let ((env (null-environment 5)))
(module-use! env (resolve-interface '(guile)))