MCPcopy Create free account
hub / github.com/Stenway/RSV-Challenge / checkTestFiles

Method checkTestFiles

Java/Rsv.java:205–238  ·  view source on GitHub ↗
(PrintWriter stdout)

Source from the content-addressed store, hash-verified

203 // ----------------------------------------------------------------------
204
205 static void checkTestFiles(PrintWriter stdout) throws IOException {
206 for (int i=1; i<=79; i++) {
207 String filePath = "./../TestFiles/Valid_" + String.format("%03d", i);
208 stdout.println("Checking valid test file: " + filePath);
209 String[][] loadedRows = loadRsv(filePath + ".rsv");
210 String jsonStr = rsvToJson(loadedRows);
211
212 String loadedJsonStr = new String(Files.readAllBytes(Paths.get(filePath + ".json")), StandardCharsets.UTF_8);
213 if (!jsonStr.equals(loadedJsonStr)) {
214 throw new RuntimeException("JSON mismatch");
215 }
216
217 if (!isValidRsv(Files.readAllBytes(Paths.get(filePath + ".rsv")))) {
218 throw new RuntimeException("Validation mismatch");
219 }
220 }
221
222 for (int i=1; i<=29; i++) {
223 String filePath = "./../TestFiles/Invalid_" + String.format("%03d", i);
224 stdout.println("Checking invalid test file: " + filePath);
225 boolean wasError = false;
226 try {
227 loadRsv(filePath + ".rsv");
228 } catch(Exception e) {
229 wasError = true;
230 }
231 if (!wasError) {
232 throw new RuntimeException("RSV document is valid");
233 }
234 if (isValidRsv(Files.readAllBytes(Paths.get(filePath + ".rsv")))) {
235 throw new RuntimeException("Validation mismatch");
236 }
237 }
238 }
239
240 // ----------------------------------------------------------------------
241

Callers 1

mainMethod · 0.95

Calls 4

loadRsvMethod · 0.95
rsvToJsonMethod · 0.95
isValidRsvMethod · 0.95
readAllBytesMethod · 0.80

Tested by

no test coverage detected