Esempio n. 1
0
// Verifies that Variant5() produces consistent results for a given name space
// and name.
func TestVariant5(t *testing.T) {
	same1 := uuid.Variant5(uuid.NameSpaceDNS(), "some-name")
	same2 := uuid.Variant5(uuid.NameSpaceDNS(), "some-name")
	other_name := uuid.Variant5(uuid.NameSpaceDNS(), "some-other-name")
	other_domain := uuid.Variant5(uuid.NameSpaceX500(), "some-name")

	if same1.String() != "33d1b922-4cf2-566d-a20a-bc0f77f14de7" {
		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..")
	}
}
Esempio n. 2
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..")
	}
}