Lines
100 %
Functions
Branches
//! Tests for the suggestion reply parser.
use super::super::parse_suggestions;
#[test]
fn a_reply_yields_its_strings() {
let wire = r#"(:id 3 :value "(\"food\" \"a b\" \"q\\\"uote\")")"#;
assert_eq!(
parse_suggestions(wire),
Some(vec![
"food".to_string(),
"a b".to_string(),
"q\"uote".to_string()
])
);
}
fn an_empty_list_is_an_answer() {
parse_suggestions(r#"(:id 1 :value "()")"#),
Some(Vec::new())
fn failures_and_other_lists_yield_nothing() {
parse_suggestions(r#"(:id 1 :error (:code args :message "no"))"#),
None
assert_eq!(parse_suggestions(r#"(:id 1 :value "(1 2)")"#), None);
assert_eq!(parse_suggestions("garbage"), None);