mirror of
https://github.com/tmrts/go-patterns.git
synced 2026-11-11 23:07:51 +03:00
Modify strategy pattern
This commit is contained in:
1 parent
b10a4f9cac
commit
b1ddd2651b
2 files changed
+19
-15
No files matched your search
@@ -0,0 +1,18 @@
|
||||
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)
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user