2017-12-04 07:27:08 +00:00
|
|
|
package matcher
|
|
|
|
|
|
|
|
import (
|
|
|
|
"fmt"
|
|
|
|
"testing"
|
|
|
|
)
|
|
|
|
|
|
|
|
type TestMatcher struct {
|
|
|
|
}
|
|
|
|
|
|
|
|
func (t *TestMatcher) ServiceName() string {
|
2018-03-29 13:55:08 +00:00
|
|
|
return "TESTMATCHER"
|
|
|
|
}
|
|
|
|
|
|
|
|
func (t *TestMatcher) String() string {
|
2017-12-04 07:27:08 +00:00
|
|
|
return "TestMatcher"
|
|
|
|
}
|
|
|
|
|
|
|
|
func (t *TestMatcher) Match(info MatchInfo, index int, packet []byte) bool {
|
|
|
|
return true
|
|
|
|
}
|
|
|
|
|
|
|
|
func (t *TestMatcher) PacketCount() int {
|
|
|
|
return 1
|
|
|
|
}
|
|
|
|
func (t *TestMatcher) Packet(index int) []byte {
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
|
|
|
func (t *TestMatcher) IsError(info MatchInfo, index int, packet []byte) bool {
|
|
|
|
return true
|
|
|
|
}
|
|
|
|
func (t *TestMatcher) HasResponse(index int) bool {
|
|
|
|
return true
|
|
|
|
}
|
|
|
|
func (t *TestMatcher) IsPrePacket() bool {
|
|
|
|
return true
|
|
|
|
}
|
|
|
|
|
|
|
|
type Animal interface {
|
|
|
|
Speak() string
|
|
|
|
}
|
|
|
|
|
|
|
|
type Dog struct {
|
|
|
|
}
|
|
|
|
|
|
|
|
func (d Dog) Speak() string {
|
|
|
|
return "Woof!"
|
|
|
|
}
|
|
|
|
|
|
|
|
type Cat struct {
|
|
|
|
}
|
|
|
|
|
|
|
|
func (c Cat) Speak() string {
|
|
|
|
return "Meow!"
|
|
|
|
}
|
|
|
|
|
|
|
|
type Llama struct {
|
|
|
|
}
|
|
|
|
|
|
|
|
func (l Llama) Speak() string {
|
|
|
|
return "?????"
|
|
|
|
}
|
|
|
|
|
|
|
|
type JavaProgrammer struct {
|
|
|
|
}
|
|
|
|
|
|
|
|
func (j JavaProgrammer) Speak() string {
|
|
|
|
return "Design patterns!"
|
|
|
|
}
|
|
|
|
|
|
|
|
func TestMatcherTTT(t *testing.T) {
|
|
|
|
|
|
|
|
//animals := []Animal{Dog{}, Cat{}, Llama{}, JavaProgrammer{}}
|
|
|
|
|
|
|
|
var animals []Animal
|
|
|
|
|
|
|
|
animals = append(animals, &Dog{})
|
|
|
|
animals = append(animals, &Cat{})
|
|
|
|
animals = append(animals, &Llama{})
|
|
|
|
animals = append(animals, &JavaProgrammer{})
|
|
|
|
|
|
|
|
for _, a := range animals {
|
|
|
|
fmt.Println(a.Speak())
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
func TestMatchersInit(t *testing.T) {
|
|
|
|
|
|
|
|
}
|