Prepended all namespaces with 'cc.journeyman'; tests run, 4 don't pass.

This commit is contained in:
Simon Brooke 2020-11-15 21:09:18 +00:00
parent 37dbb767ac
commit 310896cc95
No known key found for this signature in database
GPG key ID: A7A4F18D1D4DF987
34 changed files with 107 additions and 81 deletions

View 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)))
))

View 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."))))

View 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]))