1 #![cfg(feature = "stream")]
2 
3 #[macro_use]
4 extern crate nom;
5 
6 use nom::{not_line_ending, IResult};
7 
8 use std::fmt::Debug;
9 
10 /*
11 #[test]
12 #[allow(unused_must_use)]
13 fn tag() {
14   FileProducer::new("assets/links.txt", 20).map(|producer: FileProducer| {
15     let mut p = producer;
16     p.refill();
17 
18     consumer_from_parser!(PrintConsumer<()>, flat_map!(map_res!(tag!("https!"), str::from_utf8), print));
19     let mut cs = PrintConsumer::new();
20     for _ in 1..4 {
21       p.apply(&mut cs);
22     }
23   });
24 }
25 */
26 
print<T: Debug>(input: T) -> IResult<T, ()>27 pub fn print<T: Debug>(input: T) -> IResult<T, ()> {
28   println!("{:?}", input);
29   Ok((input, ()))
30 }
31 
32 #[test]
is_not()33 fn is_not() {
34   //is_not!(foo b"\r\n");
35   named!(foo<&[u8],&[u8]>, is_not!(&b"\r\n"[..]));
36   let a = &b"ab12cd\nefgh"[..];
37   assert_eq!(foo(a), Ok((&b"\nefgh"[..], &b"ab12cd"[..])));
38 }
39 
40 #[test]
exported_public_method_defined_by_macro()41 fn exported_public_method_defined_by_macro() {
42   let a = &b"ab12cd\nefgh"[..];
43   assert_eq!(not_line_ending(a), Ok((&b"\nefgh"[..], &b"ab12cd"[..])));
44 }
45