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
- Dumps the Result data if any test failed.
- Dumps the full parser trace if any test failed.
- Dumps the Result data.
- Do nothing report.
- Collected data of the test run.
- Dumps the Result data.
- Dumps the full parser trace.
Traits
- Result reporting.
Functions
- Runs a parser for &u8 and records the results. Use ok(), err(), … to check specifics. Finish the test with q().
- Runs a parser for &str and records the results. Use ok(), err(), … to check specifics. Finish the test with q().
Type Aliases
- Value comparison.