MCPcopy Create free account
hub / github.com/cschanck/single-file-java / roundTrip

Method roundTrip

src/test/java/org/sfj/JSONOneTest.java:170–189  ·  view source on GitHub ↗
(String... resources)

Source from the content-addressed store, hash-verified

168 }
169
170 private void roundTrip(String... resources) throws ParseException, IOException {
171 for (String res : resources) {
172 InputStream stream = JSONOneTest.class.getResourceAsStream(res);
173 StringBuilder sb = new StringBuilder();
174 new BufferedReader(new InputStreamReader(stream)).lines().forEach(l -> {
175 sb.append(l);
176 sb.append(System.lineSeparator());
177 });
178 JSONOne.JObject obj1 = new JSONOne.Parser(sb.toString()).singleObject();
179 if (obj1.getType().equals(JSONOne.Type.MAP) || obj1.getType().equals(JSONOne.Type.ARRAY)) {
180 String cString = obj1.print(0, true);
181 String nocString = obj1.print(0, false);
182 JSONOne.JObject obj3 = new JSONOne.Parser(nocString).singleObject();
183 JSONOne.JObject obj2 = new JSONOne.Parser(cString).singleObject();
184 assertThat(obj1, is(obj2));
185 assertThat(obj1, is(obj3));
186 assertThat(obj2, is(obj3));
187 }
188 }
189 }
190}

Callers 1

testRoundTripMethod · 0.95

Calls 6

singleObjectMethod · 0.80
appendMethod · 0.65
getTypeMethod · 0.65
printMethod · 0.65
toStringMethod · 0.45
equalsMethod · 0.45

Tested by

no test coverage detected