1 26 27 package net.sourceforge.groboutils.codecoverage.v2.module; 28 29 import java.io.IOException ; 30 31 import junit.framework.Test; 32 import junit.framework.TestCase; 33 import net.sourceforge.groboutils.autodoc.v1.AutoDoc; 34 import net.sourceforge.groboutils.codecoverage.v2.IAnalysisMetaDataUTestI; 35 import net.sourceforge.groboutils.junit.v1.iftc.CxFactory; 36 import net.sourceforge.groboutils.junit.v1.iftc.InterfaceTestSuite; 37 38 39 46 public class DefaultAnalysisMetaDataUTest extends TestCase 47 { 48 51 private static final Class THIS_CLASS = DefaultAnalysisMetaDataUTest.class; 52 private static final AutoDoc DOC = new AutoDoc( THIS_CLASS ); 53 54 public DefaultAnalysisMetaDataUTest( String name ) 55 { 56 super( name ); 57 } 58 59 60 63 64 public void testConstructor1() 65 { 66 try 67 { 68 new DefaultAnalysisMetaData( null, null, (byte)0 ); 69 fail( "Did not throw IllegalArgumentException." ); 70 } 71 catch (IllegalArgumentException ex) 72 { 73 } 75 } 76 77 78 public void testConstructor2() 79 { 80 try 81 { 82 new DefaultAnalysisMetaData( null, "", (byte)0 ); 83 fail( "Did not throw IllegalArgumentException." ); 84 } 85 catch (IllegalArgumentException ex) 86 { 87 } 89 } 90 91 92 public void testConstructor3() 93 { 94 try 95 { 96 new DefaultAnalysisMetaData( "", null, (byte)0 ); 97 fail( "Did not throw IllegalArgumentException." ); 98 } 99 catch (IllegalArgumentException ex) 100 { 101 } 103 } 104 105 106 public void testConstructor4() 107 { 108 new DefaultAnalysisMetaData( "", "", (byte)0 ); 109 } 110 111 112 public void testGetCoveredFormattedText1() 113 { 114 DefaultAnalysisMetaData damd = new 115 DefaultAnalysisMetaData( "a", "b", (byte)100 ); 116 assertEquals( 117 "Did not return correct covered formatted text.", 118 "a", 119 damd.getCoveredFormattedText() ); 120 } 121 122 123 public void testGetNotCoveredFormattedText1() 124 { 125 DefaultAnalysisMetaData damd = new 126 DefaultAnalysisMetaData( "a", "b", (byte)100 ); 127 assertEquals( 128 "Did not return correct not-covered formatted text.", 129 "b", 130 damd.getNotCoveredFormattedText() ); 131 } 132 133 134 public void testGetInstructionWeight1() 135 { 136 DefaultAnalysisMetaData damd = new 137 DefaultAnalysisMetaData( "a", "b", (byte)100 ); 138 assertEquals( 139 "Did not return correct instruction weight.", 140 (byte)100, 141 damd.getInstructionWeight() ); 142 } 143 144 145 148 149 150 153 154 public static Test suite() 155 { 156 InterfaceTestSuite suite = IAnalysisMetaDataUTestI.suite(); 157 suite.addTestSuite( THIS_CLASS ); 158 suite.addFactory( new CxFactory( "A" ) { 159 public Object createImplObject() throws IOException { 160 return new DefaultAnalysisMetaData( "a", "b", (byte)0 ); 161 } 162 } ); 163 suite.addFactory( new CxFactory( "B" ) { 164 public Object createImplObject() throws IOException { 165 return new DefaultAnalysisMetaData( "a", "b", Byte.MAX_VALUE ); 166 } 167 } ); 168 suite.addFactory( new CxFactory( "C" ) { 169 public Object createImplObject() throws IOException { 170 return new DefaultAnalysisMetaData( "a", "b", Byte.MIN_VALUE ); 171 } 172 } ); 173 174 return suite; 175 } 176 177 public static void main( String [] args ) 178 { 179 String [] name = { THIS_CLASS.getName() }; 180 181 184 junit.textui.TestRunner.main( name ); 185 } 186 187 188 192 protected void setUp() throws Exception 193 { 194 super.setUp(); 195 196 197 } 199 200 201 205 protected void tearDown() throws Exception 206 { 207 209 210 super.tearDown(); 211 } 212 } 213 214 | Popular Tags |