Skip to content

Commit 450e19a

Browse files
committed
remove get result from builder interface
1 parent 4cafe0a commit 450e19a

File tree

2 files changed

+5
-9
lines changed

2 files changed

+5
-9
lines changed

06_builder/builder.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ type Builder interface {
55
Part1()
66
Part2()
77
Part3()
8-
GetResult() string
98
}
109

1110
type Director struct {

06_builder/builder_test.go

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,6 @@
11
package builder
22

3-
import (
4-
"strconv"
5-
"testing"
6-
)
3+
import "testing"
74

85
type Builder1 struct {
96
result string
@@ -51,16 +48,16 @@ func (b *Builder2) Part3() {
5148
b.result += 3
5249
}
5350

54-
func (b *Builder2) GetResult() string {
55-
return strconv.Itoa(b.result)
51+
func (b *Builder2) GetResult() int {
52+
return b.result
5653
}
5754

5855
func TestBuilder2(t *testing.T) {
5956
builder := &Builder2{}
6057
director := NewDirector(builder)
6158
director.Construct()
6259
res := builder.GetResult()
63-
if res != "6" {
64-
t.Fatalf("Builder2 fail expect 6 acture %s", res)
60+
if res != 6 {
61+
t.Fatalf("Builder2 fail expect 6 acture %d", res)
6562
}
6663
}

0 commit comments

Comments
 (0)