Crates.io | nom-test-helpers |
lib.rs | nom-test-helpers |
version | 6.1.3 |
source | src |
created_at | 2016-11-02 14:25:27.419991 |
updated_at | 2021-03-25 14:33:28.41933 |
description | Macros to help with testing nom parsers |
homepage | https://gitlab.com/pwoolcoc/nom-test-helpers |
repository | https://gitlab.com/pwoolcoc/nom-test-helpers |
max_upload_size | |
id | 7113 |
size | 18,798 |
= Nom Test Helpers
https://docs.rs/nom-test-helpers[Documentation]
== Usage
Put this in your Cargo.toml:
== Examples
The macros in this crate are mostly focused on asserting things about IResult
values
returned from a nom
parser.
For example, here is how you would test that an IResult
is Ok, with a specific value
for it's output value:
use nom::{named, tag}; use nom_test_helpers::{assert_done_and_eq, assert_finished_and_eq};
named!(abcd<&str, &str>, tag!("abcd"));
fn main() { let r = abcd("abcd"); assert_done_and_eq!(r, "abcd");
// Additionally, if you want to assert that the I value of the IResult is empty,
// you can use `assert_finished_and_eq!` instead:
assert_finished_and_eq!(r, "abcd");