Skip to content

Commit 0b896ee

Browse files
committed
fix test cases
1 parent 0436d43 commit 0b896ee

File tree

2 files changed

+5
-5
lines changed

2 files changed

+5
-5
lines changed

gokay/length.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ func MinLengthString(expected int64, str *string) error {
2525
return nil // Covers the case where a value can be Nil OR has a length constraint
2626
}
2727

28-
if expected < int64(len(*str)) {
28+
if expected > int64(len(*str)) {
2929
return fmt.Errorf("Length was '%d', needs to be at least '%d'", len(*str), expected)
3030
}
3131
return nil

gokay/length_test.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -35,10 +35,10 @@ func TestMinLengthString(t *testing.T) {
3535
String string
3636
MinLength int64
3737
}{
38+
{String: "foo", MinLength: 1},
3839
{String: "foo", MinLength: 3},
3940
{String: "", MinLength: 0},
4041
{String: "a", MinLength: 1},
41-
{String: "a", MinLength: 100},
4242
}
4343
for _, tc := range validCases {
4444
tc := tc
@@ -52,9 +52,9 @@ func TestMinLengthString(t *testing.T) {
5252
String string
5353
MinLength int64
5454
}{
55-
{String: "foo", MinLength: 1},
56-
{String: "1", MinLength: 0},
57-
{String: "", MinLength: -1},
55+
{String: "1", MinLength: 2},
56+
{String: "a", MinLength: 100},
57+
{String: "", MinLength: 1},
5858
}
5959
for _, tc := range invalidCases {
6060
tc := tc

0 commit comments

Comments
 (0)