-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathv4_test.go
65 lines (52 loc) · 984 Bytes
/
v4_test.go
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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
package uuid_test
import (
"crypto/rand"
"fmt"
"testing"
"github.com/bentranter/uuid"
satori "github.com/satori/go.uuid"
)
var buf [16]byte
func Example() {
id := uuid.NewV4()
fmt.Printf("%s\n", id)
}
func TestNewV1(t *testing.T) {
x := uuid.NewV1().String()
y := uuid.NewV1().String()
if x == y {
t.Fatalf("Values %s and %s\n are the same\n", x, y)
}
}
func TestNewV4(t *testing.T) {
x := uuid.NewV4().String()
y := uuid.NewV4().String()
if x == y {
t.Fatalf("Values %s and %s\n are the same\n", x, y)
}
}
func BenchmarkNewV1(b *testing.B) {
for n := 0; n < b.N; n++ {
uuid.NewV1()
}
}
func BenchmarkNewV4(b *testing.B) {
for n := 0; n < b.N; n++ {
uuid.NewV4()
}
}
func BenchmarkNewSatoriV1(b *testing.B) {
for n := 0; n < b.N; n++ {
satori.NewV1()
}
}
func BenchmarkNewSatoriV4(b *testing.B) {
for n := 0; n < b.N; n++ {
satori.NewV4()
}
}
func BenchmarkRandAlloc(b *testing.B) {
for n := 0; n < b.N; n++ {
rand.Read(buf[:])
}
}