From c0aba5027ccad61b9323cec3e13187b8fc497e93 Mon Sep 17 00:00:00 2001 From: rhy <81539300+rhynomatt@users.noreply.github.com> Date: Mon, 9 Jan 2023 16:02:44 -0300 Subject: [PATCH] tests: Add ulid tests --- .test/tests.lua | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/.test/tests.lua b/.test/tests.lua index e379429..1474625 100644 --- a/.test/tests.lua +++ b/.test/tests.lua @@ -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