Software /
code /
prosody
Comparison
spec/util_uuid_spec.lua @ 8236:4878e4159e12
Port tests to the `busted` test runner
author | Waqas Hussain <waqas20@gmail.com> |
---|---|
date | Fri, 15 Sep 2017 17:07:57 -0400 |
child | 8241:e7496cff1215 |
comparison
equal
deleted
inserted
replaced
8235:7d9a2c200736 | 8236:4878e4159e12 |
---|---|
1 -- This tests the format, not the randomness | |
2 | |
3 local uuid = require "util.uuid"; | |
4 | |
5 describe("util.uuid", function() | |
6 describe("#generate()", function() | |
7 it("should work follow the UUID pattern", function() | |
8 -- https://tools.ietf.org/html/rfc4122#section-4.4 | |
9 | |
10 local pattern = "^" .. table.concat({ | |
11 string.rep("%x", 8), | |
12 string.rep("%x", 4), | |
13 "4" .. -- version | |
14 string.rep("%x", 3), | |
15 "[89ab]" .. -- reserved bits of 1 and 0 | |
16 string.rep("%x", 3), | |
17 string.rep("%x", 12), | |
18 }, "%-") .. "$"; | |
19 | |
20 for _ = 1, 100 do | |
21 assert.is_string(uuid.generate():match(pattern)); | |
22 end | |
23 end); | |
24 end); | |
25 | |
26 describe("#seed()", function() | |
27 it("should return nothing", function() | |
28 assert.is_nil(uuid.seed("random string here"), "seed doesn't return anything"); | |
29 end); | |
30 end); | |
31 end); |