123456789101112131415161718192021222324252627282930313233 |
- package domain
- import "testing"
- func Test_validate(t *testing.T) {
- t.Parallel()
- type args struct {
- int1 int
- int2 int
- limit int
- }
- tests := []struct {
- name string
- args args
- wantErr bool
- }{
- {"happy", args{2, 5, 10}, false},
- {"sad: 1 out of range", args{1, 5, 10}, true},
- {"sad: 2 out of range", args{2, 11, 10}, true},
- {"sad: limit out of range", args{2, 5, 1}, true},
- {"sad: repeated", args{2, 2, 10}, true},
- }
- for _, tt := range tests {
- tt := tt
- t.Run(tt.name, func(t *testing.T) {
- t.Parallel()
- if err := validateNumbers(tt.args.int1, tt.args.int2, tt.args.limit); (err != nil) != tt.wantErr {
- t.Errorf("validateNumbers() error = %v, wantErr %v", err, tt.wantErr)
- }
- })
- }
- }
|