001: /*
002: * File is generated by 'Unit Tests Generator' developed under
003: * 'Web Test Tools' project at http://sf.net/projects/wttools/
004: * Copyright (C) 2001 "Artur Hefczyc" <kobit@users.sourceforge.net>
005: * to all 'Web Test Tools' subprojects.
006: *
007: * No rigths to files and no responsibility for code generated
008: * by this tool are belonged to author of 'unittestsgen' utility.
009: *
010: */
011: package org.geotools.data.vpf.io;
012:
013: import junit.framework.Test;
014: import junit.framework.TestCase;
015: import junit.framework.TestSuite;
016:
017: import org.geotools.data.vpf.ifc.DataTypesDefinition;
018:
019: /**
020: * File <code>RowFieldTest.java</code> is automaticaly generated by
021: * 'unittestsgen' application. Code generator is created for java
022: * sources and for 'junit' package by "Artur Hefczyc"
023: * <kobit@users.sourceforge.net><br/>
024: * You should fulfil test methods with proper code for testing
025: * purpose. All methods where you should put your code are below and
026: * their names starts with 'test'.<br/>
027: * You can run unit tests in many ways, however prefered are:
028: * <ul>
029: * <li>Run tests for one class only, for example for this class you
030: * can run tests with command:
031: * <pre>
032: * java -cp "jar/thisjarfile.jar;lib/junit.jar" org.geotools.vpf.RowFieldTest
033: * </pre>
034: * </li>
035: * <li>Run tests for all classes in one command call. Code generator
036: * creates also <code>TestAll.class</code> which runs all
037: * available tests:
038: * <pre>
039: * java -cp "jar/thisjarfile.jar;lib/junit.jar" TestAll
040: * </pre>
041: * </li>
042: * <li>But the most prefered way is to run all tests from
043: * <em>Ant</em> just after compilation process finished.<br/>
044: * To do it. You need:
045: * <ol>
046: * <li>Ant package from
047: * <a href="http://jakarta.apache.org/">Ant</a>
048: * </li>
049: * <li>JUnit package from
050: * <a href="http://www.junit.org/">JUnit</a>
051: * </li>
052: * <li>Put some code in your <code>build.xml</code> file
053: * to tell Ant how to test your package. Sample code for
054: * Ant's <code>build.xml</code> you can find in created file:
055: * <code>sample-junit-build.xml</code>. And remember to have
056: * <code>junit.jar</code> in CLASSPATH <b>before</b> you run Ant.
057: * To generate reports by ant you must have <code>xalan.jar</code>
058: * in your <code>ANT_HOME/lib/</code> directory.
059: * </li>
060: * </ol>
061: * </li>
062: * </ul>
063: * @source $URL: http://svn.geotools.org/geotools/tags/2.4.1/modules/unsupported/vpf/src/test/java/org/geotools/data/vpf/io/RowFieldTest.java $
064: */
065: public class RowFieldTest extends TestCase implements
066: DataTypesDefinition {
067: /**
068: * Instance of tested class.
069: */
070: protected RowField varRowField;
071:
072: /**
073: * Public constructor for creating testing class.
074: */
075: public RowFieldTest(String name) {
076: super (name);
077: } // end of RowFieldTest(String name)
078:
079: /**
080: * This main method is used for run tests for this class only
081: * from command line.
082: */
083: public static void main(String[] args) {
084: junit.textui.TestRunner.run(suite());
085: } // end of main(Stringp[] args)
086:
087: /**
088: * This method is called every time before particular test execution.
089: * It creates new instance of tested class and it can perform some more
090: * actions which are necessary for performs tests.
091: */
092: protected void setUp() {
093: // Initialize your variable(s) here
094: // for example:
095: // varRowField = new RowField(...);
096: // But note that there is no default constructor in RowField
097: } // end of setUp()
098:
099: /**
100: * Returns all tests which should be performed for testing class.
101: * By default it returns only name of testing class. Instance of this
102: * is then created with its constructor.
103: */
104: public static Test suite() {
105: return new TestSuite(RowFieldTest.class);
106: } // end of suite()
107:
108: /**
109: * Method for testing original source method:
110: * double getAsDouble()
111: * from tested class
112: */
113: public void testGetAsDouble() {
114: double[] testVals = { Double.MAX_VALUE, Double.MIN_VALUE,
115: Double.NEGATIVE_INFINITY, Double.POSITIVE_INFINITY, 0 };
116: for (int i = 0; i < testVals.length; i++) {
117: varRowField = new RowField(new Double(testVals[i]),
118: DATA_LONG_FLOAT);
119: assertEquals("Test RowField for double value: "
120: + testVals[i], testVals[i], varRowField
121: .doubleValue(), 0);
122: } // end of for (int i = 0; i < testVals.length; i++)
123: } // end of testGetAsDouble()
124:
125: /**
126: * Method for testing original source method:
127: * float getAsFloat()
128: * from tested class
129: */
130: public void testGetAsFloat() {
131: float[] testVals = { Float.MAX_VALUE, Float.MIN_VALUE,
132: Float.NEGATIVE_INFINITY, Float.POSITIVE_INFINITY, 0 };
133: for (int i = 0; i < testVals.length; i++) {
134: varRowField = new RowField(new Float(testVals[i]),
135: DATA_SHORT_FLOAT);
136: assertEquals("Test RowField for float value: "
137: + testVals[i], testVals[i], varRowField
138: .floatValue(), 0);
139: } // end of for (int i = 0; i < testVals.length; i++)
140: } // end of testGetAsFloat()
141:
142: /**
143: * Method for testing original source method:
144: * int getAsInt()
145: * from tested class
146: */
147: public void testGetAsInt() {
148: int[] testVals = { Integer.MAX_VALUE, Integer.MIN_VALUE, 0 };
149: for (int i = 0; i < testVals.length; i++) {
150: varRowField = new RowField(new Integer(testVals[i]),
151: DATA_LONG_INTEGER);
152: assertEquals("Testing RowField for integer value: "
153: + testVals[i], testVals[i], varRowField.intValue());
154: } // end of for (int i = 0; i < testVals.length; i++)
155: } // end of testGetAsInt()
156:
157: /**
158: * Method for testing original source method:
159: * long getAsLong()
160: * from tested class
161: */
162: public void testGetAsLong() {
163: long[] testVals = { Long.MAX_VALUE, Long.MIN_VALUE, 0 };
164: for (int i = 0; i < testVals.length; i++) {
165: varRowField = new RowField(new Long(testVals[i]),
166: DATA_LONG_INTEGER);
167: assertEquals("Testing RowField for long value: "
168: + testVals[i], testVals[i], varRowField.longValue());
169: } // end of for (int i = 0; i < testVals.length; i++)
170: } // end of testGetAsLong()
171:
172: /**
173: * Method for testing original source method:
174: * short getAsShort()
175: * from tested class
176: */
177: public void testGetAsShort() {
178: short[] testVals = { Short.MAX_VALUE, Short.MIN_VALUE, 0 };
179: for (int i = 0; i < testVals.length; i++) {
180: varRowField = new RowField(new Short(testVals[i]),
181: DATA_SHORT_INTEGER);
182: assertEquals("Testing RowField for short value: "
183: + testVals[i], testVals[i], varRowField
184: .shortValue());
185: } // end of for (int i = 0; i < testVals.length; i++)
186: } // end of testGetAsShort()
187:
188: /**
189: * Method for testing original source method:
190: * java.lang.String getAsString()
191: * from tested class
192: */
193: public void testGetAsString() {
194: String[] testVals = { null, "" }; //, "\0", "\n", " " };
195: for (int i = 0; i < testVals.length; i++) {
196: varRowField = new RowField(testVals[i], DATA_TEXT);
197: assertEquals("Testing RowField for String value: "
198: + testVals[i], testVals[i], varRowField.toString());
199: } // end of for (int i = 0; i < testVals.length; i++)
200: } // end of testGetAsString()
201:
202: public static final char[] TEST_TYPES = { DATA_TEXT,
203: DATA_LEVEL1_TEXT, DATA_LEVEL2_TEXT, DATA_LEVEL3_TEXT,
204: DATA_SHORT_FLOAT, DATA_LONG_FLOAT, DATA_SHORT_INTEGER,
205: DATA_LONG_INTEGER, DATA_2_COORD_F, DATA_2_COORD_R,
206: DATA_3_COORD_F, DATA_3_COORD_R, DATA_DATE_TIME,
207: DATA_NULL_FIELD, DATA_TRIPLET_ID, };
208:
209: /**
210: * Method for testing original source method:
211: * char getType()
212: * from tested class
213: */
214: public void testGetType() {
215: for (int i = 0; i < TEST_TYPES.length; i++) {
216: assertEquals("Cheking type " + TEST_TYPES[i],
217: TEST_TYPES[i], new RowField("1", TEST_TYPES[i])
218: .getType());
219: } // end of for (int i = 0; i < TEST_TYPES.length; i++)
220: } // end of testGetType()
221:
222: /**
223: * Method for testing original source method:
224: * java.lang.Object getValue()
225: * from tested class
226: */
227: public void testGetValue() {
228: String value = "1";
229: assertSame("Cheking value.", value, new RowField(value,
230: DATA_TEXT).getValue());
231: } // end of testGetValue()
232:
233: } // end of RowFieldTest
|