aboutsummaryrefslogtreecommitdiff
path: root/test/lua_uuid_test.lua
diff options
context:
space:
mode:
Diffstat (limited to 'test/lua_uuid_test.lua')
-rwxr-xr-xtest/lua_uuid_test.lua25
1 files changed, 20 insertions, 5 deletions
diff --git a/test/lua_uuid_test.lua b/test/lua_uuid_test.lua
index 19ebf67..3406d56 100755
--- a/test/lua_uuid_test.lua
+++ b/test/lua_uuid_test.lua
@@ -2,10 +2,25 @@ package.path = package.path..";./?.lua"
local uuid = require "lua_uuid"
-assert(type(uuid) == "function")
+assert(type(uuid) == "table")
-local first = uuid()
-local second = uuid()
+local function test_generator(gen)
+ local first = gen()
+ local second = gen()
-assert(first ~= second)
-assert(type(uuid()) == "string")
+ assert(first ~= second)
+ assert(type(gen()) == "string")
+end
+
+test_generator(uuid)
+test_generator(uuid.generate)
+test_generator(uuid.generate_binary)
+
+local hexuuid = "cf08a9b2-3492-4b71-9bd9-eb12d9f463a6"
+local binuuid = "\207\008\169\178\052\146\075\113\155\217\235\018\217\244\099\166"
+
+assert(assert(uuid.parse(hexuuid)) == binuuid)
+assert(assert(uuid.unparse(binuuid)) == hexuuid)
+
+assert(uuid.parse("foobar") == nil)
+assert(uuid.unparse("foobar") == nil)