|
@@ -4,23 +4,23 @@ import (
|
|
|
"testing"
|
|
|
)
|
|
|
|
|
|
-func TestInString(t *testing.T) {
|
|
|
+func TestInInt(t *testing.T) {
|
|
|
type TestCase struct {
|
|
|
- Input string
|
|
|
- A []string
|
|
|
+ Input int
|
|
|
+ A []int
|
|
|
Err error
|
|
|
}
|
|
|
|
|
|
- allow := []string{"abcd", "ef", "1234"}
|
|
|
+ allow := []int{1, 23, 456}
|
|
|
testCases := []TestCase{
|
|
|
- {Input: "abcd", A: allow},
|
|
|
- {Input: "ef", A: allow},
|
|
|
- {Input: "1234", A: allow},
|
|
|
- {Input: "5678", A: allow, Err: ErrValueNotAllowed},
|
|
|
+ {Input: 1, A: allow},
|
|
|
+ {Input: 23, A: allow},
|
|
|
+ {Input: 456, A: allow},
|
|
|
+ {Input: 789, A: allow, Err: ErrValueNotAllowed},
|
|
|
}
|
|
|
|
|
|
for n, tc := range testCases {
|
|
|
- t.Logf("(%d) Testing %q against %v", n, tc.Input, tc.A)
|
|
|
+ t.Logf("(%d) Testing %d against %v", n, tc.Input, tc.A)
|
|
|
|
|
|
f := In(tc.A...)
|
|
|
err := f(tc.Input)
|
|
@@ -31,23 +31,23 @@ func TestInString(t *testing.T) {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
-func TestInInt(t *testing.T) {
|
|
|
+func TestInString(t *testing.T) {
|
|
|
type TestCase struct {
|
|
|
- Input int
|
|
|
- A []int
|
|
|
+ Input string
|
|
|
+ A []string
|
|
|
Err error
|
|
|
}
|
|
|
|
|
|
- allow := []int{1, 23, 456}
|
|
|
+ allow := []string{"abcd", "ef", "1234"}
|
|
|
testCases := []TestCase{
|
|
|
- {Input: 1, A: allow},
|
|
|
- {Input: 23, A: allow},
|
|
|
- {Input: 456, A: allow},
|
|
|
- {Input: 789, A: allow, Err: ErrValueNotAllowed},
|
|
|
+ {Input: "abcd", A: allow},
|
|
|
+ {Input: "ef", A: allow},
|
|
|
+ {Input: "1234", A: allow},
|
|
|
+ {Input: "5678", A: allow, Err: ErrValueNotAllowed},
|
|
|
}
|
|
|
|
|
|
for n, tc := range testCases {
|
|
|
- t.Logf("(%d) Testing %d against %v", n, tc.Input, tc.A)
|
|
|
+ t.Logf("(%d) Testing %q against %v", n, tc.Input, tc.A)
|
|
|
|
|
|
f := In(tc.A...)
|
|
|
err := f(tc.Input)
|