Using Text Fixtures Across Build Platforms
A shared text fixture should make encoding and newline expectations explicit when different platforms use different defaults.
- Source
- Anbloq
- Language
- English
- Created
- Updated
- Chapters
- 4
- Reading time
- 1 min
In this article4 chapters
Trace a final newline
A fixture ending with LF and one ending with CRLF can parse to the same logical records under universal newline rules. A byte-sensitive test may distinguish them. Physical endings show the stored bytes.
Preserve the correct kind of test
For an archive writer requiring bytes, compare the actual file against an exact reference. For decoded behavior, specify the accepted representation and test equivalent records on the build matrix.[1]
Choose text-level or byte-level fixtures per behavior
A parser fixture might target ordinary logical line separation, while a framing test needs exact CRLF bytes. A checkout can translate line endings under repository settings. Keep exact fixtures under a deliberate file or generation policy. See line endings in Git.
Logical text case: A newline B
Byte-sensitive case: 41 0D 0A 42
Verify exact length and offsets on the latter
Include real platform boundaries
Paths, case handling and default encodings can differ independently from newlines. Use explicit encodings for portable fixtures and include the intended differences as specific cases. Run a fixture on every supported platform that can alter it.