Files
go-mc/chat/nbtmessage_test.go
patyhank 185020e31c
Some checks failed
CodeQL / Analyze (go) (push) Has been cancelled
Go / Test (1.22) (push) Has been cancelled
Go / Test (^1.22) (push) Has been cancelled
Squashed below commits
nbt chat message

fixes some bug

chunk temp

relocate module

items id
2025-08-27 20:29:40 +08:00

37 lines
786 B
Go

package chat_test
import (
"testing"
"git.konjactw.dev/falloutBot/go-mc/chat"
en_us "git.konjactw.dev/falloutBot/go-mc/data/lang/en-us"
"git.konjactw.dev/falloutBot/go-mc/nbt"
)
func TestMessage_UnmarshalJSON_string(t *testing.T) {
snbts := []string{
"{translate: sleep.players_sleeping, with: [I; 1, 37]}",
}
texts := []string{
"1/37 players sleeping",
}
chat.SetLanguage(en_us.Map)
for i, v := range snbts {
bytes, err := nbt.Marshal(nbt.StringifiedMessage(v))
if err != nil {
t.Errorf("Invalid SNBT: %v", err)
continue
}
var cm chat.Message
if err := nbt.Unmarshal(bytes, &cm); err != nil {
t.Error(err)
}
if str := cm.String(); str != texts[i] {
t.Errorf("gets %q, wants %q", str, texts[i])
}
}
}