001: /*
002: * @(#)AsmblStateSetUTest.java
003: *
004: * Copyright (C) 2002-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.mbtf.v1.assembler;
028:
029: import org.easymock.EasyMock;
030: import org.easymock.MockControl;
031: import junit.framework.Test;
032: import junit.framework.TestCase;
033: import junit.framework.TestSuite;
034:
035: /**
036: * Tests the AsmblStateSet class.
037: *
038: * @author Matt Albrecht <a href="mailto:groboclown@users.sourceforge.net">groboclown@users.sourceforge.net</a>
039: * @version $Date: 2003/02/10 22:52:27 $
040: * @since June 17, 2002
041: */
042: public class AsmblStateSetUTest extends TestCase {
043: //-------------------------------------------------------------------------
044: // Standard JUnit Class-specific declarations
045:
046: private static final Class THIS_CLASS = AsmblStateUTest.class;
047:
048: public AsmblStateSetUTest(String name) {
049: super (name);
050: }
051:
052: //-------------------------------------------------------------------------
053: // setup
054:
055: /**
056: *
057: * @exception Exception thrown under any exceptional condition.
058: */
059: protected void setUp() throws Exception {
060: super .setUp();
061:
062: // set ourself up
063: }
064:
065: //-------------------------------------------------------------------------
066: // Tests
067:
068: public void testConstructor1() {
069: new AsmblStateSet();
070: }
071:
072: public void testAddState1() {
073: AsmblStateSet ats = new AsmblStateSet();
074: ats.addState(null);
075: AsmblState[] v = ats.getStates();
076: assertNotNull("states returned null.", v);
077: assertEquals("states size not right.", 0, v.length);
078: }
079:
080: public void testAddState2() {
081: AsmblState at = new AsmblState();
082: AsmblStateSet ats = new AsmblStateSet();
083: ats.addState(at);
084: AsmblState[] v = ats.getStates();
085: assertNotNull("states returned null.", v);
086: assertEquals("states size not right.", 1, v.length);
087: assertEquals("states inserted not returned.", at, v[0]);
088: }
089:
090: public void testAddStates1() {
091: AsmblStateSet ats = new AsmblStateSet();
092: ats.addStates(null);
093: AsmblState[] v = ats.getStates();
094: assertNotNull("states returned null.", v);
095: assertEquals("states size not right.", 0, v.length);
096: }
097:
098: public void testAddStates2() {
099: AsmblState[] at = new AsmblState[0];
100: AsmblStateSet ats = new AsmblStateSet();
101: ats.addStates(at);
102: AsmblState[] v = ats.getStates();
103: assertNotNull("states returned null.", v);
104: assertEquals("states size not right.", 0, v.length);
105: }
106:
107: public void testAddStates3() {
108: AsmblState[] at = new AsmblState[1];
109: AsmblStateSet ats = new AsmblStateSet();
110: ats.addStates(at);
111: AsmblState[] v = ats.getStates();
112: assertNotNull("states returned null.", v);
113: assertEquals("states size not right.", 0, v.length);
114: }
115:
116: public void testAddStates4() {
117: AsmblState at = new AsmblState();
118: AsmblState atlist[] = new AsmblState[1];
119: atlist[0] = at;
120: AsmblStateSet ats = new AsmblStateSet();
121: ats.addStates(atlist);
122: AsmblState[] v = ats.getStates();
123: assertNotNull("states returned null.", v);
124: assertEquals("states size not right.", 1, v.length);
125: assertEquals("states inserted not returned.", at, v[0]);
126: }
127:
128: public void testAddStates5() {
129: AsmblState at = new AsmblState();
130: AsmblState atlist[] = new AsmblState[2];
131: atlist[0] = at;
132: AsmblStateSet ats = new AsmblStateSet();
133: ats.addStates(atlist);
134: AsmblState[] v = ats.getStates();
135: assertNotNull("states returned null.", v);
136: assertEquals("states size not right.", 1, v.length);
137: assertEquals("states inserted not returned.", at, v[0]);
138: }
139:
140: //-------------------------------------------------------------------------
141: // Helpers
142:
143: //-------------------------------------------------------------------------
144: // Standard JUnit declarations
145:
146: public static Test suite() {
147: TestSuite suite = new TestSuite(THIS_CLASS);
148:
149: // Test the implementation's interface conformity.
150: /*
151: suite.addTest( IxUTestI.suite(
152: new ImplementationCreator[] {
153: new ImplementationCreator() {
154: public Object createImplementedObject() {
155: // XXXXXXXXXXXXXXXXXXXXXXXX
156: }
157: },
158: } ) );
159: */
160: return suite;
161: }
162:
163: public static void main(String[] args) {
164: String[] name = { THIS_CLASS.getName() };
165:
166: // junit.textui.TestRunner.main( name );
167: // junit.swingui.TestRunner.main( name );
168:
169: junit.textui.TestRunner.main(name);
170: }
171:
172: /**
173: *
174: * @exception Exception thrown under any exceptional condition.
175: */
176: protected void tearDown() throws Exception {
177: // tear ourself down
178:
179: super.tearDown();
180: }
181: }
|