88 lines
1.3 KiB
Go
88 lines
1.3 KiB
Go
|
package matcher
|
||
|
|
||
|
import (
|
||
|
"fmt"
|
||
|
"testing"
|
||
|
)
|
||
|
|
||
|
type TestMatcher struct {
|
||
|
}
|
||
|
|
||
|
func (t *TestMatcher) ServiceName() string {
|
||
|
return "TestMatcher"
|
||
|
}
|
||
|
|
||
|
func (t *TestMatcher) Match(index int, packet []byte, info ServiceScanInfo) bool {
|
||
|
return true
|
||
|
}
|
||
|
|
||
|
func (t *TestMatcher) PacketCount() int {
|
||
|
return 1
|
||
|
}
|
||
|
func (t *TestMatcher) Packet(index int) []byte {
|
||
|
return nil
|
||
|
}
|
||
|
|
||
|
func (t *TestMatcher) IsError(index int, packet []byte, info ServiceScanInfo) bool {
|
||
|
return true
|
||
|
}
|
||
|
func (t *TestMatcher) IsNoResponse(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) {
|
||
|
|
||
|
}
|