Debian Codegraph @

codec_test.go

raw symbols SCIP
1 // Copyright (C) 2013-2018 by Maxim Bublis <[email protected]>
2 //
3 // Permission is hereby granted, free of charge, to any person obtaining
4 // a copy of this software and associated documentation files (the
5 // "Software"), to deal in the Software without restriction, including
6 // without limitation the rights to use, copy, modify, merge, publish,
7 // distribute, sublicense, and/or sell copies of the Software, and to
8 // permit persons to whom the Software is furnished to do so, subject to
9 // the following conditions:
10 //
11 // The above copyright notice and this permission notice shall be
12 // included in all copies or substantial portions of the Software.
13 //
14 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15 // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16 // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17 // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18 // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19 // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20 // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
21
22 package uuidscip-go gomod github.com/gofrs/uuid/v5 . `github.com/gofrs/uuid/v5`/
23
24 import (
25 "bytesscip-go gomod github.com/golang/go/src go1.25 bytes/"
26 "regexpscip-go gomod github.com/golang/go/src go1.25 regexp/"
27 "stringsscip-go gomod github.com/golang/go/src go1.25 strings/"
28 "testingscip-go gomod github.com/golang/go/src go1.25 testing/"
29 )
30
31 // codecTestData holds []byte data for a UUID we commonly use for testing.
32 var codecTestDatascip-go gomod github.com/gofrs/uuid/v5 . `github.com/gofrs/uuid/v5`/codecTestData. = []byte{0x6b, 0xa7, 0xb8, 0x10, 0x9d, 0xad, 0x11, 0xd1, 0x80, 0xb4, 0x00, 0xc0, 0x4f, 0xd4, 0x30, 0xc8}
33
34 // codecTestUUID is the UUID value corresponding to codecTestData.
35 var codecTestUUIDscip-go gomod github.com/gofrs/uuid/v5 . `github.com/gofrs/uuid/v5`/codecTestUUID. = UUIDscip-go gomod github.com/gofrs/uuid/v5 . `github.com/gofrs/uuid/v5`/UUID#{0x6b, 0xa7, 0xb8, 0x10, 0x9d, 0xad, 0x11, 0xd1, 0x80, 0xb4, 0x00, 0xc0, 0x4f, 0xd4, 0x30, 0xc8}
36
37 func TestFromBytesscip-go gomod github.com/gofrs/uuid/v5 . `github.com/gofrs/uuid/v5`/TestFromBytes().(t *testingscip-go gomod github.com/golang/go/src go1.25 testing/.Tscip-go gomod github.com/golang/go/src go1.25 testing/T#) {
38 t.Runscip-go gomod github.com/golang/go/src go1.25 testing/T#Run().("Valid", func(t *testingscip-go gomod github.com/golang/go/src go1.25 testing/.Tscip-go gomod github.com/golang/go/src go1.25 testing/T#) {
39 got, err := FromBytesscip-go gomod github.com/gofrs/uuid/v5 . `github.com/gofrs/uuid/v5`/FromBytes().(codecTestDatascip-go gomod github.com/gofrs/uuid/v5 . `github.com/gofrs/uuid/v5`/codecTestData.)
40 if err != nil {
41 t.Fatalscip-go gomod github.com/golang/go/src go1.25 testing/common#Fatal().(err)
42 }
43 if got != codecTestUUIDscip-go gomod github.com/gofrs/uuid/v5 . `github.com/gofrs/uuid/v5`/codecTestUUID. {
44 t.Fatalfscip-go gomod github.com/golang/go/src go1.25 testing/common#Fatalf().("FromBytes(%x) = %v, want %v", codecTestDatascip-go gomod github.com/gofrs/uuid/v5 . `github.com/gofrs/uuid/v5`/codecTestData., got, codecTestUUIDscip-go gomod github.com/gofrs/uuid/v5 . `github.com/gofrs/uuid/v5`/codecTestUUID.)
45 }
46 })
47 t.Runscip-go gomod github.com/golang/go/src go1.25 testing/T#Run().("Invalid", func(t *testingscip-go gomod github.com/golang/go/src go1.25 testing/.Tscip-go gomod github.com/golang/go/src go1.25 testing/T#) {
48 var short [][]byte
49 for i := range codecTestDatascip-go gomod github.com/gofrs/uuid/v5 . `github.com/gofrs/uuid/v5`/codecTestData. {
50 short = append(short, codecTestDatascip-go gomod github.com/gofrs/uuid/v5 . `github.com/gofrs/uuid/v5`/codecTestData.[:i])
51 }
52 var long [][]byte
53 for i := 1; i < 17; i++ {
54 tmp := append(codecTestDatascip-go gomod github.com/gofrs/uuid/v5 . `github.com/gofrs/uuid/v5`/codecTestData., make([]byte, i)...)
55 long = append(long, tmp)
56 }
57 invalid := append(short, long...)
58 for _, b := range invalid {
59 got, err := FromBytesscip-go gomod github.com/gofrs/uuid/v5 . `github.com/gofrs/uuid/v5`/FromBytes().(b)
60 if err == nil {
61 t.Fatalfscip-go gomod github.com/golang/go/src go1.25 testing/common#Fatalf().("FromBytes(%x): want err != nil, got %v", b, got)
62 }
63 }
64 })
65 }
66
67 func TestFromBytesOrNilscip-go gomod github.com/gofrs/uuid/v5 . `github.com/gofrs/uuid/v5`/TestFromBytesOrNil().(t *testingscip-go gomod github.com/golang/go/src go1.25 testing/.Tscip-go gomod github.com/golang/go/src go1.25 testing/T#) {
68 t.Runscip-go gomod github.com/golang/go/src go1.25 testing/T#Run().("Invalid", func(t *testingscip-go gomod github.com/golang/go/src go1.25 testing/.Tscip-go gomod github.com/golang/go/src go1.25 testing/T#) {
69 b := []byte{4, 8, 15, 16, 23, 42}
70 got := FromBytesOrNilscip-go gomod github.com/gofrs/uuid/v5 . `github.com/gofrs/uuid/v5`/FromBytesOrNil().(b)
71 if got != Nilscip-go gomod github.com/gofrs/uuid/v5 . `github.com/gofrs/uuid/v5`/Nil. {
72 t.Errorfscip-go gomod github.com/golang/go/src go1.25 testing/common#Errorf().("FromBytesOrNil(%x): got %v, want %v", b, got, Nilscip-go gomod github.com/gofrs/uuid/v5 . `github.com/gofrs/uuid/v5`/Nil.)
73 }
74 })
75 t.Runscip-go gomod github.com/golang/go/src go1.25 testing/T#Run().("Valid", func(t *testingscip-go gomod github.com/golang/go/src go1.25 testing/.Tscip-go gomod github.com/golang/go/src go1.25 testing/T#) {
76 got := FromBytesOrNilscip-go gomod github.com/gofrs/uuid/v5 . `github.com/gofrs/uuid/v5`/FromBytesOrNil().(codecTestDatascip-go gomod github.com/gofrs/uuid/v5 . `github.com/gofrs/uuid/v5`/codecTestData.)
77 if got != codecTestUUIDscip-go gomod github.com/gofrs/uuid/v5 . `github.com/gofrs/uuid/v5`/codecTestUUID. {
78 t.Errorfscip-go gomod github.com/golang/go/src go1.25 testing/common#Errorf().("FromBytesOrNil(%x): got %v, want %v", codecTestDatascip-go gomod github.com/gofrs/uuid/v5 . `github.com/gofrs/uuid/v5`/codecTestData., got, codecTestUUIDscip-go gomod github.com/gofrs/uuid/v5 . `github.com/gofrs/uuid/v5`/codecTestUUID.)
79 }
80 })
81
82 }
83
84 type fromStringTestscip-go gomod github.com/gofrs/uuid/v5 . `github.com/gofrs/uuid/v5`/fromStringTest# struct {
85 inputscip-go gomod github.com/gofrs/uuid/v5 . `github.com/gofrs/uuid/v5`/fromStringTest#input. string
86 variantscip-go gomod github.com/gofrs/uuid/v5 . `github.com/gofrs/uuid/v5`/fromStringTest#variant. string
87 }
88
89 // Run runs the FromString test in a subtest of t, named by fst.variant.
90 func (fst fromStringTestscip-go gomod github.com/gofrs/uuid/v5 . `github.com/gofrs/uuid/v5`/fromStringTest#) TestFromStringscip-go gomod github.com/gofrs/uuid/v5 . `github.com/gofrs/uuid/v5`/fromStringTest#TestFromString().(t *testingscip-go gomod github.com/golang/go/src go1.25 testing/.Tscip-go gomod github.com/golang/go/src go1.25 testing/T#) {
91 t.Runscip-go gomod github.com/golang/go/src go1.25 testing/T#Run().(fst.variantscip-go gomod github.com/gofrs/uuid/v5 . `github.com/gofrs/uuid/v5`/fromStringTest#variant., func(t *testingscip-go gomod github.com/golang/go/src go1.25 testing/.Tscip-go gomod github.com/golang/go/src go1.25 testing/T#) {
92 got, err := FromStringscip-go gomod github.com/gofrs/uuid/v5 . `github.com/gofrs/uuid/v5`/FromString().(fst.inputscip-go gomod github.com/gofrs/uuid/v5 . `github.com/gofrs/uuid/v5`/fromStringTest#input.)
93 if err != nil {
94 t.Fatalfscip-go gomod github.com/golang/go/src go1.25 testing/common#Fatalf().("FromString(%q): %v", fst.inputscip-go gomod github.com/gofrs/uuid/v5 . `github.com/gofrs/uuid/v5`/fromStringTest#input., err)
95 }
96 if want := codecTestUUIDscip-go gomod github.com/gofrs/uuid/v5 . `github.com/gofrs/uuid/v5`/codecTestUUID.; got != want {
97 t.Fatalfscip-go gomod github.com/golang/go/src go1.25 testing/common#Fatalf().("FromString(%q) = %v, want %v", fst.inputscip-go gomod github.com/gofrs/uuid/v5 . `github.com/gofrs/uuid/v5`/fromStringTest#input., got, want)
98 }
99 })
100 }
101
102 func (fst fromStringTestscip-go gomod github.com/gofrs/uuid/v5 . `github.com/gofrs/uuid/v5`/fromStringTest#) TestUnmarshalTextscip-go gomod github.com/gofrs/uuid/v5 . `github.com/gofrs/uuid/v5`/fromStringTest#TestUnmarshalText().(t *testingscip-go gomod github.com/golang/go/src go1.25 testing/.Tscip-go gomod github.com/golang/go/src go1.25 testing/T#) {
103 t.Runscip-go gomod github.com/golang/go/src go1.25 testing/T#Run().(fst.variantscip-go gomod github.com/gofrs/uuid/v5 . `github.com/gofrs/uuid/v5`/fromStringTest#variant., func(t *testingscip-go gomod github.com/golang/go/src go1.25 testing/.Tscip-go gomod github.com/golang/go/src go1.25 testing/T#) {
104 var u UUIDscip-go gomod github.com/gofrs/uuid/v5 . `github.com/gofrs/uuid/v5`/UUID#
105 err := u.UnmarshalTextscip-go gomod github.com/gofrs/uuid/v5 . `github.com/gofrs/uuid/v5`/UUID#UnmarshalText().([]byte(fst.inputscip-go gomod github.com/gofrs/uuid/v5 . `github.com/gofrs/uuid/v5`/fromStringTest#input.))
106 if err != nil {
107 t.Fatalfscip-go gomod github.com/golang/go/src go1.25 testing/common#Fatalf().("UnmarshalText(%q) (%s): %v", fst.inputscip-go gomod github.com/gofrs/uuid/v5 . `github.com/gofrs/uuid/v5`/fromStringTest#input., fst.variantscip-go gomod github.com/gofrs/uuid/v5 . `github.com/gofrs/uuid/v5`/fromStringTest#variant., err)
108 }
109 if want := codecTestDatascip-go gomod github.com/gofrs/uuid/v5 . `github.com/gofrs/uuid/v5`/codecTestData.; !bytesscip-go gomod github.com/golang/go/src go1.25 bytes/.Equalscip-go gomod github.com/golang/go/src go1.25 bytes/Equal().(u[:], want[:]) {
110 t.Fatalfscip-go gomod github.com/golang/go/src go1.25 testing/common#Fatalf().("UnmarshalText(%q) (%s) = %v, want %v", fst.inputscip-go gomod github.com/gofrs/uuid/v5 . `github.com/gofrs/uuid/v5`/fromStringTest#input., fst.variantscip-go gomod github.com/gofrs/uuid/v5 . `github.com/gofrs/uuid/v5`/fromStringTest#variant., u, want)
111 }
112 })
113 }
114
115 // fromStringTests contains UUID variants that are expected to be parsed
116 // successfully by UnmarshalText / FromString.
117 //
118 // variants must be unique across elements of this slice. Please see the
119 // comment in fuzz.go if you change this slice or add new tests to it.
120 var fromStringTestsscip-go gomod github.com/gofrs/uuid/v5 . `github.com/gofrs/uuid/v5`/fromStringTests. = []fromStringTestscip-go gomod github.com/gofrs/uuid/v5 . `github.com/gofrs/uuid/v5`/fromStringTest#{
121 {
122 inputscip-go gomod github.com/gofrs/uuid/v5 . `github.com/gofrs/uuid/v5`/fromStringTest#input.: "6ba7b810-9dad-11d1-80b4-00c04fd430c8",
123 variantscip-go gomod github.com/gofrs/uuid/v5 . `github.com/gofrs/uuid/v5`/fromStringTest#variant.: "Canonical",
124 },
125 {
126 inputscip-go gomod github.com/gofrs/uuid/v5 . `github.com/gofrs/uuid/v5`/fromStringTest#input.: "{6ba7b810-9dad-11d1-80b4-00c04fd430c8}",
127 variantscip-go gomod github.com/gofrs/uuid/v5 . `github.com/gofrs/uuid/v5`/fromStringTest#variant.: "BracedCanonical",
128 },
129 {
130 inputscip-go gomod github.com/gofrs/uuid/v5 . `github.com/gofrs/uuid/v5`/fromStringTest#input.: "{6ba7b8109dad11d180b400c04fd430c8}",
131 variantscip-go gomod github.com/gofrs/uuid/v5 . `github.com/gofrs/uuid/v5`/fromStringTest#variant.: "BracedHashlike",
132 },
133 {
134 inputscip-go gomod github.com/gofrs/uuid/v5 . `github.com/gofrs/uuid/v5`/fromStringTest#input.: "6ba7b8109dad11d180b400c04fd430c8",
135 variantscip-go gomod github.com/gofrs/uuid/v5 . `github.com/gofrs/uuid/v5`/fromStringTest#variant.: "Hashlike",
136 },
137 {
138 inputscip-go gomod github.com/gofrs/uuid/v5 . `github.com/gofrs/uuid/v5`/fromStringTest#input.: "urn:uuid:6ba7b810-9dad-11d1-80b4-00c04fd430c8",
139 variantscip-go gomod github.com/gofrs/uuid/v5 . `github.com/gofrs/uuid/v5`/fromStringTest#variant.: "URNCanonical",
140 },
141 {
142 inputscip-go gomod github.com/gofrs/uuid/v5 . `github.com/gofrs/uuid/v5`/fromStringTest#input.: "urn:uuid:6ba7b8109dad11d180b400c04fd430c8",
143 variantscip-go gomod github.com/gofrs/uuid/v5 . `github.com/gofrs/uuid/v5`/fromStringTest#variant.: "URNHashlike",
144 },
145 }
146
147 var invalidFromStringInputsscip-go gomod github.com/gofrs/uuid/v5 . `github.com/gofrs/uuid/v5`/invalidFromStringInputs. = []string{
148 // short
149 "6ba7b810-9dad-11d1-80b4-00c04fd430c",
150 "6ba7b8109dad11d180b400c04fd430c",
151
152 // invalid hex
153 "6ba7b8109dad11d180b400c04fd430q8",
154
155 // long
156 "6ba7b810-9dad-11d1-80b4-00c04fd430c8=",
157 "6ba7b810-9dad-11d1-80b4-00c04fd430c8}",
158 "{6ba7b810-9dad-11d1-80b4-00c04fd430c8}f",
159 "6ba7b810-9dad-11d1-80b4-00c04fd430c800c04fd430c8",
160
161 // malformed in other ways
162 "ba7b8109dad11d180b400c04fd430c8}",
163 "6ba7b8109dad11d180b400c04fd430c86ba7b8109dad11d180b400c04fd430c8",
164 "urn:uuid:{6ba7b810-9dad-11d1-80b4-00c04fd430c8}",
165 "uuid:urn:6ba7b810-9dad-11d1-80b4-00c04fd430c8",
166 "uuid:urn:6ba7b8109dad11d180b400c04fd430c8",
167 "6ba7b8109-dad-11d1-80b4-00c04fd430c8",
168 "6ba7b810-9dad1-1d1-80b4-00c04fd430c8",
169 "6ba7b810-9dad-11d18-0b4-00c04fd430c8",
170 "6ba7b810-9dad-11d1-80b40-0c04fd430c8",
171 "6ba7b810+9dad+11d1+80b4+00c04fd430c8",
172 "(6ba7b810-9dad-11d1-80b4-00c04fd430c8}",
173 "{6ba7b810-9dad-11d1-80b4-00c04fd430c8>",
174 "zba7b810-9dad-11d1-80b4-00c04fd430c8",
175 "6ba7b810-9dad11d180b400c04fd430c8",
176 "6ba7b8109dad-11d180b400c04fd430c8",
177 "6ba7b8109dad11d1-80b400c04fd430c8",
178 "6ba7b8109dad11d180b4-00c04fd430c8",
179 }
180
181 func TestFromStringscip-go gomod github.com/gofrs/uuid/v5 . `github.com/gofrs/uuid/v5`/TestFromString().(t *testingscip-go gomod github.com/golang/go/src go1.25 testing/.Tscip-go gomod github.com/golang/go/src go1.25 testing/T#) {
182 t.Runscip-go gomod github.com/golang/go/src go1.25 testing/T#Run().("Valid", func(t *testingscip-go gomod github.com/golang/go/src go1.25 testing/.Tscip-go gomod github.com/golang/go/src go1.25 testing/T#) {
183 for _, fst := range fromStringTestsscip-go gomod github.com/gofrs/uuid/v5 . `github.com/gofrs/uuid/v5`/fromStringTests. {
184 fst.TestFromStringscip-go gomod github.com/gofrs/uuid/v5 . `github.com/gofrs/uuid/v5`/fromStringTest#TestFromString().(t)
185 }
186 })
187 t.Runscip-go gomod github.com/golang/go/src go1.25 testing/T#Run().("Invalid", func(t *testingscip-go gomod github.com/golang/go/src go1.25 testing/.Tscip-go gomod github.com/golang/go/src go1.25 testing/T#) {
188 for _, s := range invalidFromStringInputsscip-go gomod github.com/gofrs/uuid/v5 . `github.com/gofrs/uuid/v5`/invalidFromStringInputs. {
189 got, err := FromStringscip-go gomod github.com/gofrs/uuid/v5 . `github.com/gofrs/uuid/v5`/FromString().(s)
190 if err == nil {
191 t.Errorfscip-go gomod github.com/golang/go/src go1.25 testing/common#Errorf().("FromString(%q): want err != nil, got %v", s, got)
192 }
193 }
194 })
195 }
196
197 func TestFromStringOrNilscip-go gomod github.com/gofrs/uuid/v5 . `github.com/gofrs/uuid/v5`/TestFromStringOrNil().(t *testingscip-go gomod github.com/golang/go/src go1.25 testing/.Tscip-go gomod github.com/golang/go/src go1.25 testing/T#) {
198 t.Runscip-go gomod github.com/golang/go/src go1.25 testing/T#Run().("Invalid", func(t *testingscip-go gomod github.com/golang/go/src go1.25 testing/.Tscip-go gomod github.com/golang/go/src go1.25 testing/T#) {
199 s := "bad"
200 got := FromStringOrNilscip-go gomod github.com/gofrs/uuid/v5 . `github.com/gofrs/uuid/v5`/FromStringOrNil().(s)
201 if got != Nilscip-go gomod github.com/gofrs/uuid/v5 . `github.com/gofrs/uuid/v5`/Nil. {
202 t.Errorfscip-go gomod github.com/golang/go/src go1.25 testing/common#Errorf().("FromStringOrNil(%q): got %v, want Nil", s, got)
203 }
204 })
205 t.Runscip-go gomod github.com/golang/go/src go1.25 testing/T#Run().("Valid", func(t *testingscip-go gomod github.com/golang/go/src go1.25 testing/.Tscip-go gomod github.com/golang/go/src go1.25 testing/T#) {
206 s := "6ba7b810-9dad-11d1-80b4-00c04fd430c8"
207 got := FromStringOrNilscip-go gomod github.com/gofrs/uuid/v5 . `github.com/gofrs/uuid/v5`/FromStringOrNil().(s)
208 if got != codecTestUUIDscip-go gomod github.com/gofrs/uuid/v5 . `github.com/gofrs/uuid/v5`/codecTestUUID. {
209 t.Errorfscip-go gomod github.com/golang/go/src go1.25 testing/common#Errorf().("FromStringOrNil(%q): got %v, want %v", s, got, codecTestUUIDscip-go gomod github.com/gofrs/uuid/v5 . `github.com/gofrs/uuid/v5`/codecTestUUID.)
210 }
211 })
212 }
213
214 func TestUnmarshalTextscip-go gomod github.com/gofrs/uuid/v5 . `github.com/gofrs/uuid/v5`/TestUnmarshalText().(t *testingscip-go gomod github.com/golang/go/src go1.25 testing/.Tscip-go gomod github.com/golang/go/src go1.25 testing/T#) {
215 t.Runscip-go gomod github.com/golang/go/src go1.25 testing/T#Run().("Valid", func(t *testingscip-go gomod github.com/golang/go/src go1.25 testing/.Tscip-go gomod github.com/golang/go/src go1.25 testing/T#) {
216 for _, fst := range fromStringTestsscip-go gomod github.com/gofrs/uuid/v5 . `github.com/gofrs/uuid/v5`/fromStringTests. {
217 fst.TestUnmarshalTextscip-go gomod github.com/gofrs/uuid/v5 . `github.com/gofrs/uuid/v5`/fromStringTest#TestUnmarshalText().(t)
218 }
219 })
220 t.Runscip-go gomod github.com/golang/go/src go1.25 testing/T#Run().("Invalid", func(t *testingscip-go gomod github.com/golang/go/src go1.25 testing/.Tscip-go gomod github.com/golang/go/src go1.25 testing/T#) {
221 for _, s := range invalidFromStringInputsscip-go gomod github.com/gofrs/uuid/v5 . `github.com/gofrs/uuid/v5`/invalidFromStringInputs. {
222 var u UUIDscip-go gomod github.com/gofrs/uuid/v5 . `github.com/gofrs/uuid/v5`/UUID#
223 err := u.UnmarshalTextscip-go gomod github.com/gofrs/uuid/v5 . `github.com/gofrs/uuid/v5`/UUID#UnmarshalText().([]byte(s))
224 if err == nil {
225 t.Errorfscip-go gomod github.com/golang/go/src go1.25 testing/common#Errorf().("FromBytes(%q): want err != nil, got %v", s, u)
226 }
227 }
228 })
229 }
230
231 // Test that UnmarshalText() and Parse() return identical errors
232 func TestUnmarshalTextParseErrorsscip-go gomod github.com/gofrs/uuid/v5 . `github.com/gofrs/uuid/v5`/TestUnmarshalTextParseErrors().(t *testingscip-go gomod github.com/golang/go/src go1.25 testing/.Tscip-go gomod github.com/golang/go/src go1.25 testing/T#) {
233 for _, s := range invalidFromStringInputsscip-go gomod github.com/gofrs/uuid/v5 . `github.com/gofrs/uuid/v5`/invalidFromStringInputs. {
234 var u UUIDscip-go gomod github.com/gofrs/uuid/v5 . `github.com/gofrs/uuid/v5`/UUID#
235 e1 := u.UnmarshalTextscip-go gomod github.com/gofrs/uuid/v5 . `github.com/gofrs/uuid/v5`/UUID#UnmarshalText().([]byte(s))
236 e2 := u.Parsescip-go gomod github.com/gofrs/uuid/v5 . `github.com/gofrs/uuid/v5`/UUID#Parse().(s)
237 if e1 == nil || e1.Error() != e2.Error() {
238 t.Errorfscip-go gomod github.com/golang/go/src go1.25 testing/common#Errorf().("%q: errors don't match: UnmarshalText: %v Parse: %v", s, e1, e2)
239 }
240 }
241 }
242
243 func TestMarshalBinaryscip-go gomod github.com/gofrs/uuid/v5 . `github.com/gofrs/uuid/v5`/TestMarshalBinary().(t *testingscip-go gomod github.com/golang/go/src go1.25 testing/.Tscip-go gomod github.com/golang/go/src go1.25 testing/T#) {
244 got, err := codecTestUUIDscip-go gomod github.com/gofrs/uuid/v5 . `github.com/gofrs/uuid/v5`/codecTestUUID..MarshalBinaryscip-go gomod github.com/gofrs/uuid/v5 . `github.com/gofrs/uuid/v5`/UUID#MarshalBinary().()
245 if err != nil {
246 t.Fatalscip-go gomod github.com/golang/go/src go1.25 testing/common#Fatal().(err)
247 }
248 if !bytesscip-go gomod github.com/golang/go/src go1.25 bytes/.Equalscip-go gomod github.com/golang/go/src go1.25 bytes/Equal().(got, codecTestDatascip-go gomod github.com/gofrs/uuid/v5 . `github.com/gofrs/uuid/v5`/codecTestData.) {
249 t.Fatalfscip-go gomod github.com/golang/go/src go1.25 testing/common#Fatalf().("%v.MarshalBinary() = %x, want %x", codecTestUUIDscip-go gomod github.com/gofrs/uuid/v5 . `github.com/gofrs/uuid/v5`/codecTestUUID., got, codecTestDatascip-go gomod github.com/gofrs/uuid/v5 . `github.com/gofrs/uuid/v5`/codecTestData.)
250 }
251 }
252
253 func TestMarshalTextscip-go gomod github.com/gofrs/uuid/v5 . `github.com/gofrs/uuid/v5`/TestMarshalText().(t *testingscip-go gomod github.com/golang/go/src go1.25 testing/.Tscip-go gomod github.com/golang/go/src go1.25 testing/T#) {
254 want := []byte("6ba7b810-9dad-11d1-80b4-00c04fd430c8")
255 got, err := codecTestUUIDscip-go gomod github.com/gofrs/uuid/v5 . `github.com/gofrs/uuid/v5`/codecTestUUID..MarshalTextscip-go gomod github.com/gofrs/uuid/v5 . `github.com/gofrs/uuid/v5`/UUID#MarshalText().()
256 if err != nil {
257 t.Fatalscip-go gomod github.com/golang/go/src go1.25 testing/common#Fatal().(err)
258 }
259 if !bytesscip-go gomod github.com/golang/go/src go1.25 bytes/.Equalscip-go gomod github.com/golang/go/src go1.25 bytes/Equal().(got, want) {
260 t.Errorfscip-go gomod github.com/golang/go/src go1.25 testing/common#Errorf().("%v.MarshalText(): got %s, want %s", codecTestUUIDscip-go gomod github.com/gofrs/uuid/v5 . `github.com/gofrs/uuid/v5`/codecTestUUID., got, want)
261 }
262 }
263
264 func TestDecodePlainWithWrongLengthscip-go gomod github.com/gofrs/uuid/v5 . `github.com/gofrs/uuid/v5`/TestDecodePlainWithWrongLength().(t *testingscip-go gomod github.com/golang/go/src go1.25 testing/.Tscip-go gomod github.com/golang/go/src go1.25 testing/T#) {
265 arg := []byte{'4', '2'}
266
267 u := UUIDscip-go gomod github.com/gofrs/uuid/v5 . `github.com/gofrs/uuid/v5`/UUID#{}
268
269 if u.UnmarshalTextscip-go gomod github.com/gofrs/uuid/v5 . `github.com/gofrs/uuid/v5`/UUID#UnmarshalText().(arg) == nil {
270 t.Errorfscip-go gomod github.com/golang/go/src go1.25 testing/common#Errorf().("%v.UnmarshalText(%q): should return error, but it did not", u, arg)
271 }
272 }
273
274 func TestFromHexCharscip-go gomod github.com/gofrs/uuid/v5 . `github.com/gofrs/uuid/v5`/TestFromHexChar().(t *testingscip-go gomod github.com/golang/go/src go1.25 testing/.Tscip-go gomod github.com/golang/go/src go1.25 testing/T#) {
275 const hextable = "0123456789abcdef"
276
277 t.Runscip-go gomod github.com/golang/go/src go1.25 testing/T#Run().("Valid", func(t *testingscip-go gomod github.com/golang/go/src go1.25 testing/.Tscip-go gomod github.com/golang/go/src go1.25 testing/T#) {
278 t.Runscip-go gomod github.com/golang/go/src go1.25 testing/T#Run().("Lower", func(t *testingscip-go gomod github.com/golang/go/src go1.25 testing/.Tscip-go gomod github.com/golang/go/src go1.25 testing/T#) {
279 for i, c := range []byte(hextable) {
280 x := fromHexCharscip-go gomod github.com/gofrs/uuid/v5 . `github.com/gofrs/uuid/v5`/fromHexChar().(c)
281 if int(x) != i {
282 t.Errorfscip-go gomod github.com/golang/go/src go1.25 testing/common#Errorf().("fromHexChar(%c): got %d want %d", c, x, i)
283 }
284 }
285 })
286 t.Runscip-go gomod github.com/golang/go/src go1.25 testing/T#Run().("Upper", func(t *testingscip-go gomod github.com/golang/go/src go1.25 testing/.Tscip-go gomod github.com/golang/go/src go1.25 testing/T#) {
287 for i, c := range []byte(stringsscip-go gomod github.com/golang/go/src go1.25 strings/.ToUpperscip-go gomod github.com/golang/go/src go1.25 strings/ToUpper().(hextable)) {
288 x := fromHexCharscip-go gomod github.com/gofrs/uuid/v5 . `github.com/gofrs/uuid/v5`/fromHexChar().(c)
289 if int(x) != i {
290 t.Errorfscip-go gomod github.com/golang/go/src go1.25 testing/common#Errorf().("fromHexChar(%c): got %d want %d", c, x, i)
291 }
292 }
293 })
294 })
295
296 t.Runscip-go gomod github.com/golang/go/src go1.25 testing/T#Run().("Invalid", func(t *testingscip-go gomod github.com/golang/go/src go1.25 testing/.Tscip-go gomod github.com/golang/go/src go1.25 testing/T#) {
297 skip := make(map[byte]bool)
298 for _, c := range []byte(hextable + stringsscip-go gomod github.com/golang/go/src go1.25 strings/.ToUpperscip-go gomod github.com/golang/go/src go1.25 strings/ToUpper().(hextable)) {
299 skip[c] = true
300 }
301 for i := range 256 {
302 c := byte(i)
303 if !skip[c] {
304 v := fromHexCharscip-go gomod github.com/gofrs/uuid/v5 . `github.com/gofrs/uuid/v5`/fromHexChar().(c)
305 if v != 255 {
306 t.Errorfscip-go gomod github.com/golang/go/src go1.25 testing/common#Errorf().("fromHexChar(%c): got %d want: %d", c, v, 255)
307 }
308 }
309 }
310 })
311 }
312
313 var stringBenchmarkSinkscip-go gomod github.com/gofrs/uuid/v5 . `github.com/gofrs/uuid/v5`/stringBenchmarkSink. string
314
315 func BenchmarkStringscip-go gomod github.com/gofrs/uuid/v5 . `github.com/gofrs/uuid/v5`/BenchmarkString().(b *testingscip-go gomod github.com/golang/go/src go1.25 testing/.Bscip-go gomod github.com/golang/go/src go1.25 testing/B#) {
316 for range b.Nscip-go gomod github.com/golang/go/src go1.25 testing/B#N. {
317 stringBenchmarkSinkscip-go gomod github.com/gofrs/uuid/v5 . `github.com/gofrs/uuid/v5`/stringBenchmarkSink. = codecTestUUIDscip-go gomod github.com/gofrs/uuid/v5 . `github.com/gofrs/uuid/v5`/codecTestUUID..Stringscip-go gomod github.com/gofrs/uuid/v5 . `github.com/gofrs/uuid/v5`/UUID#String().()
318 }
319 }
320
321 func BenchmarkFromBytesscip-go gomod github.com/gofrs/uuid/v5 . `github.com/gofrs/uuid/v5`/BenchmarkFromBytes().(b *testingscip-go gomod github.com/golang/go/src go1.25 testing/.Bscip-go gomod github.com/golang/go/src go1.25 testing/B#) {
322 for range b.Nscip-go gomod github.com/golang/go/src go1.25 testing/B#N. {
323 _, _ = FromBytesscip-go gomod github.com/gofrs/uuid/v5 . `github.com/gofrs/uuid/v5`/FromBytes().(codecTestDatascip-go gomod github.com/gofrs/uuid/v5 . `github.com/gofrs/uuid/v5`/codecTestData.)
324 }
325 }
326
327 func BenchmarkFromStringscip-go gomod github.com/gofrs/uuid/v5 . `github.com/gofrs/uuid/v5`/BenchmarkFromString().(b *testingscip-go gomod github.com/golang/go/src go1.25 testing/.Bscip-go gomod github.com/golang/go/src go1.25 testing/B#) {
328 b.Runscip-go gomod github.com/golang/go/src go1.25 testing/B#Run().("canonical", func(b *testingscip-go gomod github.com/golang/go/src go1.25 testing/.Bscip-go gomod github.com/golang/go/src go1.25 testing/B#) {
329 for range b.Nscip-go gomod github.com/golang/go/src go1.25 testing/B#N. {
330 _, _ = FromStringscip-go gomod github.com/gofrs/uuid/v5 . `github.com/gofrs/uuid/v5`/FromString().("6ba7b810-9dad-11d1-80b4-00c04fd430c8")
331 }
332 })
333 b.Runscip-go gomod github.com/golang/go/src go1.25 testing/B#Run().("urn", func(b *testingscip-go gomod github.com/golang/go/src go1.25 testing/.Bscip-go gomod github.com/golang/go/src go1.25 testing/B#) {
334 for range b.Nscip-go gomod github.com/golang/go/src go1.25 testing/B#N. {
335 _, _ = FromStringscip-go gomod github.com/gofrs/uuid/v5 . `github.com/gofrs/uuid/v5`/FromString().("urn:uuid:6ba7b810-9dad-11d1-80b4-00c04fd430c8")
336 }
337 })
338 b.Runscip-go gomod github.com/golang/go/src go1.25 testing/B#Run().("braced", func(b *testingscip-go gomod github.com/golang/go/src go1.25 testing/.Bscip-go gomod github.com/golang/go/src go1.25 testing/B#) {
339 for range b.Nscip-go gomod github.com/golang/go/src go1.25 testing/B#N. {
340 _, _ = FromStringscip-go gomod github.com/gofrs/uuid/v5 . `github.com/gofrs/uuid/v5`/FromString().("{6ba7b810-9dad-11d1-80b4-00c04fd430c8}")
341 }
342 })
343 }
344
345 var FromBytesOrNilResultscip-go gomod github.com/gofrs/uuid/v5 . `github.com/gofrs/uuid/v5`/FromBytesOrNilResult. UUIDscip-go gomod github.com/gofrs/uuid/v5 . `github.com/gofrs/uuid/v5`/UUID#
346
347 func BenchmarkFromBytesOrNilscip-go gomod github.com/gofrs/uuid/v5 . `github.com/gofrs/uuid/v5`/BenchmarkFromBytesOrNil().(b *testingscip-go gomod github.com/golang/go/src go1.25 testing/.Bscip-go gomod github.com/golang/go/src go1.25 testing/B#) {
348 b.Runscip-go gomod github.com/golang/go/src go1.25 testing/B#Run().("valid", func(b *testingscip-go gomod github.com/golang/go/src go1.25 testing/.Bscip-go gomod github.com/golang/go/src go1.25 testing/B#) {
349 for range b.Nscip-go gomod github.com/golang/go/src go1.25 testing/B#N. {
350 FromBytesOrNilResultscip-go gomod github.com/gofrs/uuid/v5 . `github.com/gofrs/uuid/v5`/FromBytesOrNilResult. = FromBytesOrNilscip-go gomod github.com/gofrs/uuid/v5 . `github.com/gofrs/uuid/v5`/FromBytesOrNil().(codecTestDatascip-go gomod github.com/gofrs/uuid/v5 . `github.com/gofrs/uuid/v5`/codecTestData.)
351 }
352 })
353
354 b.Runscip-go gomod github.com/golang/go/src go1.25 testing/B#Run().("empty", func(b *testingscip-go gomod github.com/golang/go/src go1.25 testing/.Bscip-go gomod github.com/golang/go/src go1.25 testing/B#) {
355 for range b.Nscip-go gomod github.com/golang/go/src go1.25 testing/B#N. {
356 FromBytesOrNilResultscip-go gomod github.com/gofrs/uuid/v5 . `github.com/gofrs/uuid/v5`/FromBytesOrNilResult. = FromBytesOrNilscip-go gomod github.com/gofrs/uuid/v5 . `github.com/gofrs/uuid/v5`/FromBytesOrNil().([]byte{})
357 }
358 })
359 }
360
361 func BenchmarkUnmarshalTextscip-go gomod github.com/gofrs/uuid/v5 . `github.com/gofrs/uuid/v5`/BenchmarkUnmarshalText().(b *testingscip-go gomod github.com/golang/go/src go1.25 testing/.Bscip-go gomod github.com/golang/go/src go1.25 testing/B#) {
362 b.Runscip-go gomod github.com/golang/go/src go1.25 testing/B#Run().("canonical", func(b *testingscip-go gomod github.com/golang/go/src go1.25 testing/.Bscip-go gomod github.com/golang/go/src go1.25 testing/B#) {
363 text := []byte(Mustscip-go gomod github.com/gofrs/uuid/v5 . `github.com/gofrs/uuid/v5`/Must().(FromStringscip-go gomod github.com/gofrs/uuid/v5 . `github.com/gofrs/uuid/v5`/FromString().("6ba7b810-9dad-11d1-80b4-00c04fd430c8")).Stringscip-go gomod github.com/gofrs/uuid/v5 . `github.com/gofrs/uuid/v5`/UUID#String().())
364 u := new(UUIDscip-go gomod github.com/gofrs/uuid/v5 . `github.com/gofrs/uuid/v5`/UUID#)
365 if err := u.UnmarshalTextscip-go gomod github.com/gofrs/uuid/v5 . `github.com/gofrs/uuid/v5`/UUID#UnmarshalText().(text); err != nil {
366 b.Fatalscip-go gomod github.com/golang/go/src go1.25 testing/common#Fatal().(err)
367 }
368 b.ResetTimerscip-go gomod github.com/golang/go/src go1.25 testing/B#ResetTimer().()
369 for range b.Nscip-go gomod github.com/golang/go/src go1.25 testing/B#N. {
370 _ = u.UnmarshalTextscip-go gomod github.com/gofrs/uuid/v5 . `github.com/gofrs/uuid/v5`/UUID#UnmarshalText().(text)
371 }
372 })
373 b.Runscip-go gomod github.com/golang/go/src go1.25 testing/B#Run().("urn", func(b *testingscip-go gomod github.com/golang/go/src go1.25 testing/.Bscip-go gomod github.com/golang/go/src go1.25 testing/B#) {
374 text := []byte(Mustscip-go gomod github.com/gofrs/uuid/v5 . `github.com/gofrs/uuid/v5`/Must().(FromStringscip-go gomod github.com/gofrs/uuid/v5 . `github.com/gofrs/uuid/v5`/FromString().("urn:uuid:6ba7b810-9dad-11d1-80b4-00c04fd430c8")).Stringscip-go gomod github.com/gofrs/uuid/v5 . `github.com/gofrs/uuid/v5`/UUID#String().())
375 u := new(UUIDscip-go gomod github.com/gofrs/uuid/v5 . `github.com/gofrs/uuid/v5`/UUID#)
376 if err := u.UnmarshalTextscip-go gomod github.com/gofrs/uuid/v5 . `github.com/gofrs/uuid/v5`/UUID#UnmarshalText().(text); err != nil {
377 b.Fatalscip-go gomod github.com/golang/go/src go1.25 testing/common#Fatal().(err)
378 }
379 b.ResetTimerscip-go gomod github.com/golang/go/src go1.25 testing/B#ResetTimer().()
380 for range b.Nscip-go gomod github.com/golang/go/src go1.25 testing/B#N. {
381 _ = u.UnmarshalTextscip-go gomod github.com/gofrs/uuid/v5 . `github.com/gofrs/uuid/v5`/UUID#UnmarshalText().(text)
382 }
383 })
384 b.Runscip-go gomod github.com/golang/go/src go1.25 testing/B#Run().("braced", func(b *testingscip-go gomod github.com/golang/go/src go1.25 testing/.Bscip-go gomod github.com/golang/go/src go1.25 testing/B#) {
385 text := []byte(Mustscip-go gomod github.com/gofrs/uuid/v5 . `github.com/gofrs/uuid/v5`/Must().(FromStringscip-go gomod github.com/gofrs/uuid/v5 . `github.com/gofrs/uuid/v5`/FromString().("{6ba7b810-9dad-11d1-80b4-00c04fd430c8}")).Stringscip-go gomod github.com/gofrs/uuid/v5 . `github.com/gofrs/uuid/v5`/UUID#String().())
386 u := new(UUIDscip-go gomod github.com/gofrs/uuid/v5 . `github.com/gofrs/uuid/v5`/UUID#)
387 if err := u.UnmarshalTextscip-go gomod github.com/gofrs/uuid/v5 . `github.com/gofrs/uuid/v5`/UUID#UnmarshalText().(text); err != nil {
388 b.Fatalscip-go gomod github.com/golang/go/src go1.25 testing/common#Fatal().(err)
389 }
390 b.ResetTimerscip-go gomod github.com/golang/go/src go1.25 testing/B#ResetTimer().()
391 for range b.Nscip-go gomod github.com/golang/go/src go1.25 testing/B#N. {
392 _ = u.UnmarshalTextscip-go gomod github.com/gofrs/uuid/v5 . `github.com/gofrs/uuid/v5`/UUID#UnmarshalText().(text)
393 }
394 })
395 }
396
397 func BenchmarkMarshalBinaryscip-go gomod github.com/gofrs/uuid/v5 . `github.com/gofrs/uuid/v5`/BenchmarkMarshalBinary().(b *testingscip-go gomod github.com/golang/go/src go1.25 testing/.Bscip-go gomod github.com/golang/go/src go1.25 testing/B#) {
398 for range b.Nscip-go gomod github.com/golang/go/src go1.25 testing/B#N. {
399 _, _ = codecTestUUIDscip-go gomod github.com/gofrs/uuid/v5 . `github.com/gofrs/uuid/v5`/codecTestUUID..MarshalBinaryscip-go gomod github.com/gofrs/uuid/v5 . `github.com/gofrs/uuid/v5`/UUID#MarshalBinary().()
400 }
401 }
402
403 func BenchmarkMarshalTextscip-go gomod github.com/gofrs/uuid/v5 . `github.com/gofrs/uuid/v5`/BenchmarkMarshalText().(b *testingscip-go gomod github.com/golang/go/src go1.25 testing/.Bscip-go gomod github.com/golang/go/src go1.25 testing/B#) {
404 for range b.Nscip-go gomod github.com/golang/go/src go1.25 testing/B#N. {
405 _, _ = codecTestUUIDscip-go gomod github.com/gofrs/uuid/v5 . `github.com/gofrs/uuid/v5`/codecTestUUID..MarshalTextscip-go gomod github.com/gofrs/uuid/v5 . `github.com/gofrs/uuid/v5`/UUID#MarshalText().()
406 }
407 }
408
409 func BenchmarkParseV4scip-go gomod github.com/gofrs/uuid/v5 . `github.com/gofrs/uuid/v5`/BenchmarkParseV4().(b *testingscip-go gomod github.com/golang/go/src go1.25 testing/.Bscip-go gomod github.com/golang/go/src go1.25 testing/B#) {
410 const text = "f52a747a-983f-45f7-90b5-e84d70f470dd"
411 for range b.Nscip-go gomod github.com/golang/go/src go1.25 testing/B#N. {
412 var u UUIDscip-go gomod github.com/gofrs/uuid/v5 . `github.com/gofrs/uuid/v5`/UUID#
413 if err := u.Parsescip-go gomod github.com/gofrs/uuid/v5 . `github.com/gofrs/uuid/v5`/UUID#Parse().(text); err != nil {
414 b.Fatalscip-go gomod github.com/golang/go/src go1.25 testing/common#Fatal().(err)
415 }
416 }
417 }
418
419 const uuidPatternscip-go gomod github.com/gofrs/uuid/v5 . `github.com/gofrs/uuid/v5`/uuidPattern. = "[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}"
420
421 var fromBytesCorpusscip-go gomod github.com/gofrs/uuid/v5 . `github.com/gofrs/uuid/v5`/fromBytesCorpus. = [][]byte{
422 {0x6b, 0xa7, 0xb8, 0x10, 0x9d, 0xad, 0x11, 0xd1, 0x80, 0xb4, 0x00, 0xc0, 0x4f, 0xd4, 0x30, 0xc8},
423 {4, 8, 15, 16, 23, 42},
424 }
425
426 // FuzzFromBytesFunc is a fuzz testing suite that exercises the FromBytes function
427 func FuzzFromBytesFuncscip-go gomod github.com/gofrs/uuid/v5 . `github.com/gofrs/uuid/v5`/FuzzFromBytesFunc().(f *testingscip-go gomod github.com/golang/go/src go1.25 testing/.Fscip-go gomod github.com/golang/go/src go1.25 testing/F#) {
428 for _, seed := range fromBytesCorpusscip-go gomod github.com/gofrs/uuid/v5 . `github.com/gofrs/uuid/v5`/fromBytesCorpus. {
429 f.Addscip-go gomod github.com/golang/go/src go1.25 testing/F#Add().(seed)
430 }
431 uuidRegexp, err := regexpscip-go gomod github.com/golang/go/src go1.25 regexp/.Compilescip-go gomod github.com/golang/go/src go1.25 regexp/Compile().(uuidPatternscip-go gomod github.com/gofrs/uuid/v5 . `github.com/gofrs/uuid/v5`/uuidPattern.)
432 if err != nil {
433 f.Fatalscip-go gomod github.com/golang/go/src go1.25 testing/common#Fatal().("uuid regexp failed to compile")
434 }
435 f.Fuzzscip-go gomod github.com/golang/go/src go1.25 testing/F#Fuzz().(func(t *testingscip-go gomod github.com/golang/go/src go1.25 testing/.Tscip-go gomod github.com/golang/go/src go1.25 testing/T#, payload []byte) {
436 u, err := FromBytesscip-go gomod github.com/gofrs/uuid/v5 . `github.com/gofrs/uuid/v5`/FromBytes().(payload)
437 if len(payload) != Sizescip-go gomod github.com/gofrs/uuid/v5 . `github.com/gofrs/uuid/v5`/Size. && err == nil {
438 t.Errorfscip-go gomod github.com/golang/go/src go1.25 testing/common#Errorf().("%v did not result in an error", payload)
439 }
440 if len(payload) == Sizescip-go gomod github.com/gofrs/uuid/v5 . `github.com/gofrs/uuid/v5`/Size. && u == Nilscip-go gomod github.com/gofrs/uuid/v5 . `github.com/gofrs/uuid/v5`/Nil. {
441 t.Errorfscip-go gomod github.com/golang/go/src go1.25 testing/common#Errorf().("%v resulted in Nil uuid", payload)
442 }
443 if len(payload) == Sizescip-go gomod github.com/gofrs/uuid/v5 . `github.com/gofrs/uuid/v5`/Size. && !uuidRegexp.MatchStringscip-go gomod github.com/golang/go/src go1.25 regexp/Regexp#MatchString().(u.Stringscip-go gomod github.com/gofrs/uuid/v5 . `github.com/gofrs/uuid/v5`/UUID#String().()) {
444 t.Errorfscip-go gomod github.com/golang/go/src go1.25 testing/common#Errorf().("%v resulted in invalid uuid %s", payload, u.Stringscip-go gomod github.com/gofrs/uuid/v5 . `github.com/gofrs/uuid/v5`/UUID#String().())
445 }
446 // otherwise, allow to pass if no panic
447 })
448 }
449
450 // FuzzFromBytesOrNilFunc is a fuzz testing suite that exercises the FromBytesOrNil function
451 func FuzzFromBytesOrNilFuncscip-go gomod github.com/gofrs/uuid/v5 . `github.com/gofrs/uuid/v5`/FuzzFromBytesOrNilFunc().(f *testingscip-go gomod github.com/golang/go/src go1.25 testing/.Fscip-go gomod github.com/golang/go/src go1.25 testing/F#) {
452 for _, seed := range fromBytesCorpusscip-go gomod github.com/gofrs/uuid/v5 . `github.com/gofrs/uuid/v5`/fromBytesCorpus. {
453 f.Addscip-go gomod github.com/golang/go/src go1.25 testing/F#Add().(seed)
454 }
455 uuidRegexp, err := regexpscip-go gomod github.com/golang/go/src go1.25 regexp/.Compilescip-go gomod github.com/golang/go/src go1.25 regexp/Compile().(uuidPatternscip-go gomod github.com/gofrs/uuid/v5 . `github.com/gofrs/uuid/v5`/uuidPattern.)
456 if err != nil {
457 f.Errorscip-go gomod github.com/golang/go/src go1.25 testing/common#Error().("uuid regexp failed to compile")
458 }
459 f.Fuzzscip-go gomod github.com/golang/go/src go1.25 testing/F#Fuzz().(func(t *testingscip-go gomod github.com/golang/go/src go1.25 testing/.Tscip-go gomod github.com/golang/go/src go1.25 testing/T#, payload []byte) {
460 u := FromBytesOrNilscip-go gomod github.com/gofrs/uuid/v5 . `github.com/gofrs/uuid/v5`/FromBytesOrNil().(payload)
461 if len(payload) != Sizescip-go gomod github.com/gofrs/uuid/v5 . `github.com/gofrs/uuid/v5`/Size. && u != Nilscip-go gomod github.com/gofrs/uuid/v5 . `github.com/gofrs/uuid/v5`/Nil. {
462 t.Errorfscip-go gomod github.com/golang/go/src go1.25 testing/common#Errorf().("%v resulted in non Nil uuid %s", payload, u.Stringscip-go gomod github.com/gofrs/uuid/v5 . `github.com/gofrs/uuid/v5`/UUID#String().())
463 }
464 if len(payload) == Sizescip-go gomod github.com/gofrs/uuid/v5 . `github.com/gofrs/uuid/v5`/Size. && u == Nilscip-go gomod github.com/gofrs/uuid/v5 . `github.com/gofrs/uuid/v5`/Nil. {
465 t.Errorfscip-go gomod github.com/golang/go/src go1.25 testing/common#Errorf().("%v resulted Nil uuid", payload)
466 }
467 if len(payload) == Sizescip-go gomod github.com/gofrs/uuid/v5 . `github.com/gofrs/uuid/v5`/Size. && !uuidRegexp.MatchStringscip-go gomod github.com/golang/go/src go1.25 regexp/Regexp#MatchString().(u.Stringscip-go gomod github.com/gofrs/uuid/v5 . `github.com/gofrs/uuid/v5`/UUID#String().()) {
468 t.Errorfscip-go gomod github.com/golang/go/src go1.25 testing/common#Errorf().("%v resulted in invalid uuid %s", payload, u.Stringscip-go gomod github.com/gofrs/uuid/v5 . `github.com/gofrs/uuid/v5`/UUID#String().())
469 }
470 // otherwise, allow to pass if no panic
471 })
472 }
473
474 var fromStringCorpusscip-go gomod github.com/gofrs/uuid/v5 . `github.com/gofrs/uuid/v5`/fromStringCorpus. = []string{
475 "6ba7b810-9dad-11d1-80b4-00c04fd430c8",
476 "6BA7B810-9DAD-11D1-80B4-00C04FD430C8",
477 "{6BA7B810-9DAD-11D1-80B4-00C04FD430C8}",
478 "urn:uuid:6BA7B810-9DAD-11D1-80B4-00C04FD430C8",
479 "6BA7B8109DAD11D180B400C04FD430C8",
480 "{6BA7B8109DAD11D180B400C04FD430C8}",
481 "urn:uuid:6BA7B8109DAD11D180B400C04FD430C8",
482 }
483
484 // FuzzFromStringFunc is a fuzz testing suite that exercises the FromString function
485 func FuzzFromStringFuncscip-go gomod github.com/gofrs/uuid/v5 . `github.com/gofrs/uuid/v5`/FuzzFromStringFunc().(f *testingscip-go gomod github.com/golang/go/src go1.25 testing/.Fscip-go gomod github.com/golang/go/src go1.25 testing/F#) {
486 for _, seed := range fromStringCorpusscip-go gomod github.com/gofrs/uuid/v5 . `github.com/gofrs/uuid/v5`/fromStringCorpus. {
487 f.Addscip-go gomod github.com/golang/go/src go1.25 testing/F#Add().(seed)
488 }
489 uuidRegexp, err := regexpscip-go gomod github.com/golang/go/src go1.25 regexp/.Compilescip-go gomod github.com/golang/go/src go1.25 regexp/Compile().(uuidPatternscip-go gomod github.com/gofrs/uuid/v5 . `github.com/gofrs/uuid/v5`/uuidPattern.)
490 if err != nil {
491 f.Fatalscip-go gomod github.com/golang/go/src go1.25 testing/common#Fatal().("uuid regexp failed to compile")
492 }
493 f.Fuzzscip-go gomod github.com/golang/go/src go1.25 testing/F#Fuzz().(func(t *testingscip-go gomod github.com/golang/go/src go1.25 testing/.Tscip-go gomod github.com/golang/go/src go1.25 testing/T#, payload string) {
494 u, err := FromStringscip-go gomod github.com/gofrs/uuid/v5 . `github.com/gofrs/uuid/v5`/FromString().(payload)
495 if err != nil {
496 if u == Nilscip-go gomod github.com/gofrs/uuid/v5 . `github.com/gofrs/uuid/v5`/Nil. {
497 t.Errorfscip-go gomod github.com/golang/go/src go1.25 testing/common#Errorf().("%s resulted in Nil uuid", payload)
498 }
499 if !uuidRegexp.MatchStringscip-go gomod github.com/golang/go/src go1.25 regexp/Regexp#MatchString().(u.Stringscip-go gomod github.com/gofrs/uuid/v5 . `github.com/gofrs/uuid/v5`/UUID#String().()) {
500 t.Errorfscip-go gomod github.com/golang/go/src go1.25 testing/common#Errorf().("%s resulted in invalid uuid %s", payload, u.Stringscip-go gomod github.com/gofrs/uuid/v5 . `github.com/gofrs/uuid/v5`/UUID#String().())
501 }
502 }
503 // otherwise, allow to pass if no panic
504 })
505 }
506
507 // FuzzFromStringOrNil is a fuzz testing suite that exercises the FromStringOrNil function
508 func FuzzFromStringOrNilFuncscip-go gomod github.com/gofrs/uuid/v5 . `github.com/gofrs/uuid/v5`/FuzzFromStringOrNilFunc().(f *testingscip-go gomod github.com/golang/go/src go1.25 testing/.Fscip-go gomod github.com/golang/go/src go1.25 testing/F#) {
509 for _, seed := range fromStringCorpusscip-go gomod github.com/gofrs/uuid/v5 . `github.com/gofrs/uuid/v5`/fromStringCorpus. {
510 f.Addscip-go gomod github.com/golang/go/src go1.25 testing/F#Add().(seed)
511 }
512 uuidRegexp, err := regexpscip-go gomod github.com/golang/go/src go1.25 regexp/.Compilescip-go gomod github.com/golang/go/src go1.25 regexp/Compile().(uuidPatternscip-go gomod github.com/gofrs/uuid/v5 . `github.com/gofrs/uuid/v5`/uuidPattern.)
513 if err != nil {
514 f.Errorscip-go gomod github.com/golang/go/src go1.25 testing/common#Error().("uuid regexp failed to compile")
515 }
516 f.Fuzzscip-go gomod github.com/golang/go/src go1.25 testing/F#Fuzz().(func(t *testingscip-go gomod github.com/golang/go/src go1.25 testing/.Tscip-go gomod github.com/golang/go/src go1.25 testing/T#, payload string) {
517 u := FromStringOrNilscip-go gomod github.com/gofrs/uuid/v5 . `github.com/gofrs/uuid/v5`/FromStringOrNil().(payload)
518 if u != Nilscip-go gomod github.com/gofrs/uuid/v5 . `github.com/gofrs/uuid/v5`/Nil. {
519 if !uuidRegexp.MatchStringscip-go gomod github.com/golang/go/src go1.25 regexp/Regexp#MatchString().(u.Stringscip-go gomod github.com/gofrs/uuid/v5 . `github.com/gofrs/uuid/v5`/UUID#String().()) {
520 t.Errorfscip-go gomod github.com/golang/go/src go1.25 testing/common#Errorf().("%s resulted in invalid uuid %s", payload, u.Stringscip-go gomod github.com/gofrs/uuid/v5 . `github.com/gofrs/uuid/v5`/UUID#String().())
521 }
522 }
523 // otherwise, allow to pass if no panic
524 })
525 }