use of material.ExampleResult in project Zong by Xenoage.
the class SingleStaffBeamPlacerTest method computeForOneStaffTestRoss.
/**
* Tests with examples from Ross.
*/
@Test
public void computeForOneStaffTestRoss() {
List<Example> examples = new RossBeamSlant().getExamples();
List<ExampleResult> results = alist();
for (Example example : examples) {
// collect data
BeamedStems stems = example.getStems();
Slant slant = singleStaffBeamSlanter.compute(stems, 5);
// run test
Placement offset = testee.compute(slant, stems, 1, StaffLines.Companion.getStaff5Lines());
// check result
ExampleResult result = check(offset, example);
results.add(result);
}
// success, when 100% of the examples are perfect or at least accepted
// print accepted and failed results
int perfect = 0, accepted = 0, failed = 0;
for (ExampleResult result : results) {
if (result.getResult() != Result.Perfect) {
System.out.print(result.getExample().getName() + ": ");
if (result.getResult() == Result.Accepted) {
accepted++;
System.out.print("not perfect, but accepted");
} else {
failed++;
System.out.print("FAILED");
}
if (result.getComment() != null)
System.out.print("; " + result.getComment());
System.out.println();
} else {
perfect++;
}
}
System.out.println(SingleStaffBeamPlacerTest.class.getSimpleName() + ": " + perfect + " perfect, " + accepted + " accepted, " + failed + " failed");
if (failed > 0)
fail();
}
use of material.ExampleResult in project Zong by Xenoage.
the class StrategyTest method testStrategies.
@Test
public void testStrategies() {
// collect test material
List<Example> examples = getAllExamples();
// run tests
List<ExampleResult> failedExamples = alist();
for (Example example : examples) {
ExampleResult result = testExample(example);
if (result.getResult() == Result.Failed)
failedExamples.add(result);
}
// list failed examples
if (failedExamples.size() > 0) {
for (ExampleResult example : failedExamples) System.out.println(example.getExample().getName() + " failed: " + example.getComment());
fail(failedExamples.size() + " of " + examples.size() + " examples failed. " + "See console for details.");
}
}
use of material.ExampleResult in project Zong by Xenoage.
the class StrategyTest method testExample.
private ExampleResult testExample(Example example) {
int accsCount = example.getAccsCount();
AccidentalsNotation accs = testees[accsCount].compute(getParams(example.getPitches(), example.getNotes(), example.getAccsCount(), cw, example.getContext()));
ExampleResult result = perfect(example);
result.checkEquals("number of accidentals", accsCount, accs.accidentals.length);
result.checkEquals("total width", example.getExpectedAccsWidthIs(), accs.widthIs);
float[] accsXIs = example.getExpectedAccsXIs();
if (accsXIs != null) {
for (int i : range(accsCount)) {
result.checkEquals("offset of accidental " + i, accsXIs[i], accs.accidentals[i].xIs);
}
}
int[] accsLp = example.getExpectedAccsLp();
for (int i : range(accsCount)) {
result.checkEquals("LP of accidental " + i, accsLp[i], accs.accidentals[i].yLp);
}
return result;
}
Aggregations