Example #1
0
func TestWrite_multiple(t *testing.T) {
	b := new(bytes.Buffer)

	err := builder.Write(b, "a", uint8(2), uint16(15), "LOL")
	if err != nil {
		t.Fatal("Error while writing:", err)
	}
	if !bufferEquals(b, []byte{0x0, 0x1, 'a', 0x2, 0x0, 0xF, 0x0, 0x3, 'L', 'O', 'L'}) {
		t.Fatal("Bad value:", b.Bytes())
	}
}
Example #2
0
func TestWrite_int16(t *testing.T) {
	b := new(bytes.Buffer)

	err := builder.Write(b, int16(1540))
	if err != nil {
		t.Fatal("Error while writing:", err)
	}
	if !bufferEquals(b, []byte{0x6, 0x4}) {
		t.Fatal("Bad value:", b.Bytes())
	}
}
Example #3
0
func TestWrite_string(t *testing.T) {
	b := new(bytes.Buffer)

	err := builder.Write(b, "abc")
	if err != nil {
		t.Fatal("Error while writing:", err)
	}
	if !bufferEquals(b, []byte{0x0, 0x3, 'a', 'b', 'c'}) {
		t.Fatal("Bad value:", b.Bytes())
	}
}
Example #4
0
func (c *config) WriteTo(w io.Writer) (n int64, err error) {
	err = builder.Write(w, c.Int, c.Float, c.String)
	return
}
Example #5
0
func (c *Config) WriteTo(w io.Writer) (n int64, err error) {
	err = builder.Write(w, c.MaxRollbackTicks, c.TimeServerPort, c.DefaultPlayerSpeed,
		c.PlayerBallCooldown, c.DefaultBallSpeed, c.DefaultBallLifespan)
	return
}