(parse_result: &ParseResult)
| 71 | // todo: move elsewhere and improve |
| 72 | |
| 73 | fn parse_result_to_test_str(parse_result: &ParseResult) -> String { |
| 74 | let mut text = String::new(); |
| 75 | text.push_str("{\n"); |
| 76 | text.push_str(&format!( |
| 77 | " \"value\": {},\n", |
| 78 | match &parse_result.value { |
| 79 | Some(value) => value_to_test_str(value).replace("\n", "\n "), |
| 80 | None => String::from("null"), |
| 81 | } |
| 82 | )); |
| 83 | text.push_str(" \"comments\": ["); |
| 84 | let comments = parse_result.comments.as_ref().expect("Expected comments."); |
| 85 | let collection_count = comments.len(); |
| 86 | let mut comments = comments.iter().collect::<Vec<_>>(); |
| 87 | comments.sort_by(|a, b| a.0.cmp(b.0)); |
| 88 | for (i, comment_collection) in comments.into_iter().enumerate() { |
| 89 | text.push_str("\n "); |
| 90 | text.push_str(&comments_to_test_str(comment_collection).replace("\n", "\n ")); |
| 91 | if i + 1 < collection_count { |
| 92 | text.push(','); |
| 93 | } |
| 94 | } |
| 95 | text.push_str("\n ]\n"); |
| 96 | text.push_str("}\n"); |
| 97 | text |
| 98 | } |
| 99 | |
| 100 | fn value_to_test_str(value: &Value) -> String { |
| 101 | match value { |
no test coverage detected
searching dependent graphs…