Search in sources :

Example 1 with ExampleResult

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();
}
Also used : BeamedStems(com.xenoage.zong.musiclayout.spacer.beam.stem.BeamedStems) Placement(com.xenoage.zong.musiclayout.spacer.beam.placement.SingleStaffBeamPlacer.Placement) Example(material.beam.slant.Example) TouchExample(material.beam.stafftouch.TouchExample) RossBeamSlant(material.beam.slant.RossBeamSlant) Slant(com.xenoage.zong.musiclayout.spacer.beam.Slant) RossBeamSlant(material.beam.slant.RossBeamSlant) ExampleResult(material.ExampleResult) Test(org.junit.Test)

Example 2 with ExampleResult

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.");
    }
}
Also used : Example(material.accidentals.Example) ExampleResult(material.ExampleResult) VisualTest(com.xenoage.zong.test.VisualTest) Test(org.junit.Test)

Example 3 with ExampleResult

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;
}
Also used : AccidentalsNotation(com.xenoage.zong.musiclayout.notation.chord.AccidentalsNotation) ExampleResult(material.ExampleResult)

Aggregations

ExampleResult (material.ExampleResult)3 Test (org.junit.Test)2 AccidentalsNotation (com.xenoage.zong.musiclayout.notation.chord.AccidentalsNotation)1 Slant (com.xenoage.zong.musiclayout.spacer.beam.Slant)1 Placement (com.xenoage.zong.musiclayout.spacer.beam.placement.SingleStaffBeamPlacer.Placement)1 BeamedStems (com.xenoage.zong.musiclayout.spacer.beam.stem.BeamedStems)1 VisualTest (com.xenoage.zong.test.VisualTest)1 Example (material.accidentals.Example)1 Example (material.beam.slant.Example)1 RossBeamSlant (material.beam.slant.RossBeamSlant)1 TouchExample (material.beam.stafftouch.TouchExample)1