summaryrefslogtreecommitdiff
path: root/city/geometry-test.lua
diff options
context:
space:
mode:
Diffstat (limited to 'city/geometry-test.lua')
-rw-r--r--city/geometry-test.lua24
1 files changed, 24 insertions, 0 deletions
diff --git a/city/geometry-test.lua b/city/geometry-test.lua
new file mode 100644
index 0000000..ab3265d
--- /dev/null
+++ b/city/geometry-test.lua
@@ -0,0 +1,24 @@
+local test = require('minunit').test
+local geom = require 'geometry'
+
+test(
+ 'create point object',
+ function()
+ local pt = geom.point(1, 5.5)
+ assert(pt.x == 1)
+ assert(pt.y == 5.5)
+ local mt = getmetatable(pt)
+ assert(mt.__index == geom.point)
+ end
+)
+
+test(
+ 'point distances',
+ function()
+ local a = geom.point(1, 3)
+ local b = geom.point(4, 7)
+ assert(a:distance_to(b) == 5)
+
+ assert(a:distance_to(a) == 0)
+ end
+)