Chat Message support Encode now,fix test
This commit is contained in:
@ -1,9 +1,8 @@
|
|||||||
package chat
|
package chat
|
||||||
|
|
||||||
import (
|
import (
|
||||||
// "fmt"
|
|
||||||
//"github.com/mattn/go-colorable"//On Windows need
|
|
||||||
"bytes"
|
"bytes"
|
||||||
|
pk "github.com/Tnze/go-mc/net/packet"
|
||||||
"testing"
|
"testing"
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -91,8 +90,14 @@ func TestChatMsgClearString(t *testing.T) {
|
|||||||
|
|
||||||
func TestMessage_Encode(t *testing.T) {
|
func TestMessage_Encode(t *testing.T) {
|
||||||
codeMsg := Message{Translate: "multiplayer.disconnect.server_full"}.Encode()
|
codeMsg := Message{Translate: "multiplayer.disconnect.server_full"}.Encode()
|
||||||
wantMsg := []byte(`{"translate":"multiplayer.disconnect.server_full"}`)
|
|
||||||
if !bytes.Equal(codeMsg, wantMsg) {
|
var msg pk.Chat
|
||||||
t.Error("encode Message error: get", string(codeMsg), ", want", string(wantMsg))
|
if err := msg.Decode(bytes.NewReader(codeMsg)); err != nil {
|
||||||
|
t.Errorf("decode message fail: %v", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
wantMsg := `{"translate":"multiplayer.disconnect.server_full"}`
|
||||||
|
if string(msg) != wantMsg {
|
||||||
|
t.Error("encode Message error: get", string(msg), ", want", wantMsg)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user