package domain_test import ( "reflect" "testing" "code.osinet.fr/fgm/lbc/domain" ) func TestFizzbuzz(t *testing.T) { t.Parallel() const Fizz, Buzz, Both = domain.Fizz, domain.Buzz, domain.Both type args struct { int1 int int2 int limit int str1 string str2 string } tests := []struct { name string args args want domain.FizzBuzzes wantErr bool }{ {"happy", args{2, 5, 11, Fizz, Buzz}, domain.FizzBuzzes{"1", Fizz, "3", Fizz, Buzz, Fizz, "7", Fizz, "9", Both, "11"}, false}, {"sad modulo 1", args{1, 5, 10, Fizz, Buzz}, nil, true}, {"sad modulo reused", args{5, 5, 10, Fizz, Buzz}, nil, true}, {"sad modulo limit", args{2, 5, 0, Fizz, Buzz}, nil, true}, {"sad empty string", args{2, 5, 11, Fizz, ""}, nil, true}, {"sad reserved string", args{2, 5, 11, Fizz, "/"}, nil, true}, } for _, tt := range tests { tt := tt t.Run(tt.name, func(t *testing.T) { t.Parallel() got, err := domain.FizzBuzz(tt.args.int1, tt.args.int2, tt.args.limit, tt.args.str1, tt.args.str2) if (err != nil) != tt.wantErr { t.Errorf("FizzBuzz() error = %v, wantErr %v", err, tt.wantErr) return } if !reflect.DeepEqual(got, tt.want) { t.Errorf("FizzBuzz() got = %v, want %v", got, tt.want) } }) } }