Search in sources :

Example 1 with Example

use of material.beam.slant.Example 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 Example

use of material.beam.slant.Example in project Zong by Xenoage.

the class SingleStaffBeamSlanterTest method computeTest.

@Test
public void computeTest() {
    // use tests from Ross and Chlapik
    for (Suite<Example> suite : alist(new RossBeamSlant(), new ChlapikBeamSlant())) {
        for (Example example : suite.getExamples()) {
            float expectedSlant = example.getSlantIs();
            Slant slant = testee.compute(example.getStems(), example.staffLines);
            assertSlantContains(expectedSlant, slant, suite.getName() + ": " + example.name);
        }
    }
}
Also used : Example(material.beam.slant.Example) RossBeamSlant(material.beam.slant.RossBeamSlant) ChlapikBeamSlant(material.beam.slant.ChlapikBeamSlant) RossBeamSlant(material.beam.slant.RossBeamSlant) Slant(com.xenoage.zong.musiclayout.spacer.beam.Slant) ChlapikBeamSlant(material.beam.slant.ChlapikBeamSlant) Test(org.junit.Test)

Aggregations

Slant (com.xenoage.zong.musiclayout.spacer.beam.Slant)2 Example (material.beam.slant.Example)2 RossBeamSlant (material.beam.slant.RossBeamSlant)2 Test (org.junit.Test)2 Placement (com.xenoage.zong.musiclayout.spacer.beam.placement.SingleStaffBeamPlacer.Placement)1 BeamedStems (com.xenoage.zong.musiclayout.spacer.beam.stem.BeamedStems)1 ExampleResult (material.ExampleResult)1 ChlapikBeamSlant (material.beam.slant.ChlapikBeamSlant)1 TouchExample (material.beam.stafftouch.TouchExample)1