;; port-di.text  -*- scheme -*-

(add-to-load-path "guile-2.1.7-dev3/test-suite")

(use-modules (test-suite lib))

(define (test-file)
  (string-append (getcwd) "/ports-test.tmp"))

(with-test-prefix "drain-input"
  
  (pass-if "encoded input"
    (let ((fn (test-file))
	  (nc "utf-8")
	  (st "\u03b2\u03b1\u03b4 \u03b1\u03c3\u03c3 am I.")
	  ;;(st "hello, world\n")
	  )
      (let ((p1 (open-output-file fn #:encoding nc)))
	;;(display st p1)
	(string-for-each (lambda (ch) (write-char ch p1)) st)
	(close p1))
      (let* ((p0 (open-input-file fn #:encoding nc))
	     (s0 (begin (unread-char (read-char p0) p0) (drain-input p0))))
	(simple-format #t "~S\n" s0)
	(equal? s0 st))))

  )

;; --- last line ---
