This repository was archived by the owner on Apr 15, 2018. It is now read-only.
forked from ClearTables/ClearTables
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest-aero.lua
45 lines (39 loc) · 2.42 KB
/
test-aero.lua
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
--[[
This file is part of ClearTables
@author Paul Norman <[email protected]>
@copyright 2015-2016 Paul Norman, MIT license
]]--
require "aero"
print("aero.lua tests")
print("TESTING: accept_airport")
assert(not accept_airport({}), "test failed: untagged")
assert(not accept_airport({foo="bar"}), "test failed: other tags")
assert(not accept_airport({aeroway="foo"}), "test failed: other aeroway")
assert(accept_airport({aeroway="aerodrome"}), "test failed: aerodrome")
assert(accept_airport({aeroway="heliport"}), "test failed: heliport")
print("TESTING: accept_aeroway")
assert(not accept_aeroway({}), "test failed: untagged")
assert(not accept_aeroway({foo="bar"}), "test failed: other tags")
assert(not accept_aeroway({aeroway="foo"}), "test failed: other aeroway")
assert(accept_aeroway({aeroway="runway"}), "test failed: runway")
assert(accept_aeroway({aeroway="taxiway"}), "test failed: taxiway")
print("TESTING: transform_airport")
assert(deepcompare(transform_airport({}), {}), "test failed: no tags")
assert(transform_airport({aeroway="aerodrome"}).airport == "aerodrome", "test failed: aerodrome")
assert(transform_airport({aeroway="heliport"}).airport == "heliport", "test failed: heliport")
assert(transform_airport({name="foo"}).name == "foo", "test failed: name")
assert(transform_airport({["name:en"]="foo"}).names == '"en"=>"foo"', "test failed: names")
assert(transform_airport({iata="FOO"}).iata == "FOO", "test failed: iata")
assert(transform_airport({iata="FOOD"}).iata == "FOO", "test failed: long iata")
assert(transform_airport({iata="FO"}).iata == "FO", "test failed: short iata")
assert(transform_airport({iaco="FOOO"}).iaco == "FOOO", "test failed: iaco")
assert(transform_airport({iaco="FOOOD"}).iaco == "FOOO", "test failed: long iaco")
assert(transform_airport({iaco="FO"}).iaco == "FO", "test failed: short iaco")
assert(transform_airport({ref="foo", iata="bar", iaco="baz"}).ref == "foo", "test failed: ref ref")
assert(transform_airport({iata="bar", iaco="baz"}).ref == "bar", "test failed: ref iata")
assert(transform_airport({iaco="baz"}).ref == "baz", "test failed: ref iaco")
print("TESTING: transform_aeroway")
assert(deepcompare(transform_aeroway({}), {}), "test failed: no tags")
assert(transform_aeroway({aeroway="runway"}).aeroway == "runway", "test failed: runway")
assert(transform_aeroway({aeroway="taxiway"}).aeroway == "taxiway", "test failed: taxiway")
assert(transform_aeroway({ref="foo"}).ref == "foo", "test failed: ref")