diff options
author | Asbjørn Sloth Tønnesen <ast@2e8.dk> | 2019-07-13 22:24:47 +0000 |
---|---|---|
committer | Asbjørn Sloth Tønnesen <ast@2e8.dk> | 2019-07-13 22:24:47 +0000 |
commit | 23732642cb8c27de229a52ba201af2809aac6ddd (patch) | |
tree | 79a493876d3a8d7c3246acc9f045bbe9d2ade412 /test | |
parent | 8fd0b2cbc4a6fa969b3882bdb1704d9c3ff5ff7a (diff) | |
download | lua-inet-23732642cb8c27de229a52ba201af2809aac6ddd.tar.gz lua-inet-23732642cb8c27de229a52ba201af2809aac6ddd.tar.xz lua-inet-23732642cb8c27de229a52ba201af2809aac6ddd.zip |
add type check and family funcitons
Signed-off-by: Asbjørn Sloth Tønnesen <ast@2e8.dk>
Diffstat (limited to 'test')
-rw-r--r-- | test/inet.lua | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/test/inet.lua b/test/inet.lua index 22f7185..705715a 100644 --- a/test/inet.lua +++ b/test/inet.lua @@ -42,6 +42,7 @@ return test.new(function() ip = inet('10.0.0.0/24') assert(type(ip) == 'table') assert(#ip == 24, 'incorrect netmask') + assert(ip:family() == 4, 'incorrect family') assert(tostring(ip) == '10.0.0.0/24', 'not human readable') assert(inet('10.0.0.0/32') == inet('10.0.0.0')) @@ -119,4 +120,22 @@ return test.new(function() -- TODO inet6.__le -- TODO inet6.__eq + + assert(not inet.is4(false)) + assert(not inet.is4('foo')) + assert(not inet.is4(42)) + assert(inet.is4(inet('0.0.0.0'))) + assert(not inet.is4(inet('::'))) + + assert(not inet.is6(false)) + assert(not inet.is6('foo')) + assert(not inet.is6(42)) + assert(not inet.is6(inet('0.0.0.0'))) + assert(inet.is6(inet('::'))) + + assert(not inet.is(false)) + assert(not inet.is('foo')) + assert(not inet.is(42)) + assert(inet.is(inet('0.0.0.0'))) + assert(inet.is(inet('::'))) end) |