MCPcopy
hub / github.com/google/uuid / TestVersion7

Function TestVersion7

uuid_test.go:825–845  ·  uuid_test.go::TestVersion7

uuid v7 time is only unix milliseconds, so uuid1.Time() == uuid2.Time() is right, but uuid1 must != uuid2

(t *testing.T)

Source from the content-addressed store, hash-verified

823// uuid v7 time is only unix milliseconds, so
824// uuid1.Time() == uuid2.Time() is right, but uuid1 must != uuid2
825func TestVersion7(t *testing.T) {
826 SetRand(nil)
827 m := make(map[string]bool)
828 for x := 1; x < 128; x++ {
829 uuid, err := NewV7()
830 if err != nil {
831 t.Fatalf("could not create UUID: %v", err)
832 }
833 s := uuid.String()
834 if m[s] {
835 t.Errorf("NewV7 returned duplicated UUID %s", s)
836 }
837 m[s] = true
838 if v := uuid.Version(); v != 7 {
839 t.Errorf("UUID of version %s", v)
840 }
841 if uuid.Variant() != RFC4122 {
842 t.Errorf("UUID is variant %d", uuid.Variant())
843 }
844 }
845}
846
847// uuid v7 time is only unix milliseconds, so
848// uuid1.Time() == uuid2.Time() is right, but uuid1 must != uuid2

Callers

nothing calls this directly

Calls 5

SetRandFunction · 0.85
NewV7Function · 0.85
VersionMethod · 0.80
VariantMethod · 0.80
StringMethod · 0.45

Tested by

no test coverage detected