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