uuid v7 time is only unix milliseconds, so uuid1.Time() == uuid2.Time() is right, but uuid1 must != uuid2
(t *testing.T)
| 823 | // uuid v7 time is only unix milliseconds, so |
| 824 | // uuid1.Time() == uuid2.Time() is right, but uuid1 must != uuid2 |
| 825 | func 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 |