Clover coverage report - Clover results for XOM 1.2d1
Coverage timestamp: Wed Feb 8 2006 08:31:33 EST
file stats: LOC: 84   Methods: 4
NCLOC: 41   Classes: 1
 
 Source file Conditionals Statements Methods TOTAL
AttributesTest.java - 94.4% 100% 95.5%
coverage coverage
 1    /* Copyright 2002, 2003 Elliotte Rusty Harold
 2   
 3    This library is free software; you can redistribute it and/or modify
 4    it under the terms of version 2.1 of the GNU Lesser General Public
 5    License as published by the Free Software Foundation.
 6   
 7    This library is distributed in the hope that it will be useful,
 8    but WITHOUT ANY WARRANTY; without even the implied warranty of
 9    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
 10    GNU Lesser General Public License for more details.
 11   
 12    You should have received a copy of the GNU Lesser General Public
 13    License along with this library; if not, write to the
 14    Free Software Foundation, Inc., 59 Temple Place, Suite 330,
 15    Boston, MA 02111-1307 USA
 16   
 17    You can contact Elliotte Rusty Harold by sending e-mail to
 18    elharo@metalab.unc.edu. Please include the word "XOM" in the
 19    subject line. The XOM home page is located at http://www.xom.nu/
 20    */
 21   
 22    package nu.xom.tests;
 23   
 24    import nu.xom.Attribute;
 25    import nu.xom.Element;
 26   
 27    /**
 28    * <p>
 29    * This class provides unit tests for the
 30    * <code>Attributes</code> class.
 31    * </p>
 32    *
 33    * @author Elliotte Rusty Harold
 34    * @version 1.0
 35    *
 36    */
 37    public class AttributesTest extends XOMTestCase {
 38   
 39  2 public AttributesTest(String name) {
 40  2 super(name);
 41    }
 42   
 43    private Element threeAttributes;
 44    private Element noAttributes;
 45   
 46   
 47  2 protected void setUp() {
 48  2 noAttributes = new Element("test");
 49  2 threeAttributes = new Element("test");
 50  2 threeAttributes.addAttribute(new Attribute("att1", "value1"));
 51  2 threeAttributes.addAttribute(new Attribute("att2", "value2"));
 52  2 threeAttributes.addAttribute(new Attribute("att3", "value3"));
 53    }
 54   
 55  1 public void testSize() {
 56  1 assertEquals(0, noAttributes.getAttributeCount());
 57  1 assertEquals(3, threeAttributes.getAttributeCount());
 58    }
 59   
 60  1 public void testGetOutOfBounds() {
 61   
 62  1 try {
 63  1 noAttributes.getAttribute(0);
 64  0 fail("Should have thrown IndexOutOfBoundsException");
 65    }
 66    catch (IndexOutOfBoundsException success) {
 67  1 assertNotNull(success.getMessage());
 68    }
 69  1 try {
 70  1 threeAttributes.getAttribute(4);
 71    }
 72    catch (IndexOutOfBoundsException success) {
 73  1 assertNotNull(success.getMessage());
 74    }
 75  1 try {
 76  1 threeAttributes.getAttribute(-1);
 77    }
 78    catch (IndexOutOfBoundsException success) {
 79  1 assertNotNull(success.getMessage());
 80    }
 81   
 82    }
 83   
 84    }