Testing a Lossless Codec with Independent Evidence
Testing decode after encode verifies reconstruction. An independently known byte sample also checks compatibility when two implementations may share a mistake.
- Source
- Anbloq
- Language
- English
- Created
- Updated
- Chapters
- 4
- Reading time
- 1 min
In this article4 chapters
Trace a tiny code
Encode A then B under A=0 and B=10 and verify significant bits 010 with the specified length. Decoding that evidence should give A then B. See prefix-free words.
Check final framing
Add empty input and one valid symbol that leaves unused bits in the last byte. Bitstream padding defines the observed endings.[1][2]
Compare an independent fixture in both directions
A format writer and reader may encode a short integer in the same incorrect byte order and still pass their own round trip. A known exact binary fixture breaks that symmetry. Check writer output against the fixture and decode its bytes independently. See round-trip tests.
Logical value 258
Agreed big-endian bytes 01 02
Writer must emit 01 02
Reading those independent bytes must return 258
Include an invalid byte sequence too
A test of valid examples cannot verify rejection of truncated records or invalid field sizes. Add one with a documented failure and one spanning a meaningful boundary.