-
Notifications
You must be signed in to change notification settings - Fork 4
/
uuid4Spec.js
36 lines (33 loc) · 1.1 KB
/
uuid4Spec.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
(function (Random) {
describe("uuid4", function () {
function makeEngine(input) {
var index = 0;
return function () {
return input[index++];
};
}
[{
input: [0, 0, 0, 0],
output: "00000000-0000-4000-8000-000000000000"
}, {
input: [0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff],
output: "ffffffff-ffff-4fff-bfff-ffffffffffff"
}, {
input: [0xdeadbeef, 0x12345678, 0xfedcba98, 0x13371337],
output: "deadbeef-5678-4567-ba98-cba913371337"
}, {
input: [0x12345678, 0x90abcdef, 0x94746842, 0x81354732],
output: "12345678-cdef-4cde-a842-468481354732"
}].forEach(function (o) {
var input = o.input;
var output = o.output;
describe("with an engine that produces " + input, function () {
it("returns '" + output + "'", function () {
var engine = makeEngine(input);
var actual = Random.uuid4(engine);
expect(actual).toBe(output);
});
});
});
});
}(typeof module !== "undefined" ? require("../lib/random") : Random));