file-test.ss
;;;
;;; Time-stamp: <06/02/05 20:42:28 noel>
;;;
;;; Copyright (C) 2005 by Noel Welsh.
;;;

;;; This library is free software; you can redistribute it
;;; and/or modify it under the terms of the GNU Lesser
;;; General Public License as published by the Free Software
;;; Foundation; either version 2.1 of the License, or (at
;;; your option) any later version.

;;; This library is distributed in the hope that it will be
;;; useful, but WITHOUT ANY WARRANTY; without even the
;;; implied warranty of MERCHANTABILITY or FITNESS FOR A
;;; PARTICULAR PURPOSE.  See the GNU Lesser General Public
;;; License for more details.

;;; You should have received a copy of the GNU Lesser
;;; General Public License along with this library; if not,
;;; write to the Free Software Foundation, Inc., 59 Temple
;;; Place, Suite 330, Boston, MA 02111-1307 USA

;;; Author: Noel Welsh <noelwelsh@yahoo.com>
;;
;;
;; Commentary:
(module file-test mzscheme
  
  (require (planet "test.ss" ("schematics" "schemeunit.plt" 2)))
  (require "file.ss")
  
  (provide file-tests)
  
  (define file-tests
    (test-suite
     "All tests for file"
     (test-case
      "make-directory-tree creates single directory"
      (check-false (directory-exists? "testing"))
      (make-directory-tree "testing")
      (check-true (directory-exists? "testing"))
      (delete-directory "testing"))

     (test-case
      "make-directory-tree creates list of directories"
      (let ((dirs '("t1" "t2" "t3")))
        (map (lambda (dir)
               (check-false (directory-exists? dir)))
             dirs)
        (make-directory-tree dirs)
        (map (lambda (dir)
               (check-true (directory-exists? dir)))
             dirs)
        (map delete-directory dirs)))

     (test-case
      "make-directory-tree creates tree of directories"
      (check-false (directory-exists? "a"))
      (check-false (directory-exists? "a/b"))
      (check-false (directory-exists? "a/c"))
      (check-false (directory-exists? "a/c/d"))
      (make-directory-tree '("a" ("b" "c" ("d"))))
      (check-true (directory-exists? "a"))
      (check-true (directory-exists? "a/b"))
      (check-true (directory-exists? "a/c"))
      (check-true (directory-exists? "a/c/d"))
      (delete-directory "a/c/d")
      (delete-directory "a/c")
      (delete-directory "a/b")
      (delete-directory "a"))

     ))
  )