Skip to content

Commit

Permalink
Add missing test cases from wiki.vg
Browse files Browse the repository at this point in the history
  • Loading branch information
layou233 committed Sep 1, 2024
1 parent 82a52f7 commit f62e79c
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
4 changes: 2 additions & 2 deletions net/packet/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -273,8 +273,8 @@ func (v VarInt) WriteToBytes(buf []byte) int {
return 2
} else if num&0xFFE00000 == 0 {
buf[2] = byte(num >> 14)
endingBytes := uint16((num&0x7F|0x80)<<8 | ((num>>7)&0x7F | 0x80))
binary.BigEndian.PutUint16(buf, endingBytes)
startingBytes := uint16((num&0x7F|0x80)<<8 | ((num>>7)&0x7F | 0x80))
binary.BigEndian.PutUint16(buf, startingBytes)
return 3
} else if num&0xF0000000 == 0 {
result := (num&0x7F|0x80)<<24 | (((num>>7)&0x7F | 0x80) << 16) |
Expand Down
4 changes: 3 additions & 1 deletion net/packet/types_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import (
pk "github.com/Tnze/go-mc/net/packet"
)

var VarInts = []pk.VarInt{0, 1, 2, 127, 128, 255, 2147483647, -1, -2147483648}
var VarInts = []pk.VarInt{0, 1, 2, 127, 128, 255, 25565, 2097151, 2147483647, -1, -2147483648}

var PackedVarInts = [][]byte{
{0x00},
Expand All @@ -19,6 +19,8 @@ var PackedVarInts = [][]byte{
{0x7f},
{0x80, 0x01},
{0xff, 0x01},
{0xdd, 0xc7, 0x01},
{0xff, 0xff, 0x7f},
{0xff, 0xff, 0xff, 0xff, 0x07},
{0xff, 0xff, 0xff, 0xff, 0x0f},
{0x80, 0x80, 0x80, 0x80, 0x08},
Expand Down

0 comments on commit f62e79c

Please sign in to comment.