From a121cef86fcf7b3f4e3a8f067a68795da14de72c Mon Sep 17 00:00:00 2001 From: Laria Carolin Chabowski Date: Tue, 2 Apr 2019 21:43:25 +0200 Subject: Expose additional libuuid functions --- test/lua_uuid_test.lua | 25 ++++++++++++++++++++----- 1 file changed, 20 insertions(+), 5 deletions(-) (limited to 'test') 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) -- cgit v1.2.3-70-g09d2