go-pattern-examples/creation/02_simple_factory/simple_test.go
2020-05-02 17:36:50 +08:00

21 lines
374 B
Go

package simplefactory
import "testing"
//TestTeacher test get New with factory
func TestTeacher(t *testing.T) {
te := New(teacher)
name := te.Say("Tom")
if name != "I am Teacher: Tom" {
t.Fatal("Teacher test fail")
}
}
func TestStudent(t *testing.T) {
st := New(student)
name := st.Say("Tom")
if name != "I am student: Tom" {
t.Fatal("student test fail")
}
}