From: Egon W. <eg...@us...> - 2003-06-27 12:38:35
|
Update of /cvsroot/cdk/cdk/src/org/openscience/cdk/test/io/cml In directory sc8-pr-cvs1:/tmp/cvs-serv8614/src/org/openscience/cdk/test/io/cml Modified Files: CMLFragmentsTest.java cmlTestFramework.xml Log Message: Fixed reading of atomic coordinate for CML when some coordinate are not given (closes #754811) Index: CMLFragmentsTest.java =================================================================== RCS file: /cvsroot/cdk/cdk/src/org/openscience/cdk/test/io/cml/CMLFragmentsTest.java,v retrieving revision 1.2 retrieving revision 1.3 diff -u -r1.2 -r1.3 --- CMLFragmentsTest.java 11 Jun 2003 20:20:15 -0000 1.2 +++ CMLFragmentsTest.java 27 Jun 2003 12:38:31 -0000 1.3 @@ -195,6 +195,40 @@ checkForXMoleculeFile(chemFile, 2); } + public void testMissing2DCoordinates() { + String cmlString = + "<molecule id='m1'><atomArray><atom id='a1' xy2='0.0 0.1'/><atom id='a2'/><atom id='a3' xy2='0.1 0.0'/></atomArray></molecule>"; + + ChemFile chemFile = parseCMLString(cmlString); + Molecule mol = checkForSingleMoleculeFile(chemFile); + + assertEquals(3, mol.getAtomCount()); + Atom atom1 = mol.getAtomAt(0); + Atom atom2 = mol.getAtomAt(1); + Atom atom3 = mol.getAtomAt(2); + + assertNotNull(atom1.getPoint2D()); + assertNull (atom2.getPoint2D()); + assertNotNull(atom3.getPoint2D()); + } + + public void testMissing3DCoordinates() { + String cmlString = + "<molecule id='m1'><atomArray><atom id='a1' xyz3='0.0 0.1 0.2'/><atom id='a2'/><atom id='a3' xyz3='0.1 0.0 0.2'/></atomArray></molecule>"; + + ChemFile chemFile = parseCMLString(cmlString); + Molecule mol = checkForSingleMoleculeFile(chemFile); + + assertEquals(3, mol.getAtomCount()); + Atom atom1 = mol.getAtomAt(0); + Atom atom2 = mol.getAtomAt(1); + Atom atom3 = mol.getAtomAt(2); + + assertNotNull(atom1.getPoint3D()); + assertNull (atom2.getPoint3D()); + assertNotNull(atom3.getPoint3D()); + } + private ChemFile parseCMLString(String cmlString) { ChemFile chemFile = null; try { @@ -235,4 +269,5 @@ } return mol; } + } Index: cmlTestFramework.xml =================================================================== RCS file: /cvsroot/cdk/cdk/src/org/openscience/cdk/test/io/cml/cmlTestFramework.xml,v retrieving revision 1.1 retrieving revision 1.2 diff -u -r1.1 -r1.2 --- cmlTestFramework.xml 12 May 2003 14:54:23 -0000 1.1 +++ cmlTestFramework.xml 27 Jun 2003 12:38:31 -0000 1.2 @@ -58,4 +58,28 @@ <bondArray><bond id='b1' atomRefs2='a1 a2'/></bondArray> </molecule> + <!-- JFragmentsTest.testList() --> + <list> + <molecule id='m1'><atomArray><atom id='a1'/><atom id='a2'/></atomArray><bondArray><bond id='b1' atomRefs2='a1 a2'/></bondArray></molecule> + <molecule id='m2'><atomArray><atom id='a1'/><atom id='a2'/></atomArray><bondArray><bond id='b1' atomRefs2='a1 a2'/></bondArray></molecule> + </list> + + <!-- JFragmentsTest.testMissing2DCoordinates() --> + <molecule id='m1'> + <atomArray> + <atom id='a1' xy2='0.0 0.1'/> + <atom id='a2'/> + <atom id='a3' xy2='0.1 0.0'/> + </atomArray> + </molecule> + + <!-- JFragmentsTest.testMissing3DCoordinates() --> + <molecule id='m1'> + <atomArray> + <atom id='a1' xyz3='0.0 0.1 0.2'/> + <atom id='a2'/> + <atom id='a3' xyz3='0.1 0.0 0.2'/> + </atomArray> + </molecule> + </cml> |