3 import static org.testng.AssertJUnit.assertEquals;
4 import org.testng.annotations.Test;
5 import org.testng.Assert;
11 * Test the constructor that parses a PDB file format ATOM line. Fields are in
12 * fixed column positions
15 public void testStringConstructor()
18 "ATOM 349 NE2 GLN A 48 22.290 8.595 17.680 1.00 14.30 N");
19 assertEquals(349, a.atomIndex);
20 assertEquals("NE", a.name);
21 assertEquals("GLN", a.resName);
22 assertEquals("A", a.chain);
23 assertEquals(48, a.resNumber);
24 assertEquals("48", a.resNumIns);
25 assertEquals(' ', a.insCode);
26 assertEquals(22.290, a.x, 0.00001);
27 assertEquals(8.595, a.y, 0.00001);
28 assertEquals(17.680, a.z, 0.00001);
29 assertEquals(1f, a.occupancy, 0.00001);
30 assertEquals(14.3, a.tfactor, 0.00001);
34 * Test the case where occupancy and temp factor are blank - should default to
38 public void testStringConstructor_blankOccupancyTempFactor()
41 "ATOM 349 NE2 GLN A 48 22.290 8.595 17.680 N");
42 assertEquals(1f, a.occupancy, 0.00001);
43 assertEquals(1f, a.tfactor, 0.00001);
47 * Parsing non-numeric data as Atom throws an exception
50 public void testStringConstructor_malformed()
55 "ATOM 34N NE2 GLN A 48 22.290 8.595 17.680 1.00 14.30 N");
56 Assert.fail("Expected exception");
57 } catch (NumberFormatException e)