Kibitised, and improved test coverage. Cloverage currently failing, don't
know why.
This commit is contained in:
parent
3b1d28d3cd
commit
1030ece3ff
5 changed files with 33 additions and 9 deletions
|
|
@ -2,6 +2,7 @@
|
|||
(:use clojure.java.io)
|
||||
(:require [clojure.test :refer :all]
|
||||
[mw-engine.heightmap :refer :all]
|
||||
[mw-engine.world :as world :only [make-world]]
|
||||
[clojure.math.combinatorics :as combo]))
|
||||
|
||||
(deftest apply-heightmap-test
|
||||
|
|
@ -11,6 +12,21 @@
|
|||
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"))
|
||||
;; alternate means of making the world, same tests.
|
||||
(let [world (apply-heightmap (world/make-world 9 9) (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)
|
||||
|
|
|
|||
|
|
@ -4,6 +4,14 @@
|
|||
[clojure.math.combinatorics :as combo]
|
||||
[mw-engine.utils :refer :all]))
|
||||
|
||||
(deftest abs-test
|
||||
(testing "Absolute value function"
|
||||
(is (= (abs 0) 0) "Corner case: nothing comes of nothing, nothing ever could.")
|
||||
(is (= (abs 1) 1) "Corner case: one is one and all alone and ever more shall be so.")
|
||||
(is (= (abs -1) 1) "Corner case: when others are cast down and afflicted, thou shalt be able to raise them up.")
|
||||
(is (= (abs -90371) 90371) "Random check")
|
||||
(is (= (abs 30971) 30971) "Another random check")))
|
||||
|
||||
(deftest get-neighbours-test
|
||||
(testing "Gross functionality of get-neighbours: checks the right number of
|
||||
neighbours returned, doesn't actually check they're the right ones."
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue