Skip to content

Commit 1425588

Browse files
committed
Add flag test to check for minimum value
1 parent 54c53f9 commit 1425588

1 file changed

Lines changed: 15 additions & 0 deletions

File tree

flags_test.go

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,3 +57,18 @@ func TestFlagsSet(t *testing.T) {
5757
}
5858
}
5959
}
60+
61+
func TestFlagMin(t *testing.T) {
62+
var f uintFlag
63+
f.min = 1 // Set minimum to 1
64+
err := f.Set("0") // and try and set to zero
65+
if err == nil {
66+
t.Fatal("Expected an error trying to set a min value to zero")
67+
}
68+
69+
got := err.Error()
70+
exp := "Less than minimum"
71+
if !strings.Contains(got, exp) {
72+
t.Error("Expected 'Less than minimum', but got", got)
73+
}
74+
}

0 commit comments

Comments
 (0)