77)
88
99func TestLinkString (t * testing.T ) {
10+ t .Parallel ()
11+
1012 l := Parse (`<https://example.com/?page=2>; rel="next"; title="foo"` )["next" ]
1113
1214 if got , want := l .String (), "https://example.com/?page=2" ; got != want {
@@ -15,6 +17,8 @@ func TestLinkString(t *testing.T) {
1517}
1618
1719func TestParseRequest (t * testing.T ) {
20+ t .Parallel ()
21+
1822 req , _ := http .NewRequest ("GET" , "" , nil )
1923 req .Header .Set ("Link" , `<https://example.com/?page=2>; rel="next"` )
2024
@@ -42,6 +46,8 @@ func TestParseRequest(t *testing.T) {
4246}
4347
4448func TestParseResponse (t * testing.T ) {
49+ t .Parallel ()
50+
4551 resp := & http.Response {Header : http.Header {}}
4652 resp .Header .Set ("Link" , `<https://example.com/?page=2>; rel="next"` )
4753
@@ -69,6 +75,8 @@ func TestParseResponse(t *testing.T) {
6975}
7076
7177func TestParseHeader_single (t * testing.T ) {
78+ t .Parallel ()
79+
7280 h := http.Header {}
7381 h .Set ("Link" , `<https://example.com/?page=2>; rel="next"` )
7482
@@ -92,6 +100,8 @@ func TestParseHeader_single(t *testing.T) {
92100}
93101
94102func TestParseHeader_multiple (t * testing.T ) {
103+ t .Parallel ()
104+
95105 h := http.Header {}
96106 h .Add ("Link" , `<https://example.com/?page=2>; rel="next",<https://example.com/?page=34>; rel="last"` )
97107
@@ -127,6 +137,8 @@ func TestParseHeader_multiple(t *testing.T) {
127137}
128138
129139func TestParseHeader_multiple_headers (t * testing.T ) {
140+ t .Parallel ()
141+
130142 h := http.Header {}
131143 h .Add ("Link" , `<https://example.com/?page=2>; rel="next",<https://example.com/?page=34>; rel="last"` )
132144 h .Add ("Link" , `<https://example.com/?page=foo>; rel="foo",<https://example.com/?page=bar>; rel="bar"` )
@@ -163,6 +175,8 @@ func TestParseHeader_multiple_headers(t *testing.T) {
163175}
164176
165177func TestParseHeader_extra (t * testing.T ) {
178+ t .Parallel ()
179+
166180 h := http.Header {}
167181 h .Add ("Link" , `<https://example.com/?page=2>; rel="next"; title="foo"` )
168182
@@ -182,24 +196,32 @@ func TestParseHeader_extra(t *testing.T) {
182196}
183197
184198func TestParseHeader_noLink (t * testing.T ) {
199+ t .Parallel ()
200+
185201 if ParseHeader (http.Header {}) != nil {
186202 t .Fatalf (`Parse(http.Header{}) != nil` )
187203 }
188204}
189205
190206func TestParseHeader_nilHeader (t * testing.T ) {
207+ t .Parallel ()
208+
191209 if ParseHeader (nil ) != nil {
192210 t .Fatalf (`ParseHeader(nil) != nil` )
193211 }
194212}
195213
196214func TestParse_emptyString (t * testing.T ) {
215+ t .Parallel ()
216+
197217 if Parse ("" ) != nil {
198218 t .Fatalf (`Parse("") != nil` )
199219 }
200220}
201221
202222func TestParse_valuesWithComma (t * testing.T ) {
223+ t .Parallel ()
224+
203225 g := Parse (`<//www.w3.org/wiki/LinkHeader>; rel="original latest-version",<//www.w3.org/wiki/Special:TimeGate/LinkHeader>; rel="timegate",<//www.w3.org/wiki/Special:TimeMap/LinkHeader>; rel="timemap"; type="application/link-format"; from="Mon, 03 Sep 2007 14:52:48 GMT"; until="Tue, 16 Jun 2015 22:59:23 GMT",<//www.w3.org/wiki/index.php?title=LinkHeader&oldid=10152>; rel="first memento"; datetime="Mon, 03 Sep 2007 14:52:48 GMT",<//www.w3.org/wiki/index.php?title=LinkHeader&oldid=84697>; rel="last memento"; datetime="Tue, 16 Jun 2015 22:59:23 GMT"` )
204226
205227 if got , want := len (g ), 5 ; got != want {
@@ -216,6 +238,8 @@ func TestParse_valuesWithComma(t *testing.T) {
216238}
217239
218240func TestParse_rfc5988Example1 (t * testing.T ) {
241+ t .Parallel ()
242+
219243 g := Parse (`<http://example.com/TheBook/chapter2>; rel="previous"; title="previous chapter"` )
220244
221245 if got , want := len (g ), 1 ; got != want {
@@ -232,6 +256,8 @@ func TestParse_rfc5988Example1(t *testing.T) {
232256}
233257
234258func TestParse_rfc5988Example2 (t * testing.T ) {
259+ t .Parallel ()
260+
235261 g := Parse (`</>; rel="http://example.net/foo"` )
236262
237263 if got , want := len (g ), 1 ; got != want {
@@ -250,11 +276,15 @@ func TestParse_rfc5988Example2(t *testing.T) {
250276}
251277
252278func TestParse_rfc5988Example3 (t * testing.T ) {
279+ t .Parallel ()
280+
253281 // Extended notation is not supported yet
254282 // g := Parse(`</TheBook/chapter2>; rel="previous"; title*=UTF-8'de'letztes%20Kapitel, </TheBook/chapter4>; rel="next"; title*=UTF-8'de'n%c3%a4chstes%20Kapitel`)
255283}
256284
257285func TestParse_rfc5988Example4 (t * testing.T ) {
286+ t .Parallel ()
287+
258288 // Extension relation types are ignored for now
259289 g := Parse (`<http://example.org/>; rel="start http://example.net/relation/other"` )
260290
@@ -272,6 +302,8 @@ func TestParse_rfc5988Example4(t *testing.T) {
272302}
273303
274304func TestParse_fuzzCrashers (t * testing.T ) {
305+ t .Parallel ()
306+
275307 Parse ("0" )
276308}
277309
@@ -281,3 +313,12 @@ func ExampleParse() {
281313 fmt .Printf ("URI: %q, Rel: %q, Extra: %+v\n " , l .URI , l .Rel , l .Extra )
282314 // Output: URI: "https://example.com/?page=2", Rel: "next", Extra: map[title:foo]
283315}
316+
317+ func FuzzParse (f * testing.F ) {
318+ f .Add (`<https://example.com/?page=2>; rel="next"; title="foo"` )
319+ f .Add (`<http://example.org/>; rel="start http://example.net/relation/other"` )
320+
321+ f .Fuzz (func (t * testing.T , s string ) {
322+ Parse (s )
323+ })
324+ }
0 commit comments