예제 #1
0
  /**
   * A unit test suite for JUnit.
   *
   * @return The test suite
   */
  @Test
  public void testDefaultValidFalse() throws ClassNotFoundException, CDKException, Exception {

    IRule rule = new ChargeRule();

    IMolecularFormula formula = new MolecularFormula();
    formula.addIsotope(builder.newIsotope("C"), 2);
    formula.addIsotope(builder.newIsotope("H"), 200);
    formula.setCharge(1);

    Assert.assertEquals(0.0, rule.validate(formula), 0.0001);
  }
예제 #2
0
  /**
   * A unit test suite for JUnit.
   *
   * @return The test suite
   */
  @Test
  public void testDefaultValidFalse_SetParam()
      throws ClassNotFoundException, CDKException, Exception {

    IRule rule = new ChargeRule();

    Object[] params = new Object[1];
    IMolecularFormula formula = new MolecularFormula();
    formula.addIsotope(builder.newIsotope("C"), 2);
    formula.addIsotope(builder.newIsotope("H"), 200);
    formula.setCharge(1);

    params[0] = -1.0;
    rule.setParameters(params);

    Assert.assertEquals(0.0, rule.validate(formula), 0.0001);
  }