mirror of
https://github.com/Mezeporta/Erupe.git
synced 2026-03-22 07:32:32 +01:00
Add unit tests across multiple packages: - byteframe: SetBE/SetLE byte order switching - config: Mode.String() for all safe version ranges - mhfpacket: 28 Parse methods, 5 Build methods, empty packet builds, variable-length packets, NOT IMPLEMENTED error paths, UpdateWarehouse - network: PacketID.String() for known IDs, out-of-range, and all valid - channelserver: handleMsgMhfGetPaperData (6 switch cases), grpToGR (11 input values), gacha handlers, TimeGameAbsolute, equipSkinHistSize (4 config branches), guild mission handlers, dumpSaveData disabled path - entranceserver: makeHeader with various inputs
36 lines
885 B
Go
36 lines
885 B
Go
package entranceserver
|
|
|
|
import (
|
|
"testing"
|
|
)
|
|
|
|
// TestMakeHeader tests the makeHeader function with various inputs
|
|
func TestMakeHeader(t *testing.T) {
|
|
tests := []struct {
|
|
name string
|
|
data []byte
|
|
respType string
|
|
entryCount uint16
|
|
key byte
|
|
}{
|
|
{"empty data", []byte{}, "SV2", 0, 0x00},
|
|
{"small data", []byte{0x01, 0x02, 0x03}, "SV2", 1, 0x00},
|
|
{"SVR type", []byte{0xAA, 0xBB}, "SVR", 2, 0x42},
|
|
{"USR type", []byte{0x01}, "USR", 1, 0x00},
|
|
{"larger data", make([]byte, 100), "SV2", 5, 0xFF},
|
|
}
|
|
|
|
for _, tt := range tests {
|
|
t.Run(tt.name, func(t *testing.T) {
|
|
result := makeHeader(tt.data, tt.respType, tt.entryCount, tt.key)
|
|
if len(result) == 0 {
|
|
t.Error("makeHeader returned empty result")
|
|
}
|
|
// First byte should be the key
|
|
if result[0] != tt.key {
|
|
t.Errorf("first byte = %x, want %x", result[0], tt.key)
|
|
}
|
|
})
|
|
}
|
|
}
|