mirror of
https://github.com/crazybber/awesome-patterns.git
synced 2024-11-29 08:26:04 +03:00
19 lines
416 B
Go
19 lines
416 B
Go
|
package strategy
|
||
|
|
||
|
import "testing"
|
||
|
|
||
|
func TestMultiplicationStrategy(t *testing.T) {
|
||
|
mult := Operation{Multiplication{}}
|
||
|
|
||
|
if res := mult.Operate(3, 5); res != 15 {
|
||
|
t.Errorf("Multiplication.Operate(3, 5) expected 15 got %q", res)
|
||
|
}
|
||
|
}
|
||
|
|
||
|
func TestAdditionStrategy(t *testing.T) {
|
||
|
add := Operation{Addition{}}
|
||
|
if res := add.Operate(3, 5); res != 8 {
|
||
|
t.Errorf("Addition.Operate(3, 5) expected 8 got %q", res)
|
||
|
}
|
||
|
}
|