forked from caixw/gobuild
-
Notifications
You must be signed in to change notification settings - Fork 5
/
gobuild_test.go
55 lines (43 loc) · 1.44 KB
/
gobuild_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
43
44
45
46
47
48
49
50
51
52
53
54
55
// Copyright 2015 by caixw, All rights reserved.
// Use of this source code is governed by a MIT
// license that can be found in the LICENSE file.
package main
import (
"testing"
"github.com/issue9/assert"
)
func TestGetExts(t *testing.T) {
a := assert.New(t)
a.Equal(getExts(""), []string{})
a.Equal(getExts(",, ,"), []string{})
a.Equal(getExts(",.go, ,.php,"), []string{".go", ".php"})
a.Equal(getExts(",go,.php,"), []string{".go", ".php"})
a.Equal(getExts(",go , .php,"), []string{".go", ".php"})
}
func TestRecursivePath(t *testing.T) {
a := assert.New(t)
a.Equal(recursivePaths(false, false, false, []string{"./testdir"}), []string{
"./testdir",
})
a.Equal(recursivePaths(true, false, false, []string{"./testdir"}), []string{
"./testdir",
"testdir/testdir1",
"testdir/testdir2",
"testdir/testdir2/testdir3",
})
a.Equal(recursivePaths(true, false, false, []string{"./testdir/testdir1", "./testdir/testdir2"}), []string{
"./testdir/testdir1",
"./testdir/testdir2",
"testdir/testdir2/testdir3",
})
a.Equal(recursivePaths(true, false, false, []string{"./testdir/testdir2"}), []string{
"./testdir/testdir2",
"testdir/testdir2/testdir3",
})
}
func TestSplitArgs(t *testing.T) {
a := assert.New(t)
a.Equal(splitArgs("x=5 y=6"), []string{"x", "5", "y", "6"})
a.Equal(splitArgs("xxx=5 -yy=6 -bool"), []string{"xxx", "5", "-yy", "6", "-bool"})
a.Equal(splitArgs("xxx=5 yy=6 bool="), []string{"xxx", "5", "yy", "6", "bool"})
}