MCPcopy Create free account
hub / github.com/BaseXdb/basex / test

Method test

basex-core/src/test/java/org/basex/query/QueryTest.java:30–67  ·  view source on GitHub ↗

Tests the specified instance.

()

Source from the content-addressed store, hash-verified

28
29 /** Tests the specified instance. */
30 @Test public void test() {
31 final StringBuilder sb = new StringBuilder();
32 int fail = 0;
33
34 for(final Object[] qu : queries) {
35 if(qu.length == 0) continue;
36
37 final boolean correct = qu.length == 3;
38 final String query = qu[correct ? 2 : 1].toString();
39 final Value cmp = correct ? (Value) qu[1] : null;
40
41 try {
42 final Value value = run(query);
43 if(!correct || !eq(value, cmp)) {
44 sb.append('[').append(qu[0]).append("] ").append(query);
45 sb.append("\n[E] ");
46 if(correct) {
47 serialize(cmp, sb);
48 } else {
49 sb.append("error");
50 }
51 serialize(value, sb.append("\n[F] ")).append(details()).append('\n');
52 ++fail;
53 }
54 } catch(final Exception ex) {
55 final String msg = ex.getMessage();
56 if(correct || msg == null || msg.contains("mailman")) {
57 final String cp = correct && cmp.data() != null ? cmp.toString() : "()";
58 sb.append('[').append(qu[0]).append("] ").append(query).append("\n[E] ");
59 sb.append(cp).append("\n[F] ").append(msg == null ? Util.className(ex) : normNL(msg));
60 sb.append(' ').append(details()).append('\n');
61 Util.stack(ex);
62 ++fail;
63 }
64 }
65 }
66 if(fail != 0) fail(fail + " Errors. [E] = expected, [F] = found:\n" + sb.toString().trim());
67 }
68
69 /**
70 * Returns property details.

Callers

nothing calls this directly

Calls 13

runMethod · 0.95
eqMethod · 0.95
serializeMethod · 0.95
detailsMethod · 0.95
classNameMethod · 0.95
stackMethod · 0.95
toStringMethod · 0.65
appendMethod · 0.65
containsMethod · 0.65
getMessageMethod · 0.45
dataMethod · 0.45
normNLMethod · 0.45

Tested by

no test coverage detected