diff options
author | Arun Isaac | 2020-05-25 05:22:17 +0530 |
---|---|---|
committer | Arun Isaac | 2020-05-25 05:44:15 +0530 |
commit | 8a1b7f6b5534bc02692f7a02d0dc287dc46ca4c1 (patch) | |
tree | ce3e9a33b73dd7e7faa66242322b32d73534e134 /tests | |
parent | 3b662f55237e037184f92335ea0f4502adc91fe8 (diff) | |
download | guile-email-8a1b7f6b5534bc02692f7a02d0dc287dc46ca4c1.tar.gz guile-email-8a1b7f6b5534bc02692f7a02d0dc287dc46ca4c1.tar.lz guile-email-8a1b7f6b5534bc02692f7a02d0dc287dc46ca4c1.zip |
utils: Do not return eof if matched at beginning.
* email/utils.scm (read-while, read-bytes-till): Do not return eof if
matched at beginning. Return empty string or bytevector respectively.
* tests/utils.scm ("read-bytes-till returns empty bytevector on match
at beginning", "read-while returns empty string on match at
beginning"): New tests.
Diffstat (limited to 'tests')
-rw-r--r-- | tests/utils.scm | 13 |
1 files changed, 12 insertions, 1 deletions
diff --git a/tests/utils.scm b/tests/utils.scm index 7681c72..ce8fdb2 100644 --- a/tests/utils.scm +++ b/tests/utils.scm @@ -1,5 +1,5 @@ ;;; guile-email --- Guile email parser -;;; Copyright © 2019 Arun Isaac <arunisaac@systemreboot.net> +;;; Copyright © 2019, 2020 Arun Isaac <arunisaac@systemreboot.net> ;;; ;;; This file is part of guile-email. ;;; @@ -35,4 +35,15 @@ (call-with-input-string "" (cut read-while <> read identity)))) +(test-equal "read-bytes-till returns empty bytevector on match at beginning" + (call-with-port (open-bytevector-input-port #vu8(1 2 3)) + (cut read-bytes-till <> #vu8(1 2))) + #vu8()) + +(test-equal "read-while returns empty string on match at beginning" + (call-with-input-string "foo\nbar" + (lambda (port) + (read-while port get-line (negate (cut string-prefix? "foo" <>))))) + "") + (test-end "utils") |