Thread: [Japi-cvs] SF.net SVN: japi: [8] trunk/src/test/net/sf/japi
Status: Beta
Brought to you by:
christianhujer
From: <chr...@us...> - 2006-04-04 22:22:01
|
Revision: 8 Author: christianhujer Date: 2006-04-04 15:21:47 -0700 (Tue, 04 Apr 2006) ViewCVS: http://svn.sourceforge.net/japi/?rev=8&view=rev Log Message: ----------- Added some unit tests. Improved test structure. Added Paths: ----------- trunk/src/test/net/sf/japi/lang/SuperClassIteratorTest.java trunk/src/test/net/sf/japi/util/ trunk/src/test/net/sf/japi/util/Arrays2Test.java Removed Paths: ------------- trunk/src/test/net/sf/japi/lang/test/ Copied: trunk/src/test/net/sf/japi/lang/SuperClassIteratorTest.java (from rev 7, trunk/src/test/net/sf/japi/lang/test/SuperClassIteratorTest.java) =================================================================== --- trunk/src/test/net/sf/japi/lang/SuperClassIteratorTest.java (rev 0) +++ trunk/src/test/net/sf/japi/lang/SuperClassIteratorTest.java 2006-04-04 22:21:47 UTC (rev 8) @@ -0,0 +1,57 @@ +/* JAPI - (Yet another (hopefully) useful) Java API + * + * Copyright (C) 2004-2006 Christian Hujer + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License as + * published by the Free Software Foundation; either version 2 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA + * 02111-1307, USA. + */ + +package test.net.sf.japi.lang; + +/** Test for SuperClassIterator. + * @author <a href="mailto:ch...@it...">Christian Hujer</a> + */ + +import junit.framework.TestCase; +import net.sf.japi.lang.SuperClassIterator; + +/** Test for {@link SuperClassIterator}. + * @author <a href="mailto:ch...@it...">Christian Hujer</a> + */ +public class SuperClassIteratorTest extends TestCase { + + /** {@inheritDoc} */ + @Override public void setUp() throws Exception { + super.setUp(); + } + + /** {@inheritDoc} */ + @Override public void tearDown() throws Exception { + super.tearDown(); + } + + /** Test case for {@link SuperClassIterator#SuperClassIterator(Class<?>)}. */ + public void testSuperClassIterator() throws Exception { + final SuperClassIterator it = new SuperClassIterator(null); + assertFalse("SuperClassIterator with null class must not have next.", it.hasNext()); + try { + it.remove(); + fail("Expected UnsupportedOperationException."); + } catch (final UnsupportedOperationException ignore) { + /* ignore */ + } + } + +} // class SuperClassIteratorTest Property changes on: trunk/src/test/net/sf/japi/lang/SuperClassIteratorTest.java ___________________________________________________________________ Name: svn:mime-type + text/plain Name: svn:eol-style + LF Added: trunk/src/test/net/sf/japi/util/Arrays2Test.java =================================================================== --- trunk/src/test/net/sf/japi/util/Arrays2Test.java (rev 0) +++ trunk/src/test/net/sf/japi/util/Arrays2Test.java 2006-04-04 22:21:47 UTC (rev 8) @@ -0,0 +1,61 @@ +/* JAPI - (Yet another (hopefully) useful) Java API + * + * Copyright (C) 2004-2006 Christian Hujer + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License as + * published by the Free Software Foundation; either version 2 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA + * 02111-1307, USA. + */ + +package test.net.sf.japi.util; + +/** TODO + * @author <a href="mailto:ch...@it...">Christian Hujer</a> + */ + +import java.util.Arrays; +import junit.framework.TestCase; +import net.sf.japi.util.Arrays2; + +/** + * Test for {@link Arrays2}. + * @author <a href="mailto:ch...@it...">Christian Hujer</a> + */ +public class Arrays2Test extends TestCase { + + /** {@inheritDoc} */ + @Override public void setUp() throws Exception { + super.setUp(); + } + + /** {@inheritDoc} */ + @Override public void tearDown() throws Exception { + super.tearDown(); + } + + /** Test case for {@link Arrays2#concat(double[]...)}. */ + @SuppressWarnings({"ImplicitNumericConversion"}) + public void testConcat() throws Exception { + final byte[] data1Orig = {1, 2, 3}; + final byte[] data2Orig = {4, 5, 6, 7}; + final byte[] data1Copy = data1Orig.clone(); + final byte[] data2Copy = data2Orig.clone(); + final byte[] concatExpected = {1, 2, 3, 4, 5, 6, 7}; + final byte[] concatResult = Arrays2.concat(data1Copy, data2Copy); + assertTrue("Original arrays must be unmodified", Arrays.equals(data1Orig, data1Copy)); + assertTrue("Original arrays must be unmodified", Arrays.equals(data2Orig, data2Copy)); + assertTrue("Concatenation must correctly concatenate", Arrays.equals(concatExpected, concatResult)); + } + +} // class Arrays2Test \ No newline at end of file Property changes on: trunk/src/test/net/sf/japi/util/Arrays2Test.java ___________________________________________________________________ Name: svn:mime-type + text/plain Name: svn:eol-style + LF This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <chr...@us...> - 2006-04-30 13:46:46
|
Revision: 114 Author: christianhujer Date: 2006-04-30 06:46:36 -0700 (Sun, 30 Apr 2006) ViewCVS: http://svn.sourceforge.net/japi/?rev=114&view=rev Log Message: ----------- Added BCD test case. Added Paths: ----------- trunk/src/test/net/sf/japi/io/ trunk/src/test/net/sf/japi/io/BCDTest.java Added: trunk/src/test/net/sf/japi/io/BCDTest.java =================================================================== --- trunk/src/test/net/sf/japi/io/BCDTest.java (rev 0) +++ trunk/src/test/net/sf/japi/io/BCDTest.java 2006-04-30 13:46:36 UTC (rev 114) @@ -0,0 +1,90 @@ +/* + * JAPI - (Yet another (hopefully) useful) Java API + * + * Copyright (C) 2006 Christian Hujer + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License as + * published by the Free Software Foundation; either version 2 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA + * 02111-1307, USA. + */ + +package test.net.sf.japi.io; + +import junit.framework.TestCase; +import net.sf.japi.io.BCD; + +/** Test for {@link BCD}. + * @author <a href="mailto:ch...@it...">Christian Hujer</a> + */ +public class BCDTest extends TestCase { + + /** {@inheritDoc} */ + @Override public void setUp() throws Exception { + super.setUp(); + } + + /** {@inheritDoc} */ + @Override public void tearDown() throws Exception { + super.tearDown(); + } + + /** Test case for {@link BCD#bcd2int(int)}. */ + public void testBcd2int() throws Exception { + assertEquals("bcd 0x00000000 -> dec 0", 0, BCD.bcd2int(0x00000000)); + assertEquals("bcd 0x00000010 -> dec 10", 10, BCD.bcd2int(0x00000010)); + assertEquals("bcd 0x99999999 -> dec 99999999", 99999999, BCD.bcd2int(0x99999999)); + } + + /** Test case for {@link BCD#int2bcd(int)}. */ + public void testInt2bcd() throws Exception { + assertEquals("dec 0 -> bcd 0x00000000", 0x00000000, BCD.int2bcd( 0)); + assertEquals("dec 10 -> bcd 0x00000010", 0x00000010, BCD.int2bcd( 10)); + assertEquals("dec 99999999 -> bcd 0x99999999", 0x99999999, BCD.int2bcd(99999999)); + } + + /** Test case for {@link BCD#check(int)}. */ + public void testCheck() throws Exception { + try { + BCD.check(0x99999999); + } catch (final IllegalArgumentException ignore) { + fail("0x99999999 is okay"); + } + } + + /** Test case for {@link BCD#isBcd(int)}. */ + public void testIsBcd() throws Exception { + assertTrue("0x99999999 is okay", BCD.isBcd(0x99999999)); + assertFalse("0xAAAAAAAA is not okay", BCD.isBcd(0xAAAAAAAA)); + } + + /** Test case for {@link BCD#base10(int)}. */ + public void testBase10() throws Exception { + assertEquals("pow(10, 0) is 1.", 1, BCD.base10(0)); + assertEquals("pow(10, 1) is 10.", 10, BCD.base10(1)); + assertEquals("pow(10, 2) is 100.", 100, BCD.base10(2)); + assertEquals("pow(10, 3) is 1000.", 1000, BCD.base10(3)); + assertEquals("pow(10, 4) is 10000.", 10000, BCD.base10(4)); + assertEquals("pow(10, 5) is 100000.", 100000, BCD.base10(5)); + assertEquals("pow(10, 6) is 1000000.", 1000000, BCD.base10(6)); + assertEquals("pow(10, 7) is 10000000.", 10000000, BCD.base10(7)); + assertEquals("pow(10, 8) is 100000000.", 100000000, BCD.base10(8)); + assertEquals("pow(10, 9) is 1000000000.", 1000000000, BCD.base10(9)); + } + + /** Test case for {@link BCD#correct(int)}. */ + public void testCorrect() throws Exception { + assertEquals("correct(0xA) is 0x10.", 0x10, BCD.correct(0xA)); + } + +} // class BCDTest \ No newline at end of file Property changes on: trunk/src/test/net/sf/japi/io/BCDTest.java ___________________________________________________________________ Name: svn:mime-type + text/plain Name: svn:eol-style + LF This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |