001: /*
002: * @(#)DefaultAnalysisMetaDataUTest.java
003: *
004: * Copyright (C) 2003 Matt Albrecht
005: * groboclown@users.sourceforge.net
006: * http://groboutils.sourceforge.net
007: *
008: * Permission is hereby granted, free of charge, to any person obtaining a
009: * copy of this software and associated documentation files (the "Software"),
010: * to deal in the Software without restriction, including without limitation
011: * the rights to use, copy, modify, merge, publish, distribute, sublicense,
012: * and/or sell copies of the Software, and to permit persons to whom the
013: * Software is furnished to do so, subject to the following conditions:
014: *
015: * The above copyright notice and this permission notice shall be included in
016: * all copies or substantial portions of the Software.
017: *
018: * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
019: * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
020: * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
021: * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
022: * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
023: * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
024: * DEALINGS IN THE SOFTWARE.
025: */
026:
027: package net.sourceforge.groboutils.codecoverage.v2.module;
028:
029: import java.io.IOException;
030:
031: import junit.framework.Test;
032: import junit.framework.TestCase;
033: import net.sourceforge.groboutils.autodoc.v1.AutoDoc;
034: import net.sourceforge.groboutils.codecoverage.v2.IAnalysisMetaDataUTestI;
035: import net.sourceforge.groboutils.junit.v1.iftc.CxFactory;
036: import net.sourceforge.groboutils.junit.v1.iftc.InterfaceTestSuite;
037:
038: /**
039: * Tests the DefaultAnalysisMetaData class.
040: *
041: * @author Matt Albrecht <a href="mailto:groboclown@users.sourceforge.net">groboclown@users.sourceforge.net</a>
042: * @version $Date: 2004/04/15 05:48:28 $
043: * @since January 22, 2003
044: */
045: public class DefaultAnalysisMetaDataUTest extends TestCase {
046: //-------------------------------------------------------------------------
047: // Standard JUnit Class-specific declarations
048:
049: private static final Class THIS_CLASS = DefaultAnalysisMetaDataUTest.class;
050: private static final AutoDoc DOC = new AutoDoc(THIS_CLASS);
051:
052: public DefaultAnalysisMetaDataUTest(String name) {
053: super (name);
054: }
055:
056: //-------------------------------------------------------------------------
057: // Tests
058:
059: public void testConstructor1() {
060: try {
061: new DefaultAnalysisMetaData(null, null, (byte) 0);
062: fail("Did not throw IllegalArgumentException.");
063: } catch (IllegalArgumentException ex) {
064: // check exception
065: }
066: }
067:
068: public void testConstructor2() {
069: try {
070: new DefaultAnalysisMetaData(null, "", (byte) 0);
071: fail("Did not throw IllegalArgumentException.");
072: } catch (IllegalArgumentException ex) {
073: // check exception
074: }
075: }
076:
077: public void testConstructor3() {
078: try {
079: new DefaultAnalysisMetaData("", null, (byte) 0);
080: fail("Did not throw IllegalArgumentException.");
081: } catch (IllegalArgumentException ex) {
082: // check exception
083: }
084: }
085:
086: public void testConstructor4() {
087: new DefaultAnalysisMetaData("", "", (byte) 0);
088: }
089:
090: public void testGetCoveredFormattedText1() {
091: DefaultAnalysisMetaData damd = new DefaultAnalysisMetaData("a",
092: "b", (byte) 100);
093: assertEquals("Did not return correct covered formatted text.",
094: "a", damd.getCoveredFormattedText());
095: }
096:
097: public void testGetNotCoveredFormattedText1() {
098: DefaultAnalysisMetaData damd = new DefaultAnalysisMetaData("a",
099: "b", (byte) 100);
100: assertEquals(
101: "Did not return correct not-covered formatted text.",
102: "b", damd.getNotCoveredFormattedText());
103: }
104:
105: public void testGetInstructionWeight1() {
106: DefaultAnalysisMetaData damd = new DefaultAnalysisMetaData("a",
107: "b", (byte) 100);
108: assertEquals("Did not return correct instruction weight.",
109: (byte) 100, damd.getInstructionWeight());
110: }
111:
112: //-------------------------------------------------------------------------
113: // Helpers
114:
115: //-------------------------------------------------------------------------
116: // Standard JUnit declarations
117:
118: public static Test suite() {
119: InterfaceTestSuite suite = IAnalysisMetaDataUTestI.suite();
120: suite.addTestSuite(THIS_CLASS);
121: suite.addFactory(new CxFactory("A") {
122: public Object createImplObject() throws IOException {
123: return new DefaultAnalysisMetaData("a", "b", (byte) 0);
124: }
125: });
126: suite.addFactory(new CxFactory("B") {
127: public Object createImplObject() throws IOException {
128: return new DefaultAnalysisMetaData("a", "b",
129: Byte.MAX_VALUE);
130: }
131: });
132: suite.addFactory(new CxFactory("C") {
133: public Object createImplObject() throws IOException {
134: return new DefaultAnalysisMetaData("a", "b",
135: Byte.MIN_VALUE);
136: }
137: });
138:
139: return suite;
140: }
141:
142: public static void main(String[] args) {
143: String[] name = { THIS_CLASS.getName() };
144:
145: // junit.textui.TestRunner.main( name );
146: // junit.swingui.TestRunner.main( name );
147:
148: junit.textui.TestRunner.main(name);
149: }
150:
151: /**
152: *
153: * @exception Exception thrown under any exceptional condition.
154: */
155: protected void setUp() throws Exception {
156: super .setUp();
157:
158: // set ourself up
159: }
160:
161: /**
162: *
163: * @exception Exception thrown under any exceptional condition.
164: */
165: protected void tearDown() throws Exception {
166: // tear ourself down
167:
168: super.tearDown();
169: }
170: }
|