1
0
mirror of https://github.com/vlang/v.git synced 2023-08-10 21:13:21 +03:00

rand: fix rand.uuid_v4()'s clock_seq_hi_and_reserved field

This commit is contained in:
Delyan Angelov
2022-02-18 12:37:27 +02:00
parent c9867a9ae4
commit 3c38abc56e
3 changed files with 24 additions and 10 deletions

View File

@ -12,9 +12,13 @@ fn test_rand_uuid_v4() {
assert uuid1.len == 36
assert uuid2.len == 36
assert uuid3.len == 36
assert uuid1[14] == `4`
assert uuid2[14] == `4`
assert uuid3[14] == `4`
for i in 0 .. 1000 {
x := rand.uuid_v4()
// check the version field is always 4:
assert x[14] == `4`
// and the clock_seq_hi_and_reserved field is valid too:
assert x[19] in [`8`, `9`, `a`, `b`]
}
}
// ulids: