File: test1.rs

package info (click to toggle)
rust-nom-4 4.2.3-3
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, bullseye
  • size: 820 kB
  • sloc: makefile: 2
file content (44 lines) | stat: -rw-r--r-- 950 bytes parent folder | download | duplicates (18)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
#![cfg(feature = "stream")]

#[macro_use]
extern crate nom;

use nom::{not_line_ending, IResult};

use std::fmt::Debug;

/*
#[test]
#[allow(unused_must_use)]
fn tag() {
  FileProducer::new("assets/links.txt", 20).map(|producer: FileProducer| {
    let mut p = producer;
    p.refill();

    consumer_from_parser!(PrintConsumer<()>, flat_map!(map_res!(tag!("https!"), str::from_utf8), print));
    let mut cs = PrintConsumer::new();
    for _ in 1..4 {
      p.apply(&mut cs);
    }
  });
}
*/

pub fn print<T: Debug>(input: T) -> IResult<T, ()> {
  println!("{:?}", input);
  Ok((input, ()))
}

#[test]
fn is_not() {
  //is_not!(foo b"\r\n");
  named!(foo<&[u8],&[u8]>, is_not!(&b"\r\n"[..]));
  let a = &b"ab12cd\nefgh"[..];
  assert_eq!(foo(a), Ok((&b"\nefgh"[..], &b"ab12cd"[..])));
}

#[test]
fn exported_public_method_defined_by_macro() {
  let a = &b"ab12cd\nefgh"[..];
  assert_eq!(not_line_ending(a), Ok((&b"\nefgh"[..], &b"ab12cd"[..])));
}