diff --git a/defaults.go b/defaults.go index f0161317..ed6a8ab2 100644 --- a/defaults.go +++ b/defaults.go @@ -49,7 +49,6 @@ func empty(given interface{}) bool { case reflect.Struct: return false } - return true } // coalesce returns the first non-empty value. diff --git a/numeric.go b/numeric.go index 209c62e5..4bd89bf7 100644 --- a/numeric.go +++ b/numeric.go @@ -156,4 +156,4 @@ func round(a interface{}, p int, r_opt ...float64) float64 { round = math.Floor(digit) } return round / pow -} \ No newline at end of file +} diff --git a/numeric_test.go b/numeric_test.go index 2f412530..54a4d8b4 100644 --- a/numeric_test.go +++ b/numeric_test.go @@ -181,21 +181,21 @@ func TestMul(t *testing.T) { } } -func TestCeil(t *testing.T){ +func TestCeil(t *testing.T) { assert.Equal(t, 123.0, ceil(123)) assert.Equal(t, 123.0, ceil("123")) assert.Equal(t, 124.0, ceil(123.01)) assert.Equal(t, 124.0, ceil("123.01")) } -func TestFloor(t *testing.T){ +func TestFloor(t *testing.T) { assert.Equal(t, 123.0, floor(123)) assert.Equal(t, 123.0, floor("123")) assert.Equal(t, 123.0, floor(123.9999)) assert.Equal(t, 123.0, floor("123.9999")) } -func TestRound(t *testing.T){ +func TestRound(t *testing.T) { assert.Equal(t, 123.556, round(123.5555, 3)) assert.Equal(t, 123.556, round("123.55555", 3)) assert.Equal(t, 124.0, round(123.500001, 0)) diff --git a/regex.go b/regex.go index 9fe033a6..2016f663 100644 --- a/regex.go +++ b/regex.go @@ -32,4 +32,4 @@ func regexReplaceAllLiteral(regex string, s string, repl string) string { func regexSplit(regex string, s string, n int) []string { r := regexp.MustCompile(regex) return r.Split(s, n) -} \ No newline at end of file +} diff --git a/regex_test.go b/regex_test.go index ccb87fe2..d981fb7e 100644 --- a/regex_test.go +++ b/regex_test.go @@ -16,7 +16,7 @@ func TestRegexMatch(t *testing.T) { assert.False(t, regexMatch(regex, "test@acme")) } -func TestRegexFindAll(t *testing.T){ +func TestRegexFindAll(t *testing.T) { regex := "a{2}" assert.Equal(t, 1, len(regexFindAll(regex, "aa", -1))) assert.Equal(t, 1, len(regexFindAll(regex, "aaaaaaaa", 1))) @@ -24,38 +24,38 @@ func TestRegexFindAll(t *testing.T){ assert.Equal(t, 0, len(regexFindAll(regex, "none", -1))) } -func TestRegexFindl(t *testing.T){ +func TestRegexFindl(t *testing.T) { regex := "fo.?" assert.Equal(t, "foo", regexFind(regex, "foorbar")) assert.Equal(t, "foo", regexFind(regex, "foo foe fome")) assert.Equal(t, "", regexFind(regex, "none")) } -func TestRegexReplaceAll(t *testing.T){ +func TestRegexReplaceAll(t *testing.T) { regex := "a(x*)b" - assert.Equal(t, "-T-T-", regexReplaceAll(regex,"-ab-axxb-", "T")) - assert.Equal(t, "--xx-", regexReplaceAll(regex,"-ab-axxb-", "$1")) - assert.Equal(t, "---", regexReplaceAll(regex,"-ab-axxb-", "$1W")) - assert.Equal(t, "-W-xxW-", regexReplaceAll(regex,"-ab-axxb-", "${1}W")) + assert.Equal(t, "-T-T-", regexReplaceAll(regex, "-ab-axxb-", "T")) + assert.Equal(t, "--xx-", regexReplaceAll(regex, "-ab-axxb-", "$1")) + assert.Equal(t, "---", regexReplaceAll(regex, "-ab-axxb-", "$1W")) + assert.Equal(t, "-W-xxW-", regexReplaceAll(regex, "-ab-axxb-", "${1}W")) } -func TestRegexReplaceAllLiteral(t *testing.T){ +func TestRegexReplaceAllLiteral(t *testing.T) { regex := "a(x*)b" - assert.Equal(t, "-T-T-", regexReplaceAllLiteral(regex,"-ab-axxb-", "T")) - assert.Equal(t, "-$1-$1-", regexReplaceAllLiteral(regex,"-ab-axxb-", "$1")) - assert.Equal(t, "-${1}-${1}-", regexReplaceAllLiteral(regex,"-ab-axxb-", "${1}")) + assert.Equal(t, "-T-T-", regexReplaceAllLiteral(regex, "-ab-axxb-", "T")) + assert.Equal(t, "-$1-$1-", regexReplaceAllLiteral(regex, "-ab-axxb-", "$1")) + assert.Equal(t, "-${1}-${1}-", regexReplaceAllLiteral(regex, "-ab-axxb-", "${1}")) } -func TestRegexSplit(t *testing.T){ +func TestRegexSplit(t *testing.T) { regex := "a" - assert.Equal(t, 4, len(regexSplit(regex,"banana", -1))) - assert.Equal(t, 0, len(regexSplit(regex,"banana", 0))) - assert.Equal(t, 1, len(regexSplit(regex,"banana", 1))) - assert.Equal(t, 2, len(regexSplit(regex,"banana", 2))) + assert.Equal(t, 4, len(regexSplit(regex, "banana", -1))) + assert.Equal(t, 0, len(regexSplit(regex, "banana", 0))) + assert.Equal(t, 1, len(regexSplit(regex, "banana", 1))) + assert.Equal(t, 2, len(regexSplit(regex, "banana", 2))) regex = "z+" - assert.Equal(t, 2, len(regexSplit(regex,"pizza", -1))) - assert.Equal(t, 0, len(regexSplit(regex,"pizza", 0))) - assert.Equal(t, 1, len(regexSplit(regex,"pizza", 1))) - assert.Equal(t, 2, len(regexSplit(regex,"pizza", 2))) -} \ No newline at end of file + assert.Equal(t, 2, len(regexSplit(regex, "pizza", -1))) + assert.Equal(t, 0, len(regexSplit(regex, "pizza", 0))) + assert.Equal(t, 1, len(regexSplit(regex, "pizza", 1))) + assert.Equal(t, 2, len(regexSplit(regex, "pizza", 2))) +}