Asserts that the NDJSON `input` is semantically identical to `expected`
(input: &[u8], expected: &str)
| 499 | |
| 500 | /// Asserts that the NDJSON `input` is semantically identical to `expected` |
| 501 | fn assert_json_eq(input: &[u8], expected: &str) { |
| 502 | let expected: Vec<Option<Value>> = expected |
| 503 | .split('\n') |
| 504 | .map(|s| (!s.is_empty()).then(|| serde_json::from_str(s).unwrap())) |
| 505 | .collect(); |
| 506 | |
| 507 | let actual: Vec<Option<Value>> = input |
| 508 | .split(|b| *b == b'\n') |
| 509 | .map(|s| (!s.is_empty()).then(|| serde_json::from_slice(s).unwrap())) |
| 510 | .collect(); |
| 511 | |
| 512 | assert_eq!(actual, expected); |
| 513 | } |
| 514 | |
| 515 | #[test] |
| 516 | fn write_simple_rows() { |