-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain_test.go
More file actions
52 lines (47 loc) · 1.22 KB
/
main_test.go
File metadata and controls
52 lines (47 loc) · 1.22 KB
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
40
41
42
43
44
45
46
47
48
49
50
51
52
package main
import (
"os"
"testing"
)
func TestPath(t *testing.T) {
var dir, home, got, expected string
println("TestPath...")
//Test case 1 {{ if path is absolute}}
dir = validate("log/015")
home, _ = os.UserHomeDir()
got = Path(dir, false)
expected = home + dir
if got != expected {
t.Errorf("\nTest case 1:\ngot: %s\nexpected : %s", got, expected)
}
//Test case 2 {{if Path is relative[default] }}
dir = validate("log/015")
got = Path(dir, true)
expected = dir
if got != expected {
t.Errorf("\nTest case 2 :\ngot: %s\nexpected : %s", got, expected)
}
}
func TestValidate(t *testing.T) {
var dir, got string
println("TestValidate...")
expected := "/Documents/log/"
//Test case 1 {{ no leading and trailing backslashes }}
dir = "Documents/log"
got = validate(dir)
if got != expected {
t.Errorf("\nTest case 1:\ngot: %s\nexpected : %s", got, expected)
}
//Test case 2 {{ no leading backslash }}
dir = "Documents/log/"
got = validate(dir)
if got != expected {
t.Errorf("\nTest case 2:\ngot: %s\nexpected : %s", got, expected)
}
//Test case 3 {{ no trailing backslash }}
dir = "/Documents/log"
got = validate(dir)
if got != expected {
t.Errorf("\nTest case 3:\ngot: %s\nexpected : %s", got, expected)
}
}