Skip to content

feat: expand TOML reader/writer with comprehensive tests#40

Merged
alvinreal merged 1 commit intomainfrom
fix/issue-10
Feb 21, 2026
Merged

feat: expand TOML reader/writer with comprehensive tests#40
alvinreal merged 1 commit intomainfrom
fix/issue-10

Conversation

@alvinreal
Copy link
Copy Markdown
Owner

Summary

Closes #10 — TOML reader/writer.

Changes

New functionality:

  • from_reader(): Parse TOML from any io::Read source.
  • Stricter top-level constraint: to_string() now explicitly rejects all non-table top-level values (scalars, arrays, strings, bools, null) with a clear error message.

New tests (40+):

  • Basic key-value pairs, negative numbers
  • Nested tables (dotted, multi-level, multiple sections)
  • Arrays of tables ([[table]])
  • Inline tables and inline tables in arrays
  • Datetime types: offset datetime, local datetime, local date, local time
  • Integer formats: decimal with underscores, hex, octal, binary
  • Multiline strings: basic (""") and literal ('''), plus roundtrip
  • Cross-format roundtrips: YAML↔TOML, JSON↔TOML (flat + nested)
  • Top-level constraint errors for: arrays, scalars, strings, bools, null
  • Invalid TOML: broken syntax, duplicate keys, bad values
  • from_reader() for simple and nested docs
  • Edge cases: empty TOML, empty tables, empty arrays, unicode, dotted keys, quoted keys
  • Float edge cases: inf, -inf, nan
  • Null representation (TOML has no null → serialized as string "null")
  • Complex roundtrip with nested tables and arrays

All checks pass: cargo build, cargo test (210 tests), cargo fmt --check, cargo clippy -D warnings.

- Add from_reader() for parsing TOML from io::Read sources
- Enforce top-level table constraint in to_string() for all non-map types
- Add 40+ tests covering: basic key-value pairs, nested/dotted tables,
  arrays of tables, inline tables, datetime types (offset/local/date/time),
  integer formats (hex/octal/binary), multiline strings (basic/literal),
  cross-format roundtrips (JSON↔TOML, YAML↔TOML), top-level constraint
  errors for arrays/scalars/strings/bools/null, invalid TOML parsing,
  from_reader, empty documents, unicode, null representation, float
  edge cases (inf/nan), quoted keys, and complex roundtrips

Fixes #10
@alvinreal alvinreal merged commit 0fd4421 into main Feb 21, 2026
6 checks passed
@alvinreal alvinreal deleted the fix/issue-10 branch February 21, 2026 05:28
@github-actions github-actions bot mentioned this pull request Mar 20, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

TOML reader/writer

1 participant