Files
Erupe/server/entranceserver/make_resp_extended_test.go
Houmgaor 645c4ddd38 test: increase code coverage from 45.1% to 48.3%
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
2026-02-17 17:32:54 +01:00

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)
}
})
}
}