array-ec-test.ss
#| array-ec-test.ss: Tests for the array-ec.ss module.
Copyright (C) 2007 Will M. Farr <farr@mit.edu>

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., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
|#

(module array-ec-test mzscheme
  (require (planet "test.ss" ("schematics" "schemeunit.plt" 2))
           "array-ec.ss")
  
  (provide array-ec-test-suite)
  
  (define array-ec-test-suite
    (test-suite
     "array-ec.ss test suite"
     (test-case
      "array-ec"
      (let ((a (array-ec (shape 0 10 0 10) (:range i 10) (:range j 10) (+ (cos i) (sin j)))))
        (do-ec (:range i 10) (:range j 10)
          (check = (array-ref a i j) (+ (cos i) (sin j))))))
     (test-case
      ":array"
      (let ((a (array-ec (shape 0 5 0 5 0 5) (:range i 5) (:range j 5) (:range k 5) (random (+ 1 i j k)))))
        (check =
               (sum-ec (:array x a) x)
               (sum-ec (:array x (index i j k) a) (array-ref a i j k))))))))