Files
validate/chars_test.go
T

30 lines
508 B
Go
Raw Normal View History

2023-10-07 10:52:11 +01:00
package validate
import "testing"
func TestChars(t *testing.T) {
type TestCase struct {
Input string
2023-10-08 15:21:02 +01:00
C string
Err error
2023-10-07 10:52:11 +01:00
}
hexRange := "0123456789abcdef"
testCases := []TestCase{
2023-10-08 15:21:02 +01:00
{Input: "abcd1234", C: hexRange},
{Input: "abcd 1234", C: hexRange, Err: ErrDisallowedChars},
2023-10-07 10:52:11 +01:00
}
for _, tc := range testCases {
2023-10-08 15:21:02 +01:00
t.Logf("Testing %q against %q", tc.Input, tc.C)
2023-10-07 10:52:11 +01:00
f := Chars(tc.C)
err := f(tc.Input)
2023-10-08 15:21:02 +01:00
if err != tc.Err {
t.Errorf("Expected error %v, got %v", tc.Err, err)
2023-10-07 10:52:11 +01:00
}
}
}