@@ -86,35 +86,34 @@ func TestGetImgSrcWithBytesReader(t *testing.T) {
86
86
httpBody * bytes.Reader
87
87
}
88
88
89
-
90
89
var html = `<a href="http://jjjj.com">1</a> <video src="http://abc.com/ab.mp4">
91
90
<a style=\"\" href=http://imgur.com>3</a> <img src="abc.com/img.jpg">http://alink.com</p>`
92
91
93
92
c := []byte (html )
94
- i := args {
93
+ i := args {
95
94
bytes .NewReader (c ),
96
95
}
97
96
98
97
var html1 = `<a href="http://jjjj.com">1</a> <video src="http://abc.com/ab.mp4">
99
98
<a style=\"\" href=http://imgur.com>3</a> <img lin="abc.com/img.jpg">http://alink.com</p>`
100
99
101
100
c1 := []byte (html1 )
102
- i1 := args {
101
+ i1 := args {
103
102
bytes .NewReader (c1 ),
104
103
}
105
104
106
- var tests = []struct {
107
- name string
108
- args args
109
- wantS * []string
105
+ var tests = []struct {
106
+ name string
107
+ args args
108
+ wantS * []string
110
109
wantErr bool
111
110
}{
112
- {"img" ,i , & []string {"abc.com/img.jpg" },false },
113
- {"imgNoSrc" ,i1 ,& []string {},false },
111
+ {"img" , i , & []string {"abc.com/img.jpg" }, false },
112
+ {"imgNoSrc" , i1 , & []string {}, false },
114
113
}
115
- for _ , tt := range tests {
116
- t .Run (tt .name ,func (t * testing.T ){
117
- gotS , err := GetImgSrcWithBytesReader (tt .args .httpBody )
114
+ for _ , tt := range tests {
115
+ t .Run (tt .name , func (t * testing.T ) {
116
+ gotS , err := GetImgSrcWithBytesReader (tt .args .httpBody )
118
117
if (err != nil ) != tt .wantErr {
119
118
t .Errorf ("GetImgSrcWithBytesReader() error = %v, wantErr %v" , err , tt .wantErr )
120
119
return
@@ -238,8 +237,6 @@ func BenchmarkAlink(b *testing.B) {
238
237
}
239
238
}
240
239
241
-
242
-
243
240
func TestGetImgSrcWithByte (t * testing.T ) {
244
241
type args struct {
245
242
httpBody []byte
@@ -250,16 +247,16 @@ func TestGetImgSrcWithByte(t *testing.T) {
250
247
http://alink.com
251
248
</p>`
252
249
253
- //string to byte.reader
254
- httpBody := args {[]byte (reader ) }
250
+ //string to byte.reader
251
+ httpBody := args {[]byte (reader )}
255
252
256
- tests := []struct {
253
+ tests := []struct {
257
254
name string
258
255
args args
259
256
wantI * []string
260
257
wantErr bool
261
258
}{
262
- {"img" ,httpBody , & []string {"http://jjjj.com" },false },
259
+ {"img" , httpBody , & []string {"http://jjjj.com" }, false },
263
260
}
264
261
265
262
for _ , tt := range tests {
@@ -294,7 +291,7 @@ func TestGetTitleWithByte(t *testing.T) {
294
291
wantErr bool
295
292
}{
296
293
// TODO: Add test cases.
297
- {"title" ,a1 ,"test1" ,false },
294
+ {"title" , a1 , "test1" , false },
298
295
}
299
296
for _ , tt := range tests {
300
297
t .Run (tt .name , func (t * testing.T ) {
@@ -315,7 +312,7 @@ func TestGetByteWithIoReader(t *testing.T) {
315
312
respBody io.Reader
316
313
}
317
314
318
- af := []byte ("abc" )
315
+ af := []byte ("abc" )
319
316
320
317
body := args {
321
318
bytes .NewReader (af ),
@@ -327,7 +324,7 @@ func TestGetByteWithIoReader(t *testing.T) {
327
324
wantErr bool
328
325
}{
329
326
// TODO: Add test cases.
330
- {"readToByte" ,body ,[]byte {97 ,98 ,99 },false },
327
+ {"readToByte" , body , []byte {97 , 98 , 99 }, false },
331
328
}
332
329
for _ , tt := range tests {
333
330
t .Run (tt .name , func (t * testing.T ) {
@@ -383,8 +380,8 @@ func TestGetHrefWithByte1(t *testing.T) {
383
380
type args struct {
384
381
httpBody []byte
385
382
}
386
- html := `<p>test<a href="test.com">one</a></p>`
387
- html1 := `<p>test <a href="#">one</a></p>`
383
+ html := `<p>test<a href="test.com">one</a></p>`
384
+ html1 := `<p>test <a href="#">one</a></p>`
388
385
389
386
h := []byte (html )
390
387
h1 := []byte (html1 )
@@ -399,8 +396,8 @@ func TestGetHrefWithByte1(t *testing.T) {
399
396
wantErr bool
400
397
}{
401
398
// TODO: Add test cases.
402
- {"one" ,arr ,& []string {"test.com" },false },
403
- {"two" ,arr1 ,& []string {"" },false },
399
+ {"one" , arr , & []string {"test.com" }, false },
400
+ {"two" , arr1 , & []string {"" }, false },
404
401
}
405
402
for _ , tt := range tests {
406
403
t .Run (tt .name , func (t * testing.T ) {
@@ -414,4 +411,4 @@ func TestGetHrefWithByte1(t *testing.T) {
414
411
}
415
412
})
416
413
}
417
- }
414
+ }
0 commit comments