1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
|
package planr
import (
"testing"
)
func TestCname(t *testing.T) {
ROOT := "/home/rubric"
v := [] struct { path, cname string } {
{"/home/rubric/tc1.toml", "tc1" },
{"/home/rubric/alpha/tc1.toml", "alpha.tc1" },
{"/home/rubric/alpha/beta/tc2.toml", "alpha.beta.tc2"},
{"/home/rubric/.a/_b./.abcd.toml", ".a._b...abcd"},
}
for _, vec := range v {
got := cname(ROOT, vec.path)
if vec.cname != got {
t.Fatalf("Cname(%s) = %s, wanted %s", vec.path, got, vec.cname)
}
}
}
|