/** * A unit test suite for JUnit. * * @return The test suite */ @Test public void testRemove_2() { IMolecularFormula formulaMin = new MolecularFormula(); formulaMin.addIsotope(builder.newIsotope("C"), 1); formulaMin.addIsotope(builder.newIsotope("H"), 1); formulaMin.addIsotope(builder.newIsotope("N"), 1); IMolecularFormula formulaMax = new MolecularFormula(); formulaMax.addIsotope(builder.newIsotope("C"), 4); formulaMax.addIsotope(builder.newIsotope("H"), 12); formulaMax.addIsotope(builder.newIsotope("N"), 2); IMolecularFormula mf1 = new MolecularFormula(); mf1.addIsotope(builder.newIsotope("C"), 3); mf1.addIsotope(builder.newIsotope("H"), 10); mf1.addIsotope(builder.newIsotope("N"), 1); IMolecularFormula mf2 = new MolecularFormula(); mf2.addIsotope(builder.newIsotope("C"), 1); mf2.addIsotope(builder.newIsotope("H"), 1); IMolecularFormulaSet formulaSet = new MolecularFormulaSet(); formulaSet.addMolecularFormula(mf1); formulaSet.addMolecularFormula(mf2); IMolecularFormulaSet newMFSet = MolecularFormulaSetManipulator.remove(formulaSet, formulaMin, formulaMax); /*the mf2 is excluded from the limits. It doesn't contain N*/ Assert.assertEquals(1, newMFSet.size()); Assert.assertEquals( MolecularFormulaManipulator.getString(mf1), MolecularFormulaManipulator.getString(newMFSet.getMolecularFormula(0))); }
/** * A unit test suite for JUnit. * * @return The test suite */ @Test public void testRemove_IMolecularFormulaSet_MolecularFormulaRange() { MolecularFormulaRange formulaRange = new MolecularFormulaRange(); formulaRange.addIsotope(builder.newIsotope("C"), 0, 4); formulaRange.addIsotope(builder.newIsotope("H"), 0, 12); formulaRange.addIsotope(builder.newIsotope("N"), 0, 2); IMolecularFormula mf2 = new MolecularFormula(); mf2.addIsotope(builder.newIsotope("C"), 1); mf2.addIsotope(builder.newIsotope("H"), 11); mf2.addIsotope(builder.newIsotope("N"), 1); IMolecularFormula mf1 = new MolecularFormula(); mf1.addIsotope(builder.newIsotope("C"), 3); mf1.addIsotope(builder.newIsotope("H"), 10); IMolecularFormulaSet formulaSet = new MolecularFormulaSet(); formulaSet.addMolecularFormula(mf1); formulaSet.addMolecularFormula(mf2); IMolecularFormulaSet newMFSet = MolecularFormulaSetManipulator.remove(formulaSet, formulaRange); /*the mf2 is excluded from the limits. It doesn't contain N*/ Assert.assertEquals(2, newMFSet.size()); }
/** * A unit test suite for JUnit. * * @return The test suite */ @Test public void testRemove_IMolecularFormulaSet_IMolecularFormula_IMolecularFormula() { IMolecularFormula formulaMin = new MolecularFormula(); formulaMin.addIsotope(builder.newIsotope("C"), 1); formulaMin.addIsotope(builder.newIsotope("H"), 1); formulaMin.addIsotope(builder.newIsotope("O"), 1); IMolecularFormula formulaMax = new MolecularFormula(); formulaMax.addIsotope(builder.newIsotope("C"), 4); formulaMax.addIsotope(builder.newIsotope("H"), 12); formulaMax.addIsotope(builder.newIsotope("N"), 2); IMolecularFormula mf1 = new MolecularFormula(); mf1.addIsotope(builder.newIsotope("C"), 3); mf1.addIsotope(builder.newIsotope("H"), 10); mf1.addIsotope(builder.newIsotope("N"), 1); IMolecularFormulaSet formulaSet = new MolecularFormulaSet(); formulaSet.addMolecularFormula(mf1); IMolecularFormulaSet newMFSet = MolecularFormulaSetManipulator.remove(formulaSet, formulaMin, formulaMax); Assert.assertNull(newMFSet); }