-
Notifications
You must be signed in to change notification settings - Fork 0
/
main_test.go
42 lines (36 loc) · 987 Bytes
/
main_test.go
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
package main
import (
"path/filepath"
"testing"
)
func TestNormalizePath(t *testing.T) {
}
func TestWindowsPathToSheetName(t *testing.T) {
data := make(map[string]pathTest, 2)
data["./Resx/Translations.resx"] = pathTest{
path: "./Resx/Translations.resx",
separator: '/',
expected: "Translations",
}
data["C:\\Users\\woeit\\Downloads\\Excel2Resource\\Resx\\Translations.resx"] = pathTest{
path: "C:\\Users\\woeit\\Downloads\\Excel2Resource\\Resx\\Translations.resx",
separator: '\\',
expected: "Translations",
}
for k, v := range data {
t.Logf("testing %v want %v (slashed %s)", k, v, filepath.ToSlash(k))
baseDir, baseName, err := getPathInfo(k, v.separator)
if err != nil {
t.Fatal(err)
}
t.Logf("got basename %s baseDir %s", baseName, baseDir)
if baseName != v.expected {
t.Errorf("basename has unexpected result got %v want %v", baseName, v)
}
}
}
type pathTest struct {
path string
separator rune
expected string
}