Prepended all namespaces with 'cc.journeyman'; tests run, 4 don't pass.
This commit is contained in:
parent
37dbb767ac
commit
310896cc95
34 changed files with 107 additions and 81 deletions
36
test/cc/journeyman/the_great_game/world/location_test.clj
Normal file
36
test/cc/journeyman/the_great_game/world/location_test.clj
Normal file
|
|
@ -0,0 +1,36 @@
|
|||
(ns cc.journeyman.the-great-game.world.location-test
|
||||
(:require [clojure.test :refer :all]
|
||||
[cc.journeyman.the-great-game.world.location :refer :all]))
|
||||
|
||||
(deftest get-coords-test
|
||||
(testing "Get coordinates of location"
|
||||
(let [expected {:x 5 :y 7}
|
||||
actual (get-coords {:x 5 :y 7})]
|
||||
(is (= actual expected)))
|
||||
(let [expected {:x -4 :y 55}
|
||||
actual (get-coords [{:x -4 :y 55} :auchencairn :galloway :scotland])]
|
||||
(is (= actual expected)))
|
||||
(let [expected nil
|
||||
actual (get-coords [:auchencairn :galloway :scotland])]
|
||||
(is (= actual expected)))
|
||||
))
|
||||
|
||||
(deftest distance-test
|
||||
(testing "Distance between two locations"
|
||||
(let [expected 4.242640687119285
|
||||
actual (distance-between {:x 5 :y 5} {:x 2 :y 2})]
|
||||
(is (= actual expected)))
|
||||
(let [expected 3
|
||||
actual (distance-between {:x 5 :y 5} {:x 2 :y 5})]
|
||||
(is (= actual expected)))
|
||||
(let [expected 50.80354318352215
|
||||
actual (distance-between
|
||||
{:x 5 :y 5}
|
||||
[{:x -4 :y 55} :auchencairn :galloway :scotland])]
|
||||
(is (= actual expected)))
|
||||
(let [expected nil
|
||||
actual (distance-between
|
||||
{:x 5 :y 5}
|
||||
[:auchencairn :galloway :scotland])]
|
||||
(is (= actual expected)))
|
||||
))
|
||||
33
test/cc/journeyman/the_great_game/world/routes_test.clj
Normal file
33
test/cc/journeyman/the_great_game/world/routes_test.clj
Normal file
|
|
@ -0,0 +1,33 @@
|
|||
(ns cc.journeyman.the-great-game.world.routes-test
|
||||
(:require [clojure.test :refer :all]
|
||||
[cc.journeyman.the-great-game.world.routes :refer :all]
|
||||
[cc.journeyman.the-great-game.world.world :refer [default-world]]))
|
||||
|
||||
|
||||
(deftest routing-test
|
||||
(testing "Routing: possible route"
|
||||
(let [origin :buckie
|
||||
destination :glasgow
|
||||
routes (find-routes (:routes default-world) origin destination)]
|
||||
(is
|
||||
(= (first (first routes)) origin)
|
||||
"Routes should be from the specified origin")
|
||||
(is
|
||||
(= (last (first routes)) destination)
|
||||
"Routes should be from the specified destination")
|
||||
(is
|
||||
(= (count (set (map first routes))) 1)
|
||||
"All routes should have the same origin")
|
||||
(is
|
||||
(= (count (set (map last routes))) 1)
|
||||
"All routes should have the same destination")
|
||||
(is
|
||||
(= (count (set (map count routes))) 1)
|
||||
"All selected routes should have the same length")
|
||||
))
|
||||
(testing "Impossible route"
|
||||
(let [origin :buckie
|
||||
destination :london ;; not present in the routing map
|
||||
actual (find-routes (:routes default-world) origin destination)]
|
||||
(is (nil? actual) "There should be no route returned."))))
|
||||
|
||||
4
test/cc/journeyman/the_great_game/world/world_test.clj
Normal file
4
test/cc/journeyman/the_great_game/world/world_test.clj
Normal file
|
|
@ -0,0 +1,4 @@
|
|||
(ns cc.journeyman.the-great-game.world.world-test
|
||||
(:require [clojure.test :refer :all]
|
||||
[cc.journeyman.the-great-game.world.world :refer :all]))
|
||||
|
||||
Loading…
Add table
Add a link
Reference in a new issue