makeTestNewV7TestVector as defined in Draft04
()
| 728 | |
| 729 | // makeTestNewV7TestVector as defined in Draft04 |
| 730 | func makeTestNewV7TestVector() func(t *testing.T) { |
| 731 | return func(t *testing.T) { |
| 732 | pRand := make([]byte, 10) |
| 733 | //first 2 bytes will be read by clockSeq. First 4 bits will be overridden by Version. The next bits should be 0xCC3(3267) |
| 734 | binary.LittleEndian.PutUint16(pRand[:2], uint16(0xCC3)) |
| 735 | //8bytes will be read for rand_b. First 2 bits will be overridden by Variant |
| 736 | binary.LittleEndian.PutUint64(pRand[2:], uint64(0x18C4DC0C0C07398F)) |
| 737 | |
| 738 | g := &Gen{ |
| 739 | epochFunc: func() time.Time { |
| 740 | return time.UnixMilli(1645557742000) |
| 741 | }, |
| 742 | rand: bytes.NewReader(pRand), |
| 743 | } |
| 744 | u, err := g.NewV7() |
| 745 | if err != nil { |
| 746 | t.Fatal(err) |
| 747 | } |
| 748 | if got, want := u.Version(), V7; got != want { |
| 749 | t.Errorf("got version %d, want %d", got, want) |
| 750 | } |
| 751 | if got, want := u.Variant(), VariantRFC9562; got != want { |
| 752 | t.Errorf("got variant %d, want %d", got, want) |
| 753 | } |
| 754 | if got, want := u.String()[:15], "017f22e2-79b0-7"; got != want { |
| 755 | t.Errorf("got version %q, want %q", got, want) |
| 756 | } |
| 757 | } |
| 758 | } |
| 759 | |
| 760 | func makeTestNewV7Basic10000000() func(t *testing.T) { |
| 761 | return func(t *testing.T) { |