Skip to content
Permalink
Browse files

Added missing tests, and particular one about a default 0 value of ge…

…tFlagValue()

Change-Id: I37fa22a35bef0350d0fd113bbe3d113f8aebf3d6
Signed-off-by: John May <john.wilkinsonmay@gmail.com>
  • Loading branch information...
egonw committed Oct 1, 2012
1 parent d7d9003 commit 42db307f29f0c92193ab3e46233e2296f49f65c3
@@ -25,6 +25,8 @@
import java.util.Map;

import org.openscience.cdk.CDKConstants;
import org.openscience.cdk.annotations.TestClass;
import org.openscience.cdk.annotations.TestMethod;
import org.openscience.cdk.interfaces.IChemObjectBuilder;
import org.openscience.cdk.interfaces.IChemObjectChangeEvent;
import org.openscience.cdk.interfaces.IChemObjectListener;
@@ -38,11 +40,13 @@
* @cdk.module standard
* @cdk.githash
*/
@TestClass("org.openscience.cdk.config.NaturalElementTest")
public final class NaturalElement implements IElement {

private String element;
private Integer atomicNumber;

@TestMethod("testSymbol,testMassNumber")
protected NaturalElement(String element, Integer atomicNumber) {
this.element = element;
this.atomicNumber = atomicNumber;
@@ -60,7 +64,7 @@ protected NaturalElement(String element, Integer atomicNumber) {

// unsupported methods

@Override public Number getFlagValue() { return null; }
@Override @TestMethod("testGetFlagValueZeroDefault") public Number getFlagValue() { return (short)0; }
@Override public void setProperty(Object description, Object property) {}
@Override public void removeProperty(Object description) {}
@Override public Object getProperty(Object description) { return null; }
@@ -0,0 +1,47 @@
/* Copyright (C) 2012 Egon Willighagen <egonw@users.sf.net>
*
* Contact: cdk-devel@lists.sourceforge.net
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public License
* as published by the Free Software Foundation; either version 2.1
* of the License, or (at your option) any later version.
* All we ask is that proper credit is given for our work, which includes
* - but is not limited to - adding the above copyright notice to the beginning
* of your source code files, and to any copyright notice that you may distribute
* with programs based on this work.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*/
package org.openscience.cdk.config;

import org.junit.Assert;
import org.junit.Test;
import org.openscience.cdk.interfaces.IChemObject;
import org.openscience.cdk.interfaces.IElement;

public class NaturalElementTest {

@Test public void testGetFlagValueZeroDefault(){
IChemObject chemObject = new NaturalElement("C", 12);
Assert.assertEquals((short)0, chemObject.getFlagValue());
}

@Test public void testSymbol(){
IElement chemObject = new NaturalElement("C", 12);
Assert.assertEquals("C", chemObject.getSymbol());
}

@Test public void testMassNumber(){
IElement chemObject = new NaturalElement("C", 12);
Assert.assertEquals(12, chemObject.getAtomicNumber().intValue());
}

}

0 comments on commit 42db307

Please sign in to comment.
You can’t perform that action at this time.