Пример #1
0
// Verifies that Variant3() produces consistent results for a given name space
// and name.
func TestVariant3(t *testing.T) {
	same1 := uuid.Variant3(uuid.NameSpaceDNS(), "some-name")
	same2 := uuid.Variant3(uuid.NameSpaceDNS(), "some-name")
	other_name := uuid.Variant3(uuid.NameSpaceDNS(), "some-other-name")
	other_domain := uuid.Variant3(uuid.NameSpaceX500(), "some-name")

	if same1.String() != "b43b195b-cea8-388b-84c6-453be0976081" {
		t.Fatal("UUID generation for 'some-name' doesn't match known output.")
	}

	if !same1.Equal(same2) {
		t.Fatal("UUID generation for 'some-name' is not the same.")
	}

	if same1.Equal(other_name) {
		t.Fatal("UUID generation for 'some-other-name' were the same.")
	}

	if same1.Equal(other_domain) {
		t.Fatal("UUID generation for 'some-name' in other domain not different..")
	}
}
Пример #2
0
// Benchmarks the Variant3() UUIDs.
func BenchmarkVariant3(b *testing.B) {
	u := uuid.NameSpaceURL()
	for i := 0; i < b.N; i++ {
		uuid.Variant3(u, "http://apcera.com/uuidtest_url_demo_url")
	}
}