-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest.lua
More file actions
46 lines (40 loc) · 1.24 KB
/
test.lua
File metadata and controls
46 lines (40 loc) · 1.24 KB
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
46
-- test uuid library
require"uuid"
print(uuid.version)
print""
u=uuid.new()
U="uuid generation"
U=U..string.rep(" ",#u-#U)
print(U,"type","time","","os.time")
print(u,"default",uuid.time(u))
u=uuid.new("default")
print(u,"default",uuid.time(u))
u=uuid.new("random")
print(u,"random",uuid.time(u))
u=uuid.new("time")
print(u,"time",uuid.time(u),os.time())
os.execute"sleep 2"
u=uuid.new("time")
print(u,"time",uuid.time(u),os.time())
print""
function test(x,expect)
local isvalid=uuid.isvalid(x)
print(x,isvalid,expect,isvalid==expect and "ok" or "FAIL")
end
U="uuid validation"
U=U..string.rep(" ",#u-#U)
print(U,"isvalid","expect","pass")
-- from tst_uuid.c
test("84949cc5-4701-4a84-895b-354c584a981b", true)
test("84949CC5-4701-4A84-895B-354C584A981B", true)
test("84949cc5-4701-4a84-895b-354c584a981bc", false)
test("84949cc5-4701-4a84-895b-354c584a981", false)
test("84949cc5x4701-4a84-895b-354c584a981b", false)
test("84949cc504701-4a84-895b-354c584a981b", false)
test("84949cc5-470104a84-895b-354c584a981b", false)
test("84949cc5-4701-4a840895b-354c584a981b", false)
test("84949cc5-4701-4a84-895b0354c584a981b", false)
test("g4949cc5-4701-4a84-895b-354c584a981b", false)
test("84949cc5-4701-4a84-895b-354c584a981g", false)
print""
print(uuid.version)