use super::MirGraph;
#[test]
fn a_second_record_on_the_same_line_is_refused() {
let one = "{\"kind\":\"function\",\"name\":\"a\"}";
let other = "{\"kind\":\"call\",\"caller\":\"a\",\"callee\":\"b\",\"mir_line\":1}";
let error = MirGraph::from_jsonl(&format!("{one}{other}")).expect_err("a glued record");
assert_eq!(
error.line, 1,
"the line number points at the line: {error:?}"
);
assert!(
error.message.contains("trailing text"),
"the refusal names the leftover bytes: {error:?}"
);
let graph = MirGraph::from_jsonl(&format!("{one}\n{other}\n")).expect("two lines");
assert_eq!(graph.functions.len(), 1);
assert_eq!(graph.calls.len(), 1);
}
#[test]
fn whitespace_after_a_record_is_not_trailing_text() {
let line = "{\"kind\":\"function\",\"name\":\"a\"} \n";
let graph = MirGraph::from_jsonl(line).expect("a padded line is still one record");
assert_eq!(graph.functions.len(), 1);
}