diff options
author | Arun Isaac | 2020-05-25 13:40:09 +0530 |
---|---|---|
committer | Arun Isaac | 2020-05-25 19:59:26 +0530 |
commit | 88259287b5b7f84947cd21af174608b57b731fd0 (patch) | |
tree | 0a4e816c02196c57aa6d13d666f2532c056974c9 /tests | |
parent | 60ad69b8c968e5c4d08056ef68d990e26f950d91 (diff) | |
download | guile-email-88259287b5b7f84947cd21af174608b57b731fd0.tar.gz guile-email-88259287b5b7f84947cd21af174608b57b731fd0.tar.lz guile-email-88259287b5b7f84947cd21af174608b57b731fd0.zip |
tests: Test inputs of different lengths.
* tests/base64.scm ("base64 random bytevector: base64-encode and
base64-decode are inverses of each other", "base64 random
bytevector: encoded output should not be more than 76 columns wide",
"base64 random bytevector: encoded output must only consist of
characters from the base64 alphabet"): Test inputs of different lengths.
* tests/quoted-printable.scm ("quoted-printable random bytevector:
quoted-printable-encode and quoted-printable-decode are inverses of
each other", "quoted-printable random bytevector: encoded output
should not be more than 76 columns wide", "quoted-printable random
bytevector: encoded output must only consist of printable ASCII
characters", "q-encoding random bytevector: q-encoding-encode and
q-encoding-decode are inverses of each other"): Test inputs of
different lengths.
Diffstat (limited to 'tests')
-rw-r--r-- | tests/base64.scm | 21 | ||||
-rw-r--r-- | tests/quoted-printable.scm | 35 |
2 files changed, 33 insertions, 23 deletions
diff --git a/tests/base64.scm b/tests/base64.scm index c200f81..504acbf 100644 --- a/tests/base64.scm +++ b/tests/base64.scm @@ -56,18 +56,23 @@ ZSBzaG9ydCB2ZWhlbWVuY2Ugb2YgYW55IGNhcm5hbCBwbGVhc3VyZS4=") (base64-encode (string->bytevector decoded-text charset))))) -(let ((x (random-bytevector 1000))) - (test-equal "base64 random bytevector: base64-encode and base64-decode are inverses of each other" - (base64-decode (base64-encode x)) - x)) +(test-assert "base64 random bytevector: base64-encode and base64-decode are inverses of each other" + (every (lambda (len) + (let ((x (random-bytevector len))) + (equal? x (base64-decode (base64-encode x))))) + (iota 1000))) (test-assert "base64 random bytevector: encoded output should not be more than 76 columns wide" - (each-line-has-a-maximum-of-76-characters? - (base64-encode (random-bytevector 1000)))) + (every (lambda (len) + (each-line-has-a-maximum-of-76-characters? + (base64-encode (random-bytevector len)))) + (iota 1000))) (test-assert "base64 random bytevector: encoded output must only consist of characters from the base64 alphabet" - (string-has-only-valid-base64-characters? - (base64-encode (random-bytevector 1000)))) + (every (lambda (len) + (string-has-only-valid-base64-characters? + (base64-encode (random-bytevector len)))) + (iota 1000))) (test-equal "base64 decoding should ignore invalid characters" (bytevector->string (base64-decode "..TWFu,") "utf-8") diff --git a/tests/quoted-printable.scm b/tests/quoted-printable.scm index 0b5b462..bfbd985 100644 --- a/tests/quoted-printable.scm +++ b/tests/quoted-printable.scm @@ -1,5 +1,5 @@ ;;; guile-email --- Guile email parser -;;; Copyright © 2018 Arun Isaac <arunisaac@systemreboot.net> +;;; Copyright © 2018, 2020 Arun Isaac <arunisaac@systemreboot.net> ;;; ;;; This file is part of guile-email. ;;; @@ -67,20 +67,24 @@ abriquent pour te la vendre une =C3=A2me vulgaire.") (quoted-printable-escape-encode-char #\return) (quoted-printable-escape-encode-char #\newline))) -(let ((x (random-bytevector 1000))) - (test-equal "quoted-printable random bytevector: quoted-printable-encode and quoted-printable-decode are inverses of each other" - (quoted-printable-decode - (quoted-printable-encode x)) - x)) +(test-assert "quoted-printable random bytevector: quoted-printable-encode and quoted-printable-decode are inverses of each other" + (every (lambda (len) + (let ((x (random-bytevector len))) + (equal? x (quoted-printable-decode (quoted-printable-encode x))))) + (iota 1000))) (test-assert "quoted-printable random bytevector: encoded output should not be more than 76 columns wide" - (each-line-has-a-maximum-of-76-characters? - (quoted-printable-encode - (random-bytevector 1000)))) + (every (lambda (len) + (each-line-has-a-maximum-of-76-characters? + (quoted-printable-encode + (random-bytevector len)))) + (iota 1000))) (test-assert "quoted-printable random bytevector: encoded output must only consist of printable ASCII characters" - (string-has-only-quoted-printable-valid-characters? - (quoted-printable-encode (random-bytevector 1000)))) + (every (lambda (len) + (string-has-only-quoted-printable-valid-characters? + (quoted-printable-encode (random-bytevector len)))) + (iota 1000))) (let ((encoded-text "=A1Hola,_se=F1or!") (decoded-text "¡Hola, señor!") @@ -102,9 +106,10 @@ abriquent pour te la vendre une =C3=A2me vulgaire.") (quoted-printable-escape-encode-char #\_) (quoted-printable-escape-encode-char #\?))) -(let ((x (random-bytevector 1000))) - (test-equal "q-encoding random bytevector: q-encoding-encode and q-encoding-decode are inverses of each other" - (q-encoding-decode (q-encoding-encode x)) - x)) +(test-assert "q-encoding random bytevector: q-encoding-encode and q-encoding-decode are inverses of each other" + (every (lambda (len) + (let ((x (random-bytevector len))) + (equal? x (q-encoding-decode (q-encoding-encode x))))) + (iota 1000))) (test-end "quoted-printable") |