Test packet classification
(t *testing.T)
| 71 | |
| 72 | // Test packet classification |
| 73 | func TestClassifyPacket(t *testing.T) { |
| 74 | tests := []struct { |
| 75 | name string |
| 76 | firstByte byte |
| 77 | expected PacketType |
| 78 | }{ |
| 79 | {"Initial", 0xC0, PacketInitial}, // 1100 0000 - Long header, type 00 |
| 80 | {"Initial with PN", 0xC3, PacketInitial}, // 1100 0011 - Long header, type 00, PN len 4 |
| 81 | {"0-RTT", 0xD0, PacketZeroRTT}, // 1101 0000 - Long header, type 01 |
| 82 | {"Handshake", 0xE0, PacketHandshake}, // 1110 0000 - Long header, type 10 |
| 83 | {"Retry", 0xF0, PacketRetry}, // 1111 0000 - Long header, type 11 |
| 84 | {"Short Header", 0x40, PacketShortHeader}, // 0100 0000 - Short header |
| 85 | {"Short Header 2", 0x5F, PacketShortHeader}, // 0101 1111 - Short header |
| 86 | } |
| 87 | |
| 88 | for _, tt := range tests { |
| 89 | t.Run(tt.name, func(t *testing.T) { |
| 90 | packet := []byte{tt.firstByte, 0, 0, 0, 0} |
| 91 | got := ClassifyPacket(packet) |
| 92 | if got != tt.expected { |
| 93 | t.Errorf("ClassifyPacket(%02x) = %v, want %v", tt.firstByte, got, tt.expected) |
| 94 | } |
| 95 | }) |
| 96 | } |
| 97 | } |
nothing calls this directly
no test coverage detected