@Test
public void testGetFinishedPercentage() throws Exception {

    IsotopeFactory ifac = Isotopes.getInstance();
    IIsotope c = ifac.getMajorIsotope("C");
    IIsotope h = ifac.getMajorIsotope("H");
    IIsotope n = ifac.getMajorIsotope("N");
    IIsotope o = ifac.getMajorIsotope("O");
    MolecularFormulaRange mfRange = new MolecularFormulaRange();
    mfRange.addIsotope(c, 0, 10);
    mfRange.addIsotope(h, 0, 10);
    mfRange.addIsotope(o, 0, 10);
    mfRange.addIsotope(n, 0, 10);
    double minMass = 100.0;
    double maxMass = 100.05;
    MolecularFormulaGenerator gen = new MolecularFormulaGenerator(builder,
            minMass, maxMass, mfRange);
    double finishedPerc, lastFinishedPerc = 0d;
    // The initial value must be 0
    finishedPerc = gen.getFinishedPercentage();
    Assert.assertEquals(0d, finishedPerc, 0.0001);
    // The value must increase after each generated formula
    while (gen.getNextFormula() != null) {
        finishedPerc = gen.getFinishedPercentage();
        Assert.assertTrue(finishedPerc > lastFinishedPerc);
        lastFinishedPerc = finishedPerc;
    }
    // The final value must be 1
    finishedPerc = gen.getFinishedPercentage();
    Assert.assertEquals(1d, finishedPerc, 0.0001);
}