On Wed, 2013-01-16 at 18:42 +0100, Andy Wingo wrote:
> On Wed 07 Mar 2012 17:32, Nala Ginrut <nalagin...@gmail.com> writes:
> 
> > (call-with-input-string "asdf" (lambda (port) (read-delimited "@" port
> > 'fail))))
> 
> LGTM; just missing a test case.  I would tighten up the documentation,
> too: make sure each sentence is actually a sentence.  (It's a common
> mistake, even for native speakers.)
> 

Attached the patch for rdelim test case. Please review it.
Thanks!

> Cheers,
> 
> Andy


>From 47d484faac2d98dde0658467d45e848727bc1929 Mon Sep 17 00:00:00 2001
From: Nala Ginrut <nalagin...@gmail.com>
Date: Thu, 17 Jan 2013 17:04:21 +0800
Subject: [PATCH 2/2] * test-case/tests/rdelim.test: Add test case for 'fail
 in read-delimited.

---
 test-suite/tests/rdelim.test |   21 +++++++++++++++++++++
 1 file changed, 21 insertions(+)

diff --git a/test-suite/tests/rdelim.test b/test-suite/tests/rdelim.test
index e61fc92..6c6e323 100644
--- a/test-suite/tests/rdelim.test
+++ b/test-suite/tests/rdelim.test
@@ -113,6 +113,16 @@
               (read-delimited ",.;" (open-input-string "hello, world!")
                               'concat)))
 
+    (pass-if "delimiter fail, fail"
+      (equal? #f
+              (read-delimited "@" (open-input-string "asdf")
+                              'fail)))
+
+    (pass-if "delimiter hit, fail"
+      (equal? "hello"
+              (read-delimited "," (open-input-string "hello, world")
+                              'fail)))
+
     (pass-if "delimiter hit, peek"
       (let ((p (open-input-string "hello, world!")))
         (and (string=? "hello" (read-delimited ",.;" p 'peek))
@@ -161,6 +171,11 @@
              (string=? (substring s 0 5) "hello")
              (char=? #\, (peek-char p)))))
 
+    (pass-if "delimiter hit, fail"
+      (let ((s (make-string 123))
+            (p (open-input-string "asdf")))
+        (not (read-delimited! "@" s p 'fail))))
+
     (pass-if "string too small"
       (let ((s (make-string 7)))
         (and (= 7 (read-delimited! "}{" s
@@ -183,6 +198,12 @@
                                       'split))
              (string=? s "hello, "))))
 
+    (pass-if "string too small, fail"
+      (let ((s (make-string 7)))
+        (not (read-delimited! "@" s
+                              (open-input-string "asdf")
+                              'fail))))
+    
     (pass-if "eof"
       (eof-object? (read-delimited! ":" (make-string 7)
                                     (open-input-string ""))))
-- 
1.7.10.4

Reply via email to