Lines
100 %
Functions
Branches
use super::{parse_notices, parse_response};
use crate::envelope::{RequestId, Response, ResponsePayload, format_response, with_notices};
use nomiscript::Value;
fn reply() -> String {
format_response(&Response {
stream: 0,
id: RequestId::Int(7),
payload: ResponsePayload::Value(Value::String("id".to_string())),
})
}
#[test]
fn notices_ride_beside_the_value() -> anyhow::Result<()> {
let notices = vec!["twin \"Cafe\"".to_string(), "second".to_string()];
let wire = with_notices(reply(), ¬ices);
assert_eq!(
wire,
"(:id 7 :value \"id\" :notices (\"twin \\\"Cafe\\\"\" \"second\"))"
);
assert_eq!(parse_notices(&wire), notices);
parse_response(&wire)?.payload,
ResponsePayload::Value(Value::String("id".to_string()))
Ok(())
fn no_notices_leave_the_frame_alone() {
assert_eq!(with_notices(reply(), &[]), reply());
assert!(parse_notices(&reply()).is_empty());
assert!(parse_notices("not a frame (").is_empty());