mirror of
https://github.com/1bardesign/batteries.git
synced 2024-11-22 06:04:35 +00:00
tests: Add ulid tests
This commit is contained in:
parent
8d8b0dc243
commit
c0aba5027c
@ -179,3 +179,17 @@ local function test_uuid4()
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
local function test_ulid()
|
||||
for i = 1, 100 do
|
||||
local ulid = assert(uuid.ulid())
|
||||
|
||||
-- right len
|
||||
assert(#ulid == 26)
|
||||
-- have the same timestamp with the same time
|
||||
local a, b = uuid.ulid(nil, 1):sub(1, 10), uuid.ulid(nil, 1):sub(1, 10)
|
||||
assert(a == b)
|
||||
-- don't have characters out of crockford base32
|
||||
assert(not ulid:match("[ILOU%l]"))
|
||||
end
|
||||
end
|
||||
|
Loading…
Reference in New Issue
Block a user