Provided tests for functions that can be tested (Closes #20).
This commit is contained in:
39
flags/validChar_test.go
Normal file
39
flags/validChar_test.go
Normal file
@ -0,0 +1,39 @@
|
||||
package flags
|
||||
|
||||
import "testing"
|
||||
|
||||
func TestValidChar(t *testing.T) {
|
||||
tests := []struct {
|
||||
name string
|
||||
char rune
|
||||
valid bool
|
||||
}{
|
||||
{
|
||||
name: "Valid char",
|
||||
char: '1',
|
||||
valid: true,
|
||||
},
|
||||
{
|
||||
name: "Invalid char",
|
||||
char: 'a',
|
||||
valid: false,
|
||||
},
|
||||
{
|
||||
name: "Valid char but not relevant",
|
||||
char: '0',
|
||||
valid: true,
|
||||
},
|
||||
}
|
||||
|
||||
flags := Flags{}
|
||||
|
||||
// Run tests
|
||||
for _, tt := range tests {
|
||||
t.Run(tt.name, func(t *testing.T) {
|
||||
if got := flags.validChar(tt.char); got != tt.valid {
|
||||
t.Errorf("validChar() = %v, want %v", got, tt.valid)
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
}
|
Reference in New Issue
Block a user