From b605af00be541e8a2154ca2a690b5dc06fe00164 Mon Sep 17 00:00:00 2001 From: BONNAURE Olivier Date: Tue, 9 Apr 2024 17:39:26 +0200 Subject: [PATCH] add specs --- test/tool/net/uuidv4_test.lua | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100644 test/tool/net/uuidv4_test.lua diff --git a/test/tool/net/uuidv4_test.lua b/test/tool/net/uuidv4_test.lua new file mode 100644 index 000000000..a0fcaa670 --- /dev/null +++ b/test/tool/net/uuidv4_test.lua @@ -0,0 +1,23 @@ +-- Copyright 2022 Justine Alexandra Roberts Tunney +-- +-- Permission to use, copy, modify, and/or distribute this software for +-- any purpose with or without fee is hereby granted, provided that the +-- above copyright notice and this permission notice appear in all copies. +-- +-- THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL +-- WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED +-- WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE +-- AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL +-- DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR +-- PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER +-- TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR +-- PERFORMANCE OF THIS SOFTWARE. + +assert(#UuidV4() == 36) +assert(string.sub(UuidV4(), 9, 9) == "-") +assert(string.sub(UuidV4(), 14, 14) == "-") +assert(string.sub(UuidV4(), 15, 15) == "4") +assert(string.sub(UuidV4(), 19, 19) == "-") +local y = string.sub(UuidV4(), 20, 20) +assert(y == "8" or y == "9" or y == "a" or y == "b") +assert(string.sub(UuidV4(), 24, 24) == "-")