This project uses a comprehensive conformance test suite to verify streaming behavior, markdown parsing, and ANSI formatting, and unit tests to verify application-specific behavior.
Conformance tests are written as TOML fixture files that specify:
- Input chunks: Markdown arriving incrementally (simulating streaming)
- Expected emissions: What should be output after each chunk (empty string if block incomplete)
- Raw ANSI codes: Actual escape sequences for exact terminal output matching
name = "heading-basic"
description = "Heading should emit after newline is received"
[[chunks]]
input = "#"
emit = ""
[[chunks]]
input = " Hello"
emit = ""
[[chunks]]
input = "\n"
emit = "\u001b[1;34m# Hello\u001b[0m\n"Key Points:
- Each
[[chunks]]represents a piece of markdown fed to the parser input: The markdown chunkemit: Expected terminal output (empty""means no emission yet)- ANSI codes use
\u001bformat (TOML Unicode escape)
Tests are organized in tests/fixtures/:
blocks/- Individual block types (headings, paragraphs, code blocks, lists)streaming/- Incremental emission and block boundary detectionansi/- ANSI escape sequence formatting (bold, italic, colors)complex/- Real-world documents with mixed block types
# Run all conformance tests
cargo test
# Run specific test category
cargo test test_block_fixtures
cargo test test_streaming_fixtures
cargo test test_ansi_fixtures
cargo test test_complex_fixtures
# Run with verbose output
cargo test -- --nocaptureWhen tests fail, you see clear diagnostics:
Running 4 tests from blocks...
✗ heading-basic
Heading should emit after newline is received
Chunk 4 failed:
Input: "\n"
Expected: "\u{1b}[1;34m# Hello\u{1b}[0m\n"
Actual: ""
- Create a
.tomlfile in the appropriatetests/fixtures/subdirectory - Define test name and description
- Add chunks with input and expected emissions
- Use
\u001bfor ESC character in ANSI codes
Example ANSI codes:
- Bold:
\u001b[1m...\u001b[0m - Italic:
\u001b[3m...\u001b[0m - Color:
\u001b[1;34m...\u001b[0m(bold blue) - Background:
\u001b[48;5;235m...\u001b[0m
The unit tests live in tests/unit.rs