mirror of
https://github.com/rutgersc/m3u8-rs.git
synced 2024-12-22 06:26:28 +00:00
Fix failed test on CLRF
This commit is contained in:
parent
ab9c554eb4
commit
100a57078a
2 changed files with 23 additions and 8 deletions
|
@ -88,7 +88,7 @@ use nom::{IResult};
|
|||
use nom::{ delimited,none_of,peek,is_not,complete,terminated,tag,
|
||||
alt,do_parse,opt,named,map,map_res,eof,many0,take,take_until,char};
|
||||
use nom::combinator::map;
|
||||
|
||||
use nom::character::complete::{line_ending};
|
||||
use std::str;
|
||||
use std::f32;
|
||||
use std::string;
|
||||
|
@ -513,10 +513,9 @@ named!(pub unquoted<String>,
|
|||
|
||||
named!(pub consume_line<String>,
|
||||
do_parse!(
|
||||
l: map_res!(is_not!("\r\n"), from_utf8_slice)
|
||||
>> take!(1)
|
||||
>>
|
||||
(l)
|
||||
line: map_res!(is_not!("\r\n"), from_utf8_slice)
|
||||
>> line_ending
|
||||
>> (line)
|
||||
)
|
||||
);
|
||||
|
||||
|
|
22
tests/lib.rs
22
tests/lib.rs
|
@ -199,13 +199,29 @@ fn quotes() {
|
|||
Result::Ok(("rest".as_bytes(), "value".to_string()))
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn consume_line_empty() {
|
||||
assert_eq!(
|
||||
consume_line(b"\r\nrest"),
|
||||
Result::Err(nom::Err::Error(("\r\nrest".as_bytes(), nom::error::ErrorKind::IsNot)))
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn consume_empty_line() {
|
||||
let line = consume_line(b"\r\nrest");
|
||||
println!("{:?}", line);
|
||||
fn consume_line_n() {
|
||||
assert_eq!(
|
||||
consume_line(b"before\nrest"),
|
||||
Result::Ok(("rest".as_bytes(), "before".into()))
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn consume_line_rn() {
|
||||
assert_eq!(
|
||||
consume_line(b"before\r\nrest"),
|
||||
Result::Ok(("rest".as_bytes(), "before".into()))
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
|
Loading…
Reference in a new issue