|
|
@ -45,17 +45,18 @@ mod tests {
|
|
|
|
|
|
|
|
|
|
|
|
let result = parse_message(buf);
|
|
|
|
let result = parse_message(buf);
|
|
|
|
match result {
|
|
|
|
match result {
|
|
|
|
IResult::Done(remainder, message) => {
|
|
|
|
Ok((remainder, message)) => {
|
|
|
|
// Check the first message.
|
|
|
|
// Check the first message.
|
|
|
|
assert_eq!(message, "Hello World!");
|
|
|
|
assert_eq!(message, "Hello World!");
|
|
|
|
|
|
|
|
|
|
|
|
// And we should have 6 bytes left.
|
|
|
|
// And we should have 6 bytes left.
|
|
|
|
assert_eq!(remainder.len(), 6);
|
|
|
|
assert_eq!(remainder.len(), 6);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
IResult::Incomplete(_) => {
|
|
|
|
Err(Err::Incomplete(_)) => {
|
|
|
|
panic!("Result should not have been incomplete.");
|
|
|
|
panic!("Result should not have been incomplete.");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
IResult::Error(err) => {
|
|
|
|
Err(Err::Error(err)) |
|
|
|
|
|
|
|
|
Err(Err::Failure(err)) => {
|
|
|
|
panic!("Result should not be an error: {:?}.", err);
|
|
|
|
panic!("Result should not be an error: {:?}.", err);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|