27 lines
695 B
Go
27 lines
695 B
Go
package model
|
|
|
|
import (
|
|
"strings"
|
|
"testing"
|
|
)
|
|
|
|
func TestAllocateInputLimit(t *testing.T) {
|
|
for _, test := range []struct {
|
|
name string
|
|
input string
|
|
wantError bool
|
|
}{
|
|
{"empty", " \r\n\t", true},
|
|
{"ignore blanks", "\r\n123\r\n\n456 789 012\n", false},
|
|
{"at limit", strings.Repeat("123\n", SimCardAllocateMaxInputRows), false},
|
|
{"above limit", strings.Repeat("123\n", SimCardAllocateMaxInputRows+1), true},
|
|
} {
|
|
t.Run(test.name, func(t *testing.T) {
|
|
param := &TSimCardAllocatePrepareParam{Input: test.input}
|
|
if err := param.ValidateInput(); (err != nil) != test.wantError {
|
|
t.Fatalf("ValidateInput() = %v, wantError = %v", err, test.wantError)
|
|
}
|
|
})
|
|
}
|
|
}
|