golifehk/datasources/mtr/bus/query_test.go

34 lines
686 B
Go
Raw Normal View History

2022-09-14 09:12:48 +00:00
package bus
2022-09-13 13:42:51 +00:00
import (
"fmt"
2022-09-16 20:33:47 +00:00
"strings"
2022-09-13 13:42:51 +00:00
"testing"
)
2022-09-16 20:33:47 +00:00
func TestQuery( t *testing.T ) {
qo := Query( "zh-Hant", "K73" )
mesg, err := qo.Message()
if err != nil {
t.Errorf( "Unexpected Error: %s", err )
}
2022-09-13 13:42:51 +00:00
2022-09-16 20:33:47 +00:00
if !strings.Contains( mesg, "K73\\-O" ) {
t.Errorf( "Expected Route Listing, got \"%s\" instead", mesg )
}
qo = Query( "zh-Hant", "K76 池" )
mesg, err = qo.Message()
if err == nil {
t.Errorf( "Expecting error, got \"%s\" instead", mesg )
}
qo = Query( "zh-Hant", "K73 池" )
mesg, err = qo.Message()
if err != nil {
t.Errorf( "Unexpected Error: %s", err )
}
fmt.Println( mesg )
2022-09-13 13:42:51 +00:00
}