Software /
code /
prosody
Annotate
tests/test_util_uuid.lua @ 7567:495de404a8ae
ejabberdsql2prosody: rename variable 'host' to prevent shadowing upvalue [luacheck]
Functions roster(), roster_pending(), roster_group(), private_storage() and
offline_msg() have argument named "host", which used to shadow upvalue of this
variable before this change. Instead of renaming this argument, let's rename
the variable to match what the script says in usage:
Usage: ejabberdsql2prosody.lua filename.txt hostname
author | Anton Shestakov <av6@dwimlabs.net> |
---|---|
date | Fri, 12 Aug 2016 13:44:47 +0800 |
parent | 7512:7a655ff689b1 |
rev | line source |
---|---|
7073
31fa6770019c
tests: Add test for util.uuid (checks that the output format is correct)
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
1 -- This tests the format, not the randomness |
31fa6770019c
tests: Add test for util.uuid (checks that the output format is correct)
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
2 |
31fa6770019c
tests: Add test for util.uuid (checks that the output format is correct)
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
3 -- https://tools.ietf.org/html/rfc4122#section-4.4 |
31fa6770019c
tests: Add test for util.uuid (checks that the output format is correct)
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
4 |
31fa6770019c
tests: Add test for util.uuid (checks that the output format is correct)
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
5 local pattern = "^" .. table.concat({ |
31fa6770019c
tests: Add test for util.uuid (checks that the output format is correct)
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
6 string.rep("%x", 8), |
31fa6770019c
tests: Add test for util.uuid (checks that the output format is correct)
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
7 string.rep("%x", 4), |
31fa6770019c
tests: Add test for util.uuid (checks that the output format is correct)
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
8 "4" .. -- version |
31fa6770019c
tests: Add test for util.uuid (checks that the output format is correct)
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
9 string.rep("%x", 3), |
31fa6770019c
tests: Add test for util.uuid (checks that the output format is correct)
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
10 "[89ab]" .. -- reserved bits of 1 and 0 |
31fa6770019c
tests: Add test for util.uuid (checks that the output format is correct)
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
11 string.rep("%x", 3), |
31fa6770019c
tests: Add test for util.uuid (checks that the output format is correct)
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
12 string.rep("%x", 12), |
31fa6770019c
tests: Add test for util.uuid (checks that the output format is correct)
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
13 }, "%-") .. "$"; |
31fa6770019c
tests: Add test for util.uuid (checks that the output format is correct)
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
14 |
31fa6770019c
tests: Add test for util.uuid (checks that the output format is correct)
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
15 function generate(generate) |
7512
7a655ff689b1
test_util_uuid: remove unused one-letter loop variable [luacheck]
Anton Shestakov <av6@dwimlabs.net>
parents:
7073
diff
changeset
|
16 for _ = 1, 100 do |
7073
31fa6770019c
tests: Add test for util.uuid (checks that the output format is correct)
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
17 assert_is(generate():match(pattern)); |
31fa6770019c
tests: Add test for util.uuid (checks that the output format is correct)
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
18 end |
31fa6770019c
tests: Add test for util.uuid (checks that the output format is correct)
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
19 end |
31fa6770019c
tests: Add test for util.uuid (checks that the output format is correct)
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
20 |
31fa6770019c
tests: Add test for util.uuid (checks that the output format is correct)
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
21 function seed(seed) |
31fa6770019c
tests: Add test for util.uuid (checks that the output format is correct)
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
22 assert_equal(seed("random string here"), nil, "seed doesn't return anything"); |
31fa6770019c
tests: Add test for util.uuid (checks that the output format is correct)
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
23 end |
31fa6770019c
tests: Add test for util.uuid (checks that the output format is correct)
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
24 |