From 1f5b6185b628a5582b6873ef4668111aad220b02 Mon Sep 17 00:00:00 2001 From: "W. Kosior" Date: Tue, 23 Jul 2024 23:17:50 +0200 Subject: Write tests for `parse-cookies' procedure. --- tests/guile/cantius-test.scm | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) (limited to 'tests/guile/cantius-test.scm') 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))) -- cgit v1.2.3