()
| 2339 | |
| 2340 | #[test] |
| 2341 | fn safe_write_output_is_valid_json() { |
| 2342 | // Verify the written file is always parseable JSON (round-trip). |
| 2343 | let dir = tmpdir(); |
| 2344 | let path = dir.path().join("roundtrip.json"); |
| 2345 | let value = serde_json::json!({ |
| 2346 | "unicode": "héllo wörld 🦀", |
| 2347 | "nested": {"deep": {"array": [1, null, true, "str"]}}, |
| 2348 | "empty_obj": {}, |
| 2349 | "empty_arr": [] |
| 2350 | }); |
| 2351 | |
| 2352 | safe_write_json_file(&path, &value, None).unwrap(); |
| 2353 | |
| 2354 | let raw = fs::read_to_string(&path).unwrap(); |
| 2355 | let reparsed: serde_json::Value = |
| 2356 | serde_json::from_str(&raw).expect("written file must be valid JSON"); |
| 2357 | assert_eq!(reparsed, value); |
| 2358 | } |
| 2359 | } |
| 2360 | |
| 2361 | #[cfg(test)] |
nothing calls this directly
no test coverage detected