-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpath_test.go
More file actions
39 lines (34 loc) · 917 Bytes
/
path_test.go
File metadata and controls
39 lines (34 loc) · 917 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
package filesystem
import (
"testing"
"github.com/stretchr/testify/assert"
)
func TestPath_IsAbsolute(t *testing.T) {
absolutes := []Path{
"/",
"/smth",
"/smth/",
}
for _, absolute := range absolutes {
t.Run(absolute.String(), func(t *testing.T) {
assert.Truef(t, absolute.IsAbsolute(), `"%s" was expected to be absolute`, absolute)
assert.Falsef(t, absolute.IsRelative(), `"%s" is both, relative and absolute`, absolute)
})
}
}
func TestPath_IsRelative(t *testing.T) {
relatives := []Path{
"smth",
"./smth",
"../smth/",
}
for _, relative := range relatives {
t.Run(relative.String(), func(t *testing.T) {
assert.Truef(t, relative.IsRelative(), `"%s" was expected to be relative`, relative)
assert.Falsef(t, relative.IsAbsolute(), `"%s" is both, relative and absolute`, relative)
})
}
}
func TestPath_String(t *testing.T) {
assert.Equal(t, (Path)("/").String(), "/")
}