From 8ff62f7a5f9441a3ab2935e541935f18fcd4a9a1 Mon Sep 17 00:00:00 2001 From: David Capello Date: Tue, 18 Apr 2023 07:41:32 -0300 Subject: [PATCH] [lua] Add Uuid tests Missing file from 636cce6f0de14e8b950fe8af97b666d63ba1290c commit --- tests/scripts/uuid.lua | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100644 tests/scripts/uuid.lua diff --git a/tests/scripts/uuid.lua b/tests/scripts/uuid.lua new file mode 100644 index 000000000..fd1210578 --- /dev/null +++ b/tests/scripts/uuid.lua @@ -0,0 +1,26 @@ +-- Copyright (C) 2023 Igara Studio S.A. +-- +-- This file is released under the terms of the MIT license. +-- Read LICENSE.txt for more information. + +local a = Uuid() +local b = a +assert(a == b) +assert(a ~= Uuid()) + +local s = tostring(a) -- e.g. "74341b56-4f7f-4ab1-9495-58cf5bce0e1c" +assert(a == Uuid(s)) -- Check that Uuid(string) is working +assert(#s == 36) + +-- Test __index +local t = string.format("%02x%02x%02x%02x-%02x%02x-%02x%02x-%02x%02x-%02x%02x%02x%02x%02x%02x", + a[1], a[2], a[3], a[4], + a[5], a[6], + a[7], a[8], + a[9], a[10], + a[11], a[12], a[13], a[14], a[15], a[16]) +assert(s == t) + +-- Out of bounds +assert(nil == a[0]) +assert(nil == a[17])