Expand description
Test framework for parsers.
use nom::bytes::complete::tag;
use kparse::combinators::with_code;
use kparse::examples::{ExSpan, ExTagB, ExTokenizerResult};
use kparse::test::{CheckDump, str_parse};
// run the parser and expect Ok(). Otherwise dump & panic.
str_parse(&mut None, "b", nom_parse_b).ok_any().q(CheckDump);
fn nom_parse_b(i: ExSpan<'_>) -> ExTokenizerResult<'_, ExSpan<'_>> {
with_code(tag("b"), ExTagB)(i)
}
Runs the parser and works like a builder to evaluate the results. The final function is q() which runs the given report.
Note: The &mut None is because lifetimes.
Structs§
- Check
Dump - Dumps the Result data if any test failed.
- Check
Trace - Dumps the full parser trace if any test failed.
- Dump
- Dumps the Result data.
- NoReport
- Do nothing report.
- Test
- Collected data of the test run.
- Timing
- Dumps the Result data.
- Trace
- Dumps the full parser trace.
Traits§
- Report
- Result reporting.
Functions§
- byte_
parse - Runs a parser for &u8 and records the results. Use ok(), err(), … to check specifics. Finish the test with q().
- str_
parse - Runs a parser for &str and records the results. Use ok(), err(), … to check specifics. Finish the test with q().
Type Aliases§
- Test
EqFn - Value comparison.