Conditions | 3 |
Total Lines | 45 |
Code Lines | 26 |
Lines | 0 |
Ratio | 0 % |
Changes | 0 |
1 | package urlpath_test |
||
10 | func TestHasExtension(t *testing.T) { |
||
11 | testCases := []struct { |
||
12 | path string |
||
13 | expectedResult bool |
||
14 | }{ |
||
15 | { |
||
16 | path: "images/image.jpg", |
||
17 | expectedResult: true, |
||
18 | }, |
||
19 | { |
||
20 | path: "file.pdf", |
||
21 | expectedResult: true, |
||
22 | }, |
||
23 | { |
||
24 | path: "home/page.php", |
||
25 | expectedResult: true, |
||
26 | }, |
||
27 | { |
||
28 | path: "src/code.cpp", |
||
29 | expectedResult: true, |
||
30 | }, |
||
31 | { |
||
32 | path: "src/code.h", |
||
33 | expectedResult: true, |
||
34 | }, |
||
35 | { |
||
36 | path: "folder/script.sh", |
||
37 | expectedResult: true, |
||
38 | }, |
||
39 | { |
||
40 | path: "myfile", |
||
41 | expectedResult: false, |
||
42 | }, |
||
43 | { |
||
44 | path: "myfolder/myfile", |
||
45 | expectedResult: false, |
||
46 | }, |
||
47 | } |
||
48 | |||
49 | for _, tc := range testCases { |
||
50 | tc := tc |
||
51 | t.Run(tc.path, func(t *testing.T) { |
||
52 | t.Parallel() |
||
53 | |||
54 | assert.Equal(t, tc.expectedResult, urlpath.HasExtension(tc.path)) |
||
55 | }) |
||
58 |