MCPcopy Create free account
hub / github.com/dprint/jsonc-parser / parse_result_to_test_str

Function parse_result_to_test_str

tests/test.rs:73–98  ·  view source on GitHub ↗
(parse_result: &ParseResult)

Source from the content-addressed store, hash-verified

71// todo: move elsewhere and improve
72
73fn 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
100fn value_to_test_str(value: &Value) -> String {
101 match value {

Callers 1

test_specsFunction · 0.85

Calls 4

comments_to_test_strFunction · 0.85
lenMethod · 0.80
iterMethod · 0.80
into_iterMethod · 0.80

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…