mw-engine/test/mw_engine/heightmap_test.clj
Simon Brooke cd99f8fd0b Gone back (hopefully temporarily) to using collage load-image function
while I try to sort out the resources issue. This isn't very satisfactory,
as the collage distribution is compiled using Java 7, which is going to
break for some people, and because I'm bloating my code with two separate
image libraries.
2014-07-30 12:33:45 +01:00

25 lines
1.1 KiB
Clojure

(ns mw-engine.heightmap-test
(:use clojure.java.io)
(:require [clojure.test :refer :all]
[mw-engine.heightmap :refer :all]
[clojure.math.combinatorics :as combo]))
(deftest apply-heightmap-test
(testing "Heightmap functionality"
(let [world (apply-heightmap (as-file "resources/heightmaps/test9x9.png"))
altitudes (map #(:altitude %) (flatten world))
gradients (map #(:gradient %) (flatten world))]
(is (= (count world) 9) "World should be 9x9")
(is (= (count (first world)) 9) "World should be 9x9")
(is (= (count (remove nil? altitudes)) 81)
"All cells should have altitude")
(is (= (count (remove nil? gradients)) 81)
"All cells should have gradient")
(is (> (apply max altitudes)
(apply min altitudes))
"There should be a range of altitudes")
(is (> (apply + gradients) 0)
"At least some gradients must be positive, none should be negative")
)))