Skip to content

Commit

Permalink
simplify test
Browse files Browse the repository at this point in the history
  • Loading branch information
trabetti committed Feb 26, 2019
1 parent 005951d commit caad4a1
Showing 1 changed file with 14 additions and 39 deletions.
53 changes: 14 additions & 39 deletions uuid_source_test.go
Original file line number Diff line number Diff line change
@@ -1,55 +1,30 @@
package uuid

import (
"testing"
"fmt"
"strings"
"math/rand"

"testing"
"time"
)

func TestUuidSources(t *testing.T) {

uuidSourceA := NewSource(rand.New(rand.NewSource(34576)))
uuidSourceB := NewSource(rand.New(rand.NewSource(34576)))
currentTime := time.Now().UnixNano()
uuidSourceA := NewSource(rand.New(rand.NewSource(currentTime)))
uuidSourceB := NewSource(rand.New(rand.NewSource(currentTime)))

var uuidStrA, uuidStrB string
fmt.Printf("Random values: ")
for i := 0; i < 10; i++ {
uuidStrA += uuidSourceA.New().String() + "."
}
fmt.Printf("%v\n", uuidStrA)

fmt.Printf("Random values: ")
for i := 0; i < 10; i++ {
uuidStrB += uuidSourceB.New().String() + "."
}
fmt.Printf("%v\n", uuidStrB)

if !strings.EqualFold(uuidStrA, uuidStrB) {
t.Error("Uuid values are not reproducaible!")
if uuidSourceA.New().String() != uuidSourceB.New().String() {
t.Error("Uuid values are not reproducaible!")
}
}

uuidSourceA = NewSource(rand.New(rand.NewSource(66)))
uuidSourceB = NewSource(rand.New(rand.NewSource(77)))
uuidSourceA = NewSource(rand.New(rand.NewSource(123)))
uuidSourceB = NewSource(rand.New(rand.NewSource(456)))


uuidStrA = ""
uuidStrB = ""
fmt.Printf("Random values: ")
for i := 0; i < 10; i++ {
uuidStrA += uuidSourceA.New().String() + "."
}
fmt.Printf("%v\n", uuidStrA)

fmt.Printf("Random values: ")
for i := 0; i < 10; i++ {
uuidStrB += uuidSourceB.New().String() + "."
if uuidSourceA.New().String() == uuidSourceB.New().String() {
t.Error("Uuid values should not match!")
}
}
fmt.Printf("%v\n", uuidStrB)

if strings.EqualFold(uuidStrA, uuidStrB) {
t.Error("Uuid values should not be reproducaible!")
}


}

0 comments on commit caad4a1

Please sign in to comment.