You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@harmony.apache.org by sm...@apache.org on 2006/04/26 09:12:49 UTC
svn commit: r397123 [3/7] - in
/incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java:
org/apache/harmony/tests/java/util/ tests/api/java/io/ tests/api/java/lang/
tests/api/java/lang/ref/ tests/api/java/lang/reflect/ tests/api/java/net/ ...
Modified: incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/tests/api/java/lang/IntegerTest.java
URL: http://svn.apache.org/viewcvs/incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/tests/api/java/lang/IntegerTest.java?rev=397123&r1=397122&r2=397123&view=diff
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/tests/api/java/lang/IntegerTest.java (original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/tests/api/java/lang/IntegerTest.java Wed Apr 26 00:12:16 2006
@@ -27,7 +27,7 @@
public void test_ConstructorI() {
// Test for method java.lang.Integer(int)
Integer i = new Integer(-89000);
- assertTrue("Incorrect Integer created", i.intValue() == -89000);
+ assertEquals("Incorrect Integer created", -89000, i.intValue());
}
/**
@@ -36,7 +36,7 @@
public void test_ConstructorLjava_lang_String() {
// Test for method java.lang.Integer(java.lang.String)
Integer i = new Integer("65000");
- assertTrue("Created incorrect Integer", i.intValue() == 65000);
+ assertEquals("Created incorrect Integer", 65000, i.intValue());
}
/**
@@ -44,10 +44,10 @@
*/
public void test_byteValue() {
// Test for method byte java.lang.Integer.byteValue()
- assertTrue("Returned incorrect byte value", new Integer(65535)
- .byteValue() == -1);
- assertTrue("Returned incorrect byte value", new Integer(127)
- .byteValue() == 127);
+ assertEquals("Returned incorrect byte value", -1, new Integer(65535)
+ .byteValue());
+ assertEquals("Returned incorrect byte value", 127, new Integer(127)
+ .byteValue());
}
/**
@@ -57,8 +57,8 @@
// Test for method int java.lang.Integer.compareTo(java.lang.Integer)
assertTrue("-2 compared to 1 gave non-negative answer", new Integer(-2)
.compareTo(new Integer(1)) < 0);
- assertTrue("-2 compared to -2 gave non-zero answer", new Integer(-2)
- .compareTo(new Integer(-2)) == 0);
+ assertEquals("-2 compared to -2 gave non-zero answer", 0, new Integer(-2)
+ .compareTo(new Integer(-2)));
assertTrue("3 compared to 2 gave non-positive answer", new Integer(3)
.compareTo(new Integer(2)) > 0);
@@ -75,19 +75,19 @@
public void test_decodeLjava_lang_String() {
// Test for method java.lang.Integer
// java.lang.Integer.decode(java.lang.String)
- assertTrue("Failed for 132233",
- Integer.decode("132233").intValue() == 132233);
- assertTrue("Failed for 07654321",
- Integer.decode("07654321").intValue() == 07654321);
+ assertEquals("Failed for 132233",
+ 132233, Integer.decode("132233").intValue());
+ assertEquals("Failed for 07654321",
+ 07654321, Integer.decode("07654321").intValue());
assertTrue("Failed for #1234567",
Integer.decode("#1234567").intValue() == 0x1234567);
assertTrue("Failed for 0xdAd",
Integer.decode("0xdAd").intValue() == 0xdad);
- assertTrue("Failed for -23", Integer.decode("-23").intValue() == -23);
- assertTrue("Returned incorrect value for 0 decimal", Integer
- .decode("0").intValue() == 0);
- assertTrue("Returned incorrect value for 0 hex", Integer.decode("0x0")
- .intValue() == 0);
+ assertEquals("Failed for -23", -23, Integer.decode("-23").intValue());
+ assertEquals("Returned incorrect value for 0 decimal", 0, Integer
+ .decode("0").intValue());
+ assertEquals("Returned incorrect value for 0 hex", 0, Integer.decode("0x0")
+ .intValue());
assertTrue("Returned incorrect value for most negative value decimal",
Integer.decode("-2147483648").intValue() == 0x80000000);
assertTrue("Returned incorrect value for most negative value hex",
@@ -158,10 +158,10 @@
*/
public void test_doubleValue() {
// Test for method double java.lang.Integer.doubleValue()
- assertTrue("Returned incorrect double value", new Integer(2147483647)
- .doubleValue() == 2147483647.0);
- assertTrue("Returned incorrect double value", new Integer(-2147483647)
- .doubleValue() == -2147483647.0);
+ assertEquals("Returned incorrect double value", 2147483647.0, new Integer(2147483647)
+ .doubleValue());
+ assertEquals("Returned incorrect double value", -2147483647.0, new Integer(-2147483647)
+ .doubleValue());
}
/**
@@ -197,8 +197,8 @@
System.setProperties(tProps);
assertTrue("returned incorrect Integer", Integer.getInteger("testInt")
.equals(new Integer(99)));
- assertTrue("returned incorrect default Integer", Integer
- .getInteger("ff") == null);
+ assertNull("returned incorrect default Integer", Integer
+ .getInteger("ff"));
}
/**
@@ -250,7 +250,7 @@
// Test for method int java.lang.Integer.intValue()
Integer i = new Integer(8900);
- assertTrue("Returned incorrect int value", i.intValue() == 8900);
+ assertEquals("Returned incorrect int value", 8900, i.intValue());
}
/**
@@ -259,7 +259,7 @@
public void test_longValue() {
// Test for method long java.lang.Integer.longValue()
Integer i = new Integer(8900);
- assertTrue("Returned incorrect long value", i.longValue() == 8900L);
+ assertEquals("Returned incorrect long value", 8900L, i.longValue());
}
/**
@@ -269,8 +269,8 @@
// Test for method int java.lang.Integer.parseInt(java.lang.String)
int i = Integer.parseInt("-8900");
- assertTrue("Returned incorrect int", i == -8900);
- assertTrue("Returned incorrect value for 0", Integer.parseInt("0") == 0);
+ assertEquals("Returned incorrect int", -8900, i);
+ assertEquals("Returned incorrect value for 0", 0, Integer.parseInt("0"));
assertTrue("Returned incorrect value for most negative value", Integer
.parseInt("-2147483648") == 0x80000000);
assertTrue("Returned incorrect value for most positive value", Integer
@@ -309,20 +309,20 @@
*/
public void test_parseIntLjava_lang_StringI() {
// Test for method int java.lang.Integer.parseInt(java.lang.String, int)
- assertTrue("Parsed dec val incorrectly",
- Integer.parseInt("-8000", 10) == -8000);
- assertTrue("Parsed hex val incorrectly",
- Integer.parseInt("FF", 16) == 255);
- assertTrue("Parsed oct val incorrectly",
- Integer.parseInt("20", 8) == 16);
- assertTrue("Returned incorrect value for 0 hex", Integer.parseInt("0",
- 16) == 0);
+ assertEquals("Parsed dec val incorrectly",
+ -8000, Integer.parseInt("-8000", 10));
+ assertEquals("Parsed hex val incorrectly",
+ 255, Integer.parseInt("FF", 16));
+ assertEquals("Parsed oct val incorrectly",
+ 16, Integer.parseInt("20", 8));
+ assertEquals("Returned incorrect value for 0 hex", 0, Integer.parseInt("0",
+ 16));
assertTrue("Returned incorrect value for most negative value hex",
Integer.parseInt("-80000000", 16) == 0x80000000);
assertTrue("Returned incorrect value for most positive value hex",
Integer.parseInt("7fffffff", 16) == 0x7fffffff);
- assertTrue("Returned incorrect value for 0 decimal", Integer.parseInt(
- "0", 10) == 0);
+ assertEquals("Returned incorrect value for 0 decimal", 0, Integer.parseInt(
+ "0", 10));
assertTrue("Returned incorrect value for most negative value decimal",
Integer.parseInt("-2147483648", 10) == 0x80000000);
assertTrue("Returned incorrect value for most positive value decimal",
@@ -391,7 +391,7 @@
public void test_shortValue() {
// Test for method short java.lang.Integer.shortValue()
Integer i = new Integer(2147450880);
- assertTrue("Returned incorrect long value", i.shortValue() == -32768);
+ assertEquals("Returned incorrect long value", -32768, i.shortValue());
}
/**
@@ -400,10 +400,10 @@
public void test_toBinaryStringI() {
// Test for method java.lang.String
// java.lang.Integer.toBinaryString(int)
- assertTrue("Incorrect string returned", Integer.toBinaryString(
- Integer.MAX_VALUE).equals("1111111111111111111111111111111"));
- assertTrue("Incorrect string returned", Integer.toBinaryString(
- Integer.MIN_VALUE).equals("10000000000000000000000000000000"));
+ assertEquals("Incorrect string returned", "1111111111111111111111111111111", Integer.toBinaryString(
+ Integer.MAX_VALUE));
+ assertEquals("Incorrect string returned", "10000000000000000000000000000000", Integer.toBinaryString(
+ Integer.MIN_VALUE));
}
/**
@@ -433,10 +433,10 @@
public void test_toOctalStringI() {
// Test for method java.lang.String java.lang.Integer.toOctalString(int)
// Spec states that the int arg is treated as unsigned
- assertTrue("Returned incorrect octal string", Integer.toOctalString(
- Integer.MAX_VALUE).equals("17777777777"));
- assertTrue("Returned incorrect octal string", Integer.toOctalString(
- Integer.MIN_VALUE).equals("20000000000"));
+ assertEquals("Returned incorrect octal string", "17777777777", Integer.toOctalString(
+ Integer.MAX_VALUE));
+ assertEquals("Returned incorrect octal string", "20000000000", Integer.toOctalString(
+ Integer.MIN_VALUE));
}
/**
@@ -447,7 +447,7 @@
Integer i = new Integer(-80001);
- assertTrue("Returned incorrect String", i.toString().equals("-80001"));
+ assertEquals("Returned incorrect String", "-80001", i.toString());
}
/**
@@ -456,14 +456,14 @@
public void test_toStringI() {
// Test for method java.lang.String java.lang.Integer.toString(int)
- assertTrue("Returned incorrect String", Integer.toString(-80765)
- .equals("-80765"));
- assertTrue("Returned incorrect octal string", Integer.toString(
- Integer.MAX_VALUE).equals("2147483647"));
- assertTrue("Returned incorrect octal string", Integer.toString(
- -Integer.MAX_VALUE).equals("-2147483647"));
- assertTrue("Returned incorrect octal string", Integer.toString(
- Integer.MIN_VALUE).equals("-2147483648"));
+ assertEquals("Returned incorrect String", "-80765", Integer.toString(-80765)
+ );
+ assertEquals("Returned incorrect octal string", "2147483647", Integer.toString(
+ Integer.MAX_VALUE));
+ assertEquals("Returned incorrect octal string", "-2147483647", Integer.toString(
+ -Integer.MAX_VALUE));
+ assertEquals("Returned incorrect octal string", "-2147483648", Integer.toString(
+ Integer.MIN_VALUE));
}
/**
@@ -471,37 +471,37 @@
*/
public void test_toStringII() {
// Test for method java.lang.String java.lang.Integer.toString(int, int)
- assertTrue("Returned incorrect octal string", Integer.toString(
- 2147483647, 8).equals("17777777777"));
+ assertEquals("Returned incorrect octal string", "17777777777", Integer.toString(
+ 2147483647, 8));
assertTrue("Returned incorrect hex string--wanted 7fffffff but got: "
+ Integer.toString(2147483647, 16), Integer.toString(
2147483647, 16).equals("7fffffff"));
- assertTrue("Incorrect string returned", Integer.toString(2147483647, 2)
- .equals("1111111111111111111111111111111"));
- assertTrue("Incorrect string returned", Integer
- .toString(2147483647, 10).equals("2147483647"));
+ assertEquals("Incorrect string returned", "1111111111111111111111111111111", Integer.toString(2147483647, 2)
+ );
+ assertEquals("Incorrect string returned", "2147483647", Integer
+ .toString(2147483647, 10));
- assertTrue("Returned incorrect octal string", Integer.toString(
- -2147483647, 8).equals("-17777777777"));
+ assertEquals("Returned incorrect octal string", "-17777777777", Integer.toString(
+ -2147483647, 8));
assertTrue("Returned incorrect hex string--wanted -7fffffff but got: "
+ Integer.toString(-2147483647, 16), Integer.toString(
-2147483647, 16).equals("-7fffffff"));
- assertTrue("Incorrect string returned", Integer
- .toString(-2147483647, 2).equals(
- "-1111111111111111111111111111111"));
- assertTrue("Incorrect string returned", Integer.toString(-2147483647,
- 10).equals("-2147483647"));
+ assertEquals("Incorrect string returned",
+ "-1111111111111111111111111111111", Integer
+ .toString(-2147483647, 2));
+ assertEquals("Incorrect string returned", "-2147483647", Integer.toString(-2147483647,
+ 10));
- assertTrue("Returned incorrect octal string", Integer.toString(
- -2147483648, 8).equals("-20000000000"));
+ assertEquals("Returned incorrect octal string", "-20000000000", Integer.toString(
+ -2147483648, 8));
assertTrue("Returned incorrect hex string--wanted -80000000 but got: "
+ Integer.toString(-2147483648, 16), Integer.toString(
-2147483648, 16).equals("-80000000"));
- assertTrue("Incorrect string returned", Integer
- .toString(-2147483648, 2).equals(
- "-10000000000000000000000000000000"));
- assertTrue("Incorrect string returned", Integer.toString(-2147483648,
- 10).equals("-2147483648"));
+ assertEquals("Incorrect string returned",
+ "-10000000000000000000000000000000", Integer
+ .toString(-2147483648, 2));
+ assertEquals("Incorrect string returned", "-2147483648", Integer.toString(-2147483648,
+ 10));
}
/**
@@ -510,8 +510,8 @@
public void test_valueOfLjava_lang_String() {
// Test for method java.lang.Integer
// java.lang.Integer.valueOf(java.lang.String)
- assertTrue("Returned incorrect int", Integer.valueOf("8888888")
- .intValue() == 8888888);
+ assertEquals("Returned incorrect int", 8888888, Integer.valueOf("8888888")
+ .intValue());
assertTrue("Returned incorrect int", Integer.valueOf("2147483647")
.intValue() == Integer.MAX_VALUE);
assertTrue("Returned incorrect int", Integer.valueOf("-2147483648")
@@ -542,19 +542,19 @@
public void test_valueOfLjava_lang_StringI() {
// Test for method java.lang.Integer
// java.lang.Integer.valueOf(java.lang.String, int)
- assertTrue("Returned incorrect int for hex string", Integer.valueOf(
- "FF", 16).intValue() == 255);
- assertTrue("Returned incorrect int for oct string", Integer.valueOf(
- "20", 8).intValue() == 16);
- assertTrue("Returned incorrect int for bin string", Integer.valueOf(
- "100", 2).intValue() == 4);
-
- assertTrue("Returned incorrect int for - hex string", Integer.valueOf(
- "-FF", 16).intValue() == -255);
- assertTrue("Returned incorrect int for - oct string", Integer.valueOf(
- "-20", 8).intValue() == -16);
- assertTrue("Returned incorrect int for - bin string", Integer.valueOf(
- "-100", 2).intValue() == -4);
+ assertEquals("Returned incorrect int for hex string", 255, Integer.valueOf(
+ "FF", 16).intValue());
+ assertEquals("Returned incorrect int for oct string", 16, Integer.valueOf(
+ "20", 8).intValue());
+ assertEquals("Returned incorrect int for bin string", 4, Integer.valueOf(
+ "100", 2).intValue());
+
+ assertEquals("Returned incorrect int for - hex string", -255, Integer.valueOf(
+ "-FF", 16).intValue());
+ assertEquals("Returned incorrect int for - oct string", -16, Integer.valueOf(
+ "-20", 8).intValue());
+ assertEquals("Returned incorrect int for - bin string", -4, Integer.valueOf(
+ "-100", 2).intValue());
assertTrue("Returned incorrect int", Integer.valueOf("2147483647", 10)
.intValue() == Integer.MAX_VALUE);
assertTrue("Returned incorrect int", Integer.valueOf("-2147483648", 10)
Modified: incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/tests/api/java/lang/InternalErrorTest.java
URL: http://svn.apache.org/viewcvs/incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/tests/api/java/lang/InternalErrorTest.java?rev=397123&r1=397122&r2=397123&view=diff
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/tests/api/java/lang/InternalErrorTest.java (original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/tests/api/java/lang/InternalErrorTest.java Wed Apr 26 00:12:16 2006
@@ -41,8 +41,8 @@
if (true)
throw new InternalError("Test");
} catch (InternalError e) {
- assertTrue("Returned incorrect message", e.getMessage().equals(
- "Test"));
+ assertEquals("Returned incorrect message",
+ "Test", e.getMessage());
return;
}
fail("Failed to throw Runtime Exception");
Modified: incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/tests/api/java/lang/LinkageErrorTest.java
URL: http://svn.apache.org/viewcvs/incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/tests/api/java/lang/LinkageErrorTest.java?rev=397123&r1=397122&r2=397123&view=diff
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/tests/api/java/lang/LinkageErrorTest.java (original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/tests/api/java/lang/LinkageErrorTest.java Wed Apr 26 00:12:16 2006
@@ -27,8 +27,8 @@
}
fail("Error not thrown.");
} catch (LinkageError e) {
- assertTrue("Error not initialized.", e.toString().equals(
- "java.lang.LinkageError"));
+ assertEquals("Error not initialized.",
+ "java.lang.LinkageError", e.toString());
}
}
Modified: incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/tests/api/java/lang/LongTest.java
URL: http://svn.apache.org/viewcvs/incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/tests/api/java/lang/LongTest.java?rev=397123&r1=397122&r2=397123&view=diff
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/tests/api/java/lang/LongTest.java (original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/tests/api/java/lang/LongTest.java Wed Apr 26 00:12:16 2006
@@ -27,7 +27,7 @@
// Test for method java.lang.Long(long)
Long l = new Long(-8900000006L);
- assertTrue("Created incorrect Long", l.longValue() == -8900000006L);
+ assertEquals("Created incorrect Long", -8900000006L, l.longValue());
}
/**
@@ -37,7 +37,7 @@
// Test for method java.lang.Long(java.lang.String)
Long l = new Long("-8900000006");
- assertTrue("Created incorrect Long", l.longValue() == -8900000006L);
+ assertEquals("Created incorrect Long", -8900000006L, l.longValue());
}
/**
@@ -46,9 +46,9 @@
public void test_byteValue() {
// Test for method byte java.lang.Long.byteValue()
Long l = new Long(127);
- assertTrue("Returned incorrect byte value", l.byteValue() == 127);
- assertTrue("Returned incorrect byte value", new Long(Long.MAX_VALUE)
- .byteValue() == -1);
+ assertEquals("Returned incorrect byte value", 127, l.byteValue());
+ assertEquals("Returned incorrect byte value", -1, new Long(Long.MAX_VALUE)
+ .byteValue());
}
/**
@@ -58,8 +58,8 @@
// Test for method int java.lang.Long.compareTo(java.lang.Long)
assertTrue("-2 compared to 1 gave non-negative answer", new Long(-2L)
.compareTo(new Long(1L)) < 0);
- assertTrue("-2 compared to -2 gave non-zero answer", new Long(-2L)
- .compareTo(new Long(-2L)) == 0);
+ assertEquals("-2 compared to -2 gave non-zero answer", 0, new Long(-2L)
+ .compareTo(new Long(-2L)));
assertTrue("3 compared to 2 gave non-positive answer", new Long(3L)
.compareTo(new Long(2L)) > 0);
@@ -76,14 +76,14 @@
public void test_decodeLjava_lang_String() {
// Test for method java.lang.Long
// java.lang.Long.decode(java.lang.String)
- assertTrue("Returned incorrect value for hex string", Long.decode(
- "0xFF").longValue() == 255L);
- assertTrue("Returned incorrect value for dec string", Long.decode(
- "-89000").longValue() == -89000L);
- assertTrue("Returned incorrect value for 0 decimal", Long.decode("0")
- .longValue() == 0);
- assertTrue("Returned incorrect value for 0 hex", Long.decode("0x0")
- .longValue() == 0);
+ assertEquals("Returned incorrect value for hex string", 255L, Long.decode(
+ "0xFF").longValue());
+ assertEquals("Returned incorrect value for dec string", -89000L, Long.decode(
+ "-89000").longValue());
+ assertEquals("Returned incorrect value for 0 decimal", 0, Long.decode("0")
+ .longValue());
+ assertEquals("Returned incorrect value for 0 hex", 0, Long.decode("0x0")
+ .longValue());
assertTrue(
"Returned incorrect value for most negative value decimal",
Long.decode("-9223372036854775808").longValue() == 0x8000000000000000L);
@@ -162,8 +162,8 @@
public void test_doubleValue() {
// Test for method double java.lang.Long.doubleValue()
Long l = new Long(10000000);
- assertTrue("Returned incorrect double value",
- l.doubleValue() == 10000000.0);
+ assertEquals("Returned incorrect double value",
+ 10000000.0, l.doubleValue());
}
@@ -200,8 +200,8 @@
System.setProperties(tProps);
assertTrue("returned incorrect Long", Long.getLong("testLong").equals(
new Long(99)));
- assertTrue("returned incorrect default Long",
- Long.getLong("ff") == null);
+ assertNull("returned incorrect default Long",
+ Long.getLong("ff"));
}
/**
@@ -255,9 +255,9 @@
public void test_intValue() {
// Test for method int java.lang.Long.intValue()
Long l = new Long(100000);
- assertTrue("Returned incorrect int value", l.intValue() == 100000);
- assertTrue("Returned incorrect int value", new Long(Long.MAX_VALUE)
- .intValue() == -1);
+ assertEquals("Returned incorrect int value", 100000, l.intValue());
+ assertEquals("Returned incorrect int value", -1, new Long(Long.MAX_VALUE)
+ .intValue());
}
/**
@@ -266,8 +266,8 @@
public void test_longValue() {
// Test for method long java.lang.Long.longValue()
Long l = new Long(89000000005L);
- assertTrue("Returned incorrect long value",
- l.longValue() == 89000000005L);
+ assertEquals("Returned incorrect long value",
+ 89000000005L, l.longValue());
}
/**
@@ -277,8 +277,8 @@
// Test for method long java.lang.Long.parseLong(java.lang.String)
long l = Long.parseLong("89000000005");
- assertTrue("Parsed to incorrect long value", l == 89000000005L);
- assertTrue("Returned incorrect value for 0", Long.parseLong("0") == 0);
+ assertEquals("Parsed to incorrect long value", 89000000005L, l);
+ assertEquals("Returned incorrect value for 0", 0, Long.parseLong("0"));
assertTrue("Returned incorrect value for most negative value", Long
.parseLong("-9223372036854775808") == 0x8000000000000000L);
assertTrue("Returned incorrect value for most positive value", Long
@@ -308,21 +308,21 @@
*/
public void test_parseLongLjava_lang_StringI() {
// Test for method long java.lang.Long.parseLong(java.lang.String, int)
- assertTrue("Returned incorrect value",
- Long.parseLong("100000000", 10) == 100000000L);
- assertTrue("Returned incorrect value from hex string", Long.parseLong(
- "FFFFFFFFF", 16) == 68719476735L);
+ assertEquals("Returned incorrect value",
+ 100000000L, Long.parseLong("100000000", 10));
+ assertEquals("Returned incorrect value from hex string", 68719476735L, Long.parseLong(
+ "FFFFFFFFF", 16));
assertTrue("Returned incorrect value from octal string: "
+ Long.parseLong("77777777777"), Long.parseLong("77777777777",
8) == 8589934591L);
- assertTrue("Returned incorrect value for 0 hex", Long
- .parseLong("0", 16) == 0);
+ assertEquals("Returned incorrect value for 0 hex", 0, Long
+ .parseLong("0", 16));
assertTrue("Returned incorrect value for most negative value hex", Long
.parseLong("-8000000000000000", 16) == 0x8000000000000000L);
assertTrue("Returned incorrect value for most positive value hex", Long
.parseLong("7fffffffffffffff", 16) == 0x7fffffffffffffffL);
- assertTrue("Returned incorrect value for 0 decimal", Long.parseLong(
- "0", 10) == 0);
+ assertEquals("Returned incorrect value for 0 decimal", 0, Long.parseLong(
+ "0", 10));
assertTrue(
"Returned incorrect value for most negative value decimal",
Long.parseLong("-9223372036854775808", 10) == 0x8000000000000000L);
@@ -393,9 +393,9 @@
public void test_shortValue() {
// Test for method short java.lang.Long.shortValue()
Long l = new Long(10000);
- assertTrue("Returned incorrect short value", l.shortValue() == 10000);
- assertTrue("Returned incorrect short value", new Long(Long.MAX_VALUE)
- .shortValue() == -1);
+ assertEquals("Returned incorrect short value", 10000, l.shortValue());
+ assertEquals("Returned incorrect short value", -1, new Long(Long.MAX_VALUE)
+ .shortValue());
}
/**
@@ -403,20 +403,18 @@
*/
public void test_toBinaryStringJ() {
// Test for method java.lang.String java.lang.Long.toBinaryString(long)
- assertTrue("Incorrect binary string returned", Long.toBinaryString(
- 890000L).equals("11011001010010010000"));
- assertTrue(
- "Incorrect binary string returned",
- Long
+ assertEquals("Incorrect binary string returned", "11011001010010010000", Long.toBinaryString(
+ 890000L));
+ assertEquals("Incorrect binary string returned",
+
+ "1000000000000000000000000000000000000000000000000000000000000000", Long
.toBinaryString(Long.MIN_VALUE)
- .equals(
- "1000000000000000000000000000000000000000000000000000000000000000"));
- assertTrue(
- "Incorrect binary string returned",
- Long
+ );
+ assertEquals("Incorrect binary string returned",
+
+ "111111111111111111111111111111111111111111111111111111111111111", Long
.toBinaryString(Long.MAX_VALUE)
- .equals(
- "111111111111111111111111111111111111111111111111111111111111111"));
+ );
}
/**
@@ -424,12 +422,12 @@
*/
public void test_toHexStringJ() {
// Test for method java.lang.String java.lang.Long.toHexString(long)
- assertTrue("Incorrect hex string returned", Long.toHexString(89000005L)
- .equals("54e0845"));
- assertTrue("Incorrect hex string returned", Long.toHexString(
- Long.MIN_VALUE).equals("8000000000000000"));
- assertTrue("Incorrect hex string returned", Long.toHexString(
- Long.MAX_VALUE).equals("7fffffffffffffff"));
+ assertEquals("Incorrect hex string returned", "54e0845", Long.toHexString(89000005L)
+ );
+ assertEquals("Incorrect hex string returned", "8000000000000000", Long.toHexString(
+ Long.MIN_VALUE));
+ assertEquals("Incorrect hex string returned", "7fffffffffffffff", Long.toHexString(
+ Long.MAX_VALUE));
}
/**
@@ -437,12 +435,12 @@
*/
public void test_toOctalStringJ() {
// Test for method java.lang.String java.lang.Long.toOctalString(long)
- assertTrue("Returned incorrect oct string", Long.toOctalString(
- 8589934591L).equals("77777777777"));
- assertTrue("Returned incorrect oct string", Long.toOctalString(
- Long.MIN_VALUE).equals("1000000000000000000000"));
- assertTrue("Returned incorrect oct string", Long.toOctalString(
- Long.MAX_VALUE).equals("777777777777777777777"));
+ assertEquals("Returned incorrect oct string", "77777777777", Long.toOctalString(
+ 8589934591L));
+ assertEquals("Returned incorrect oct string", "1000000000000000000000", Long.toOctalString(
+ Long.MIN_VALUE));
+ assertEquals("Returned incorrect oct string", "777777777777777777777", Long.toOctalString(
+ Long.MAX_VALUE));
}
/**
@@ -451,12 +449,12 @@
public void test_toString() {
// Test for method java.lang.String java.lang.Long.toString()
Long l = new Long(89000000005L);
- assertTrue("Returned incorrect String", l.toString().equals(
- "89000000005"));
- assertTrue("Returned incorrect String", new Long(Long.MIN_VALUE)
- .toString().equals("-9223372036854775808"));
- assertTrue("Returned incorrect String", new Long(Long.MAX_VALUE)
- .toString().equals("9223372036854775807"));
+ assertEquals("Returned incorrect String",
+ "89000000005", l.toString());
+ assertEquals("Returned incorrect String", "-9223372036854775808", new Long(Long.MIN_VALUE)
+ .toString());
+ assertEquals("Returned incorrect String", "9223372036854775807", new Long(Long.MAX_VALUE)
+ .toString());
}
/**
@@ -465,12 +463,12 @@
public void test_toStringJ() {
// Test for method java.lang.String java.lang.Long.toString(long)
- assertTrue("Returned incorrect String", Long.toString(89000000005L)
- .equals("89000000005"));
- assertTrue("Returned incorrect String", Long.toString(Long.MIN_VALUE)
- .equals("-9223372036854775808"));
- assertTrue("Returned incorrect String", Long.toString(Long.MAX_VALUE)
- .equals("9223372036854775807"));
+ assertEquals("Returned incorrect String", "89000000005", Long.toString(89000000005L)
+ );
+ assertEquals("Returned incorrect String", "-9223372036854775808", Long.toString(Long.MIN_VALUE)
+ );
+ assertEquals("Returned incorrect String", "9223372036854775807", Long.toString(Long.MAX_VALUE)
+ );
}
/**
@@ -478,23 +476,23 @@
*/
public void test_toStringJI() {
// Test for method java.lang.String java.lang.Long.toString(long, int)
- assertTrue("Returned incorrect dec string", Long.toString(100000000L,
- 10).equals("100000000"));
- assertTrue("Returned incorrect hex string", Long.toString(68719476735L,
- 16).equals("fffffffff"));
- assertTrue("Returned incorrect oct string", Long.toString(8589934591L,
- 8).equals("77777777777"));
- assertTrue("Returned incorrect bin string", Long.toString(
- 8796093022207L, 2).equals(
- "1111111111111111111111111111111111111111111"));
- assertTrue("Returned incorrect min string", Long.toString(
- 0x8000000000000000L, 10).equals("-9223372036854775808"));
- assertTrue("Returned incorrect max string", Long.toString(
- 0x7fffffffffffffffL, 10).equals("9223372036854775807"));
- assertTrue("Returned incorrect min string", Long.toString(
- 0x8000000000000000L, 16).equals("-8000000000000000"));
- assertTrue("Returned incorrect max string", Long.toString(
- 0x7fffffffffffffffL, 16).equals("7fffffffffffffff"));
+ assertEquals("Returned incorrect dec string", "100000000", Long.toString(100000000L,
+ 10));
+ assertEquals("Returned incorrect hex string", "fffffffff", Long.toString(68719476735L,
+ 16));
+ assertEquals("Returned incorrect oct string", "77777777777", Long.toString(8589934591L,
+ 8));
+ assertEquals("Returned incorrect bin string",
+ "1111111111111111111111111111111111111111111", Long.toString(
+ 8796093022207L, 2));
+ assertEquals("Returned incorrect min string", "-9223372036854775808", Long.toString(
+ 0x8000000000000000L, 10));
+ assertEquals("Returned incorrect max string", "9223372036854775807", Long.toString(
+ 0x7fffffffffffffffL, 10));
+ assertEquals("Returned incorrect min string", "-8000000000000000", Long.toString(
+ 0x8000000000000000L, 16));
+ assertEquals("Returned incorrect max string", "7fffffffffffffff", Long.toString(
+ 0x7fffffffffffffffL, 16));
}
/**
@@ -503,8 +501,8 @@
public void test_valueOfLjava_lang_String() {
// Test for method java.lang.Long
// java.lang.Long.valueOf(java.lang.String)
- assertTrue("Returned incorrect value", Long.valueOf("100000000")
- .longValue() == 100000000L);
+ assertEquals("Returned incorrect value", 100000000L, Long.valueOf("100000000")
+ .longValue());
assertTrue("Returned incorrect value", Long.valueOf(
"9223372036854775807").longValue() == Long.MAX_VALUE);
assertTrue("Returned incorrect value", Long.valueOf(
@@ -548,10 +546,10 @@
public void test_valueOfLjava_lang_StringI() {
// Test for method java.lang.Long
// java.lang.Long.valueOf(java.lang.String, int)
- assertTrue("Returned incorrect value", Long.valueOf("100000000", 10)
- .longValue() == 100000000L);
- assertTrue("Returned incorrect value from hex string", Long.valueOf(
- "FFFFFFFFF", 16).longValue() == 68719476735L);
+ assertEquals("Returned incorrect value", 100000000L, Long.valueOf("100000000", 10)
+ .longValue());
+ assertEquals("Returned incorrect value from hex string", 68719476735L, Long.valueOf(
+ "FFFFFFFFF", 16).longValue());
assertTrue("Returned incorrect value from octal string: "
+ Long.valueOf("77777777777", 8).toString(), Long.valueOf(
"77777777777", 8).longValue() == 8589934591L);
Modified: incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/tests/api/java/lang/MathTest.java
URL: http://svn.apache.org/viewcvs/incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/tests/api/java/lang/MathTest.java?rev=397123&r1=397122&r2=397123&view=diff
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/tests/api/java/lang/MathTest.java (original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/tests/api/java/lang/MathTest.java Wed Apr 26 00:12:16 2006
@@ -118,8 +118,10 @@
*/
public void test_ceilD() {
// Test for method double java.lang.Math.ceil(double)
- assertTrue("Incorrect ceiling for double", Math.ceil(78.89) == 79);
- assertTrue("Incorrect ceiling for double", Math.ceil(-78.89) == -78);
+ assertEquals("Incorrect ceiling for double",
+ 79, Math.ceil(78.89), 0);
+ assertEquals("Incorrect ceiling for double",
+ -78, Math.ceil(-78.89), 0);
}
/**
@@ -127,8 +129,8 @@
*/
public void test_cosD() {
// Test for method double java.lang.Math.cos(double)
- assertTrue("Incorrect answer", Math.cos(0) == 1.0);
- assertTrue("Incorrect answer", Math.cos(1) == 0.5403023058681398);
+ assertEquals("Incorrect answer", 1.0, Math.cos(0));
+ assertEquals("Incorrect answer", 0.5403023058681398, Math.cos(1));
}
/**
@@ -148,8 +150,10 @@
*/
public void test_floorD() {
// Test for method double java.lang.Math.floor(double)
- assertTrue("Incorrect floor for double", Math.floor(78.89) == 78);
- assertTrue("Incorrect floor for double", Math.floor(-78.89) == -79);
+ assertEquals("Incorrect floor for double",
+ 78, Math.floor(78.89), 0);
+ assertEquals("Incorrect floor for double",
+ -79, Math.floor(-78.89), 0);
}
/**
@@ -157,8 +161,8 @@
*/
public void test_IEEEremainderDD() {
// Test for method double java.lang.Math.IEEEremainder(double, double)
- assertTrue("Incorrect remainder returned",
- Math.IEEEremainder(1.0, 1.0) == 0.0);
+ assertEquals("Incorrect remainder returned",
+ 0.0, Math.IEEEremainder(1.0, 1.0));
assertTrue("Incorrect remainder returned", Math.IEEEremainder(1.32,
89.765) >= 1.4705063220631647E-2
|| Math.IEEEremainder(1.32, 89.765) >= 1.4705063220631649E-2);
@@ -182,12 +186,12 @@
*/
public void test_maxDD() {
// Test for method double java.lang.Math.max(double, double)
- assertTrue("Incorrect double max value", Math.max(-1908897.6000089,
- 1908897.6000089) == 1908897.6000089);
- assertTrue("Incorrect double max value",
- Math.max(2.0, 1908897.6000089) == 1908897.6000089);
- assertTrue("Incorrect double max value", Math.max(-2.0,
- -1908897.6000089) == -2.0);
+ assertEquals("Incorrect double max value", 1908897.6000089, Math.max(-1908897.6000089,
+ 1908897.6000089));
+ assertEquals("Incorrect double max value",
+ 1908897.6000089, Math.max(2.0, 1908897.6000089));
+ assertEquals("Incorrect double max value", -2.0, Math.max(-2.0,
+ -1908897.6000089));
}
@@ -209,11 +213,11 @@
*/
public void test_maxII() {
// Test for method int java.lang.Math.max(int, int)
- assertTrue("Incorrect int max value",
- Math.max(-19088976, 19088976) == 19088976);
- assertTrue("Incorrect int max value",
- Math.max(20, 19088976) == 19088976);
- assertTrue("Incorrect int max value", Math.max(-20, -19088976) == -20);
+ assertEquals("Incorrect int max value",
+ 19088976, Math.max(-19088976, 19088976));
+ assertEquals("Incorrect int max value",
+ 19088976, Math.max(20, 19088976));
+ assertEquals("Incorrect int max value", -20, Math.max(-20, -19088976));
}
/**
@@ -221,12 +225,12 @@
*/
public void test_maxJJ() {
// Test for method long java.lang.Math.max(long, long)
- assertTrue("Incorrect long max value", Math.max(-19088976000089L,
- 19088976000089L) == 19088976000089L);
- assertTrue("Incorrect long max value",
- Math.max(20, 19088976000089L) == 19088976000089L);
- assertTrue("Incorrect long max value",
- Math.max(-20, -19088976000089L) == -20);
+ assertEquals("Incorrect long max value", 19088976000089L, Math.max(-19088976000089L,
+ 19088976000089L));
+ assertEquals("Incorrect long max value",
+ 19088976000089L, Math.max(20, 19088976000089L));
+ assertEquals("Incorrect long max value",
+ -20, Math.max(-20, -19088976000089L));
}
/**
@@ -234,12 +238,12 @@
*/
public void test_minDD() {
// Test for method double java.lang.Math.min(double, double)
- assertTrue("Incorrect double min value", Math.min(-1908897.6000089,
- 1908897.6000089) == -1908897.6000089);
- assertTrue("Incorrect double min value",
- Math.min(2.0, 1908897.6000089) == 2.0);
- assertTrue("Incorrect double min value", Math.min(-2.0,
- -1908897.6000089) == -1908897.6000089);
+ assertEquals("Incorrect double min value", -1908897.6000089, Math.min(-1908897.6000089,
+ 1908897.6000089));
+ assertEquals("Incorrect double min value",
+ 2.0, Math.min(2.0, 1908897.6000089));
+ assertEquals("Incorrect double min value", -1908897.6000089, Math.min(-2.0,
+ -1908897.6000089));
}
/**
@@ -260,11 +264,11 @@
*/
public void test_minII() {
// Test for method int java.lang.Math.min(int, int)
- assertTrue("Incorrect int min value",
- Math.min(-19088976, 19088976) == -19088976);
- assertTrue("Incorrect int min value", Math.min(20, 19088976) == 20);
- assertTrue("Incorrect int min value",
- Math.min(-20, -19088976) == -19088976);
+ assertEquals("Incorrect int min value",
+ -19088976, Math.min(-19088976, 19088976));
+ assertEquals("Incorrect int min value", 20, Math.min(20, 19088976));
+ assertEquals("Incorrect int min value",
+ -19088976, Math.min(-20, -19088976));
}
@@ -273,12 +277,12 @@
*/
public void test_minJJ() {
// Test for method long java.lang.Math.min(long, long)
- assertTrue("Incorrect long min value", Math.min(-19088976000089L,
- 19088976000089L) == -19088976000089L);
- assertTrue("Incorrect long min value",
- Math.min(20, 19088976000089L) == 20);
- assertTrue("Incorrect long min value",
- Math.min(-20, -19088976000089L) == -19088976000089L);
+ assertEquals("Incorrect long min value", -19088976000089L, Math.min(-19088976000089L,
+ 19088976000089L));
+ assertEquals("Incorrect long min value",
+ 20, Math.min(20, 19088976000089L));
+ assertEquals("Incorrect long min value",
+ -19088976000089L, Math.min(-20, -19088976000089L));
}
/**
@@ -290,8 +294,8 @@
(long) Math.pow(2, 8) == 256l);
assertTrue("pow returned incorrect value",
Math.pow(2, -8) == 0.00390625d);
- assertTrue("Incorrect root returned1", Math.sqrt(Math.pow(Math.sqrt(2),
- 4)) == 2);
+ assertEquals("Incorrect root returned1",
+ 2, Math.sqrt(Math.pow(Math.sqrt(2), 4)), 0);
}
/**
@@ -299,12 +303,12 @@
*/
public void test_rintD() {
// Test for method double java.lang.Math.rint(double)
- assertTrue("Failed to round properly - up to odd",
- Math.rint(2.9) == 3.0);
+ assertEquals("Failed to round properly - up to odd",
+ 3.0, Math.rint(2.9));
assertTrue("Failed to round properly - NaN", Double.isNaN(Math
.rint(Double.NaN)));
- assertTrue("Failed to round properly down to even",
- Math.rint(2.1) == 2.0);
+ assertEquals("Failed to round properly down to even",
+ 2.0, Math.rint(2.1));
assertTrue("Failed to round properly " + 2.5 + " to even", Math
.rint(2.5) == 2.0);
}
@@ -314,7 +318,7 @@
*/
public void test_roundD() {
// Test for method long java.lang.Math.round(double)
- assertTrue("Incorrect rounding of a float", Math.round(-90.89d) == -91);
+ assertEquals("Incorrect rounding of a float", -91, Math.round(-90.89d));
}
/**
@@ -322,7 +326,7 @@
*/
public void test_roundF() {
// Test for method int java.lang.Math.round(float)
- assertTrue("Incorrect rounding of a float", Math.round(-90.89f) == -91);
+ assertEquals("Incorrect rounding of a float", -91, Math.round(-90.89f));
}
/**
@@ -330,8 +334,8 @@
*/
public void test_sinD() {
// Test for method double java.lang.Math.sin(double)
- assertTrue("Incorrect answer", Math.sin(0) == 0.0);
- assertTrue("Incorrect answer", Math.sin(1) == 0.8414709848078965);
+ assertEquals("Incorrect answer", 0.0, Math.sin(0));
+ assertEquals("Incorrect answer", 0.8414709848078965, Math.sin(1));
}
/**
@@ -339,7 +343,7 @@
*/
public void test_sqrtD() {
// Test for method double java.lang.Math.sqrt(double)
- assertTrue("Incorrect root returned2", Math.sqrt(49) == 7);
+ assertEquals("Incorrect root returned2", 7, Math.sqrt(49), 0);
}
/**
@@ -347,8 +351,8 @@
*/
public void test_tanD() {
// Test for method double java.lang.Math.tan(double)
- assertTrue("Incorrect answer", Math.tan(0) == 0.0);
- assertTrue("Incorrect answer", Math.tan(1) == 1.5574077246549023);
+ assertEquals("Incorrect answer", 0.0, Math.tan(0));
+ assertEquals("Incorrect answer", 1.5574077246549023, Math.tan(1));
}
@@ -357,10 +361,10 @@
*/
public void test_random() {
// There isn't a place for these tests so just stick them here
- assertTrue("Wrong value E",
- Double.doubleToLongBits(Math.E) == 4613303445314885481L);
- assertTrue("Wrong value PI",
- Double.doubleToLongBits(Math.PI) == 4614256656552045848L);
+ assertEquals("Wrong value E",
+ 4613303445314885481L, Double.doubleToLongBits(Math.E));
+ assertEquals("Wrong value PI",
+ 4614256656552045848L, Double.doubleToLongBits(Math.PI));
for (int i = 500; i >= 0; i--) {
double d = Math.random();
Modified: incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/tests/api/java/lang/NoClassDefFoundErrorTest.java
URL: http://svn.apache.org/viewcvs/incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/tests/api/java/lang/NoClassDefFoundErrorTest.java?rev=397123&r1=397122&r2=397123&view=diff
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/tests/api/java/lang/NoClassDefFoundErrorTest.java (original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/tests/api/java/lang/NoClassDefFoundErrorTest.java Wed Apr 26 00:12:16 2006
@@ -27,8 +27,8 @@
}
fail("Error not thrown.");
} catch (NoClassDefFoundError e) {
- assertTrue("Error not intitialized.", e.toString().equals(
- "java.lang.NoClassDefFoundError"));
+ assertEquals("Error not intitialized.",
+ "java.lang.NoClassDefFoundError", e.toString());
}
}
Modified: incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/tests/api/java/lang/NoSuchFieldErrorTest.java
URL: http://svn.apache.org/viewcvs/incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/tests/api/java/lang/NoSuchFieldErrorTest.java?rev=397123&r1=397122&r2=397123&view=diff
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/tests/api/java/lang/NoSuchFieldErrorTest.java (original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/tests/api/java/lang/NoSuchFieldErrorTest.java Wed Apr 26 00:12:16 2006
@@ -25,9 +25,9 @@
if (true)
throw new NoSuchFieldError();
} catch (NoSuchFieldError e) {
- assertTrue("Initializer failed.", e.getMessage() == null);
- assertTrue("To string failed.", e.toString().equals(
- "java.lang.NoSuchFieldError"));
+ assertNull("Initializer failed.", e.getMessage());
+ assertEquals("To string failed.",
+ "java.lang.NoSuchFieldError", e.toString());
}
}
Modified: incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/tests/api/java/lang/NoSuchMethodErrorTest.java
URL: http://svn.apache.org/viewcvs/incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/tests/api/java/lang/NoSuchMethodErrorTest.java?rev=397123&r1=397122&r2=397123&view=diff
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/tests/api/java/lang/NoSuchMethodErrorTest.java (original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/tests/api/java/lang/NoSuchMethodErrorTest.java Wed Apr 26 00:12:16 2006
@@ -25,9 +25,9 @@
if (true)
throw new NoSuchMethodError();
} catch (NoSuchMethodError e) {
- assertTrue("Initializer failed.", e.getMessage() == null);
- assertTrue("To string failed.", e.toString().equals(
- "java.lang.NoSuchMethodError"));
+ assertNull("Initializer failed.", e.getMessage());
+ assertEquals("To string failed.",
+ "java.lang.NoSuchMethodError", e.toString());
}
}
Modified: incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/tests/api/java/lang/ObjectTest.java
URL: http://svn.apache.org/viewcvs/incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/tests/api/java/lang/ObjectTest.java?rev=397123&r1=397122&r2=397123&view=diff
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/tests/api/java/lang/ObjectTest.java (original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/tests/api/java/lang/ObjectTest.java Wed Apr 26 00:12:16 2006
@@ -35,7 +35,7 @@
*/
public void test_Constructor() {
// Test for method java.lang.Object()
- assertTrue("Constructor failed !!!", new Object() != null);
+ assertNotNull("Constructor failed !!!", new Object());
}
/**
@@ -232,7 +232,7 @@
*/
public void test_toString() {
// Test for method java.lang.String java.lang.Object.toString()
- assertTrue("Object toString returned null.", obj1.toString() != null);
+ assertNotNull("Object toString returned null.", obj1.toString());
}
/**
Modified: incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/tests/api/java/lang/PackageTest.java
URL: http://svn.apache.org/viewcvs/incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/tests/api/java/lang/PackageTest.java?rev=397123&r1=397122&r2=397123&view=diff
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/tests/api/java/lang/PackageTest.java (original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/tests/api/java/lang/PackageTest.java Wed Apr 26 00:12:16 2006
@@ -54,28 +54,22 @@
urls[0] = resourceURL;
ucl = new java.net.URLClassLoader(urls, null);
c = Class.forName("p.C", true, ucl);
- assertTrue(
- "Package getImplementationTitle returns a wrong string (1)",
- c.getPackage().getImplementationTitle().equals(
- "p Implementation-Title"));
- assertTrue(
- "Package getImplementationVendor returns a wrong string (1)",
- c.getPackage().getImplementationVendor().equals(
- "p Implementation-Vendor"));
- assertTrue(
- "Package getImplementationVersion returns a wrong string (1)",
- c.getPackage().getImplementationVersion().equals("2.2.2"));
- assertTrue(
- "Package getSpecificationTitle returns a wrong string (1)",
- c.getPackage().getSpecificationTitle().equals(
- "p Specification-Title"));
- assertTrue(
- "Package getSpecificationVendor returns a wrong string (1)",
- c.getPackage().getSpecificationVendor().equals(
- "p Specification-Vendor"));
- assertTrue(
- "Package getSpecificationVersion returns a wrong string (1)",
- c.getPackage().getSpecificationVersion().equals("2.2.2"));
+ assertEquals("Package getImplementationTitle returns a wrong string (1)",
+
+ "p Implementation-Title", c.getPackage().getImplementationTitle());
+ assertEquals("Package getImplementationVendor returns a wrong string (1)",
+
+ "p Implementation-Vendor", c.getPackage().getImplementationVendor());
+ assertEquals("Package getImplementationVersion returns a wrong string (1)",
+ "2.2.2", c.getPackage().getImplementationVersion());
+ assertEquals("Package getSpecificationTitle returns a wrong string (1)",
+
+ "p Specification-Title", c.getPackage().getSpecificationTitle());
+ assertEquals("Package getSpecificationVendor returns a wrong string (1)",
+
+ "p Specification-Vendor", c.getPackage().getSpecificationVendor());
+ assertEquals("Package getSpecificationVersion returns a wrong string (1)",
+ "2.2.2", c.getPackage().getSpecificationVersion());
} catch (Exception e) {
fail("Exception during helperAttributes test : " + e.getMessage());
}
@@ -88,28 +82,22 @@
urls[0] = resourceURL;
ucl = new java.net.URLClassLoader(urls, null);
c = Class.forName("p.C", true, ucl);
- assertTrue(
- "Package getImplementationTitle returns a wrong string (2)",
- c.getPackage().getImplementationTitle().equals(
- "MF Implementation-Title"));
- assertTrue(
- "Package getImplementationVendor returns a wrong string (2)",
- c.getPackage().getImplementationVendor().equals(
- "MF Implementation-Vendor"));
- assertTrue(
- "Package getImplementationVersion returns a wrong string (2)",
- c.getPackage().getImplementationVersion().equals("5.3.b1"));
- assertTrue(
- "Package getSpecificationTitle returns a wrong string (2)",
- c.getPackage().getSpecificationTitle().equals(
- "MF Specification-Title"));
- assertTrue(
- "Package getSpecificationVendor returns a wrong string (2)",
- c.getPackage().getSpecificationVendor().equals(
- "MF Specification-Vendor"));
- assertTrue(
- "Package getSpecificationVersion returns a wrong string (2)",
- c.getPackage().getSpecificationVersion().equals("1.2.3"));
+ assertEquals("Package getImplementationTitle returns a wrong string (2)",
+
+ "MF Implementation-Title", c.getPackage().getImplementationTitle());
+ assertEquals("Package getImplementationVendor returns a wrong string (2)",
+
+ "MF Implementation-Vendor", c.getPackage().getImplementationVendor());
+ assertEquals("Package getImplementationVersion returns a wrong string (2)",
+ "5.3.b1", c.getPackage().getImplementationVersion());
+ assertEquals("Package getSpecificationTitle returns a wrong string (2)",
+
+ "MF Specification-Title", c.getPackage().getSpecificationTitle());
+ assertEquals("Package getSpecificationVendor returns a wrong string (2)",
+
+ "MF Specification-Vendor", c.getPackage().getSpecificationVendor());
+ assertEquals("Package getSpecificationVersion returns a wrong string (2)",
+ "1.2.3", c.getPackage().getSpecificationVersion());
} catch (Exception e) {
fail("Exception in helperAttributes test : " + e.getMessage());
}
@@ -123,28 +111,22 @@
urls[0] = resourceURL;
ucl = new java.net.URLClassLoader(urls, null);
c = Class.forName("p.C", true, ucl);
- assertTrue(
- "Package getImplementationTitle returns a wrong string (3)",
- c.getPackage().getImplementationTitle().equals(
- "MF Implementation-Title"));
- assertTrue(
- "Package getImplementationVendor returns a wrong string (3)",
- c.getPackage().getImplementationVendor().equals(
- "MF Implementation-Vendor"));
- assertTrue(
- "Package getImplementationVersion returns a wrong string (3)",
- c.getPackage().getImplementationVersion().equals("5.3.b1"));
- assertTrue(
- "Package getSpecificationTitle returns a wrong string (3)",
- c.getPackage().getSpecificationTitle().equals(
- "MF Specification-Title"));
- assertTrue(
- "Package getSpecificationVendor returns a wrong string (3)",
- c.getPackage().getSpecificationVendor().equals(
- "MF Specification-Vendor"));
- assertTrue(
- "Package getSpecificationVersion returns a wrong string (3)",
- c.getPackage().getSpecificationVersion().equals("1.2.3"));
+ assertEquals("Package getImplementationTitle returns a wrong string (3)",
+
+ "MF Implementation-Title", c.getPackage().getImplementationTitle());
+ assertEquals("Package getImplementationVendor returns a wrong string (3)",
+
+ "MF Implementation-Vendor", c.getPackage().getImplementationVendor());
+ assertEquals("Package getImplementationVersion returns a wrong string (3)",
+ "5.3.b1", c.getPackage().getImplementationVersion());
+ assertEquals("Package getSpecificationTitle returns a wrong string (3)",
+
+ "MF Specification-Title", c.getPackage().getSpecificationTitle());
+ assertEquals("Package getSpecificationVendor returns a wrong string (3)",
+
+ "MF Specification-Vendor", c.getPackage().getSpecificationVendor());
+ assertEquals("Package getSpecificationVersion returns a wrong string (3)",
+ "1.2.3", c.getPackage().getSpecificationVersion());
} catch (Exception e) {
fail("Exception during helperAttributes test : " + e.getMessage());
}
@@ -158,28 +140,22 @@
urls[0] = resourceURL;
ucl = new java.net.URLClassLoader(urls, null);
c = Class.forName("p.C", true, ucl);
- assertTrue(
- "Package getImplementationTitle returns a wrong string (4)",
- c.getPackage().getImplementationTitle().equals(
- "p Implementation-Title"));
- assertTrue(
- "Package getImplementationVendor returns a wrong string (4)",
- c.getPackage().getImplementationVendor().equals(
- "MF Implementation-Vendor"));
- assertTrue(
- "Package getImplementationVersion returns a wrong string (4)",
- c.getPackage().getImplementationVersion().equals("2.2.2"));
- assertTrue(
- "Package getSpecificationTitle returns a wrong string (4)",
- c.getPackage().getSpecificationTitle().equals(
- "MF Specification-Title"));
- assertTrue(
- "Package getSpecificationVendor returns a wrong string (4)",
- c.getPackage().getSpecificationVendor().equals(
- "p Specification-Vendor"));
- assertTrue(
- "Package getSpecificationVersion returns a wrong string (4)",
- c.getPackage().getSpecificationVersion().equals("2.2.2"));
+ assertEquals("Package getImplementationTitle returns a wrong string (4)",
+
+ "p Implementation-Title", c.getPackage().getImplementationTitle());
+ assertEquals("Package getImplementationVendor returns a wrong string (4)",
+
+ "MF Implementation-Vendor", c.getPackage().getImplementationVendor());
+ assertEquals("Package getImplementationVersion returns a wrong string (4)",
+ "2.2.2", c.getPackage().getImplementationVersion());
+ assertEquals("Package getSpecificationTitle returns a wrong string (4)",
+
+ "MF Specification-Title", c.getPackage().getSpecificationTitle());
+ assertEquals("Package getSpecificationVendor returns a wrong string (4)",
+
+ "p Specification-Vendor", c.getPackage().getSpecificationVendor());
+ assertEquals("Package getSpecificationVersion returns a wrong string (4)",
+ "2.2.2", c.getPackage().getSpecificationVersion());
} catch (Exception e) {
fail("Exception during helperAttributes test : " + e.getMessage());
}
@@ -192,29 +168,23 @@
urls[0] = resourceURL;
ucl = new java.net.URLClassLoader(urls, null);
c = Class.forName("p.q.C", true, ucl);
- assertTrue(
- "Package getImplementationTitle returns a wrong string (5)",
- c.getPackage().getImplementationTitle().equals(
- "p Implementation-Title"));
- assertTrue(
- "Package getImplementationVendor returns a wrong string (5)",
- c.getPackage().getImplementationVendor().equals(
- "p Implementation-Vendor"));
- assertTrue(
- "Package getImplementationVersion returns a wrong string (5)",
- c.getPackage().getImplementationVersion().equals("1.1.3"));
- assertTrue(
- "Package getSpecificationTitle returns a wrong string (5)",
- c.getPackage().getSpecificationTitle().equals(
- "p Specification-Title"));
- assertTrue(
- "Package getSpecificationVendor returns a wrong string (5)",
- c.getPackage().getSpecificationVendor().equals(
- "p Specification-Vendor"));
- assertTrue(
- "Package getSpecificationVersion returns a wrong string (5)",
- c.getPackage().getSpecificationVersion().equals(
- "2.2.0.0.0.0.0.0.0.0.0"));
+ assertEquals("Package getImplementationTitle returns a wrong string (5)",
+
+ "p Implementation-Title", c.getPackage().getImplementationTitle());
+ assertEquals("Package getImplementationVendor returns a wrong string (5)",
+
+ "p Implementation-Vendor", c.getPackage().getImplementationVendor());
+ assertEquals("Package getImplementationVersion returns a wrong string (5)",
+ "1.1.3", c.getPackage().getImplementationVersion());
+ assertEquals("Package getSpecificationTitle returns a wrong string (5)",
+
+ "p Specification-Title", c.getPackage().getSpecificationTitle());
+ assertEquals("Package getSpecificationVendor returns a wrong string (5)",
+
+ "p Specification-Vendor", c.getPackage().getSpecificationVendor());
+ assertEquals("Package getSpecificationVersion returns a wrong string (5)",
+
+ "2.2.0.0.0.0.0.0.0.0.0", c.getPackage().getSpecificationVersion());
} catch (Exception e) {
fail("Exception during helperAttributes test : " + e.getMessage());
@@ -261,8 +231,8 @@
urls[0] = resourceURL;
ucl = new java.net.URLClassLoader(urls, null);
c = Class.forName("p.q.C", true, ucl);
- assertTrue("Package getName returns a wrong string", c.getPackage()
- .getName().equals("p.q"));
+ assertEquals("Package getName returns a wrong string", "p.q", c.getPackage()
+ .getName());
} catch (Exception e) {
fail("Exception during getName test : " + e.getMessage());
Modified: incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/tests/api/java/lang/ProcessTest.java
URL: http://svn.apache.org/viewcvs/incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/tests/api/java/lang/ProcessTest.java?rev=397123&r1=397122&r2=397123&view=diff
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/tests/api/java/lang/ProcessTest.java (original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/tests/api/java/lang/ProcessTest.java Wed Apr 26 00:12:16 2006
@@ -54,7 +54,7 @@
proc.waitFor();
Support_Exec.checkStderr(execArgs);
proc.destroy();
- assertTrue(msg.toString(), msg.toString().equals("true"));
+ assertEquals("true", msg.toString(), msg.toString());
} catch (IOException e) {
fail("IOException executing avail test: " + e);
} catch (InterruptedException e) {
Modified: incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/tests/api/java/lang/RuntimeExceptionTest.java
URL: http://svn.apache.org/viewcvs/incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/tests/api/java/lang/RuntimeExceptionTest.java?rev=397123&r1=397122&r2=397123&view=diff
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/tests/api/java/lang/RuntimeExceptionTest.java (original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/tests/api/java/lang/RuntimeExceptionTest.java Wed Apr 26 00:12:16 2006
@@ -44,8 +44,8 @@
if (true)
throw new RuntimeException("Runtime message");
} catch (RuntimeException e) {
- assertTrue("Incorrect message", e.getMessage().equals(
- "Runtime message"));
+ assertEquals("Incorrect message",
+ "Runtime message", e.getMessage());
return;
}
fail("Failed to throw Runtime Exception");
Modified: incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/tests/api/java/lang/RuntimePermissionTest.java
URL: http://svn.apache.org/viewcvs/incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/tests/api/java/lang/RuntimePermissionTest.java?rev=397123&r1=397122&r2=397123&view=diff
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/tests/api/java/lang/RuntimePermissionTest.java (original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/tests/api/java/lang/RuntimePermissionTest.java Wed Apr 26 00:12:16 2006
@@ -23,8 +23,8 @@
public void test_ConstructorLjava_lang_String() {
// Test for method java.lang.RuntimePermission(java.lang.String)
RuntimePermission r = new RuntimePermission("createClassLoader");
- assertTrue("Returned incorrect name", r.getName().equals(
- "createClassLoader"));
+ assertEquals("Returned incorrect name",
+ "createClassLoader", r.getName());
}
@@ -36,8 +36,8 @@
// Test for method java.lang.RuntimePermission(java.lang.String,
// java.lang.String)
RuntimePermission r = new RuntimePermission("createClassLoader", null);
- assertTrue("Returned incorrect name", r.getName().equals(
- "createClassLoader"));
+ assertEquals("Returned incorrect name",
+ "createClassLoader", r.getName());
}
/**
Modified: incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/tests/api/java/lang/ShortTest.java
URL: http://svn.apache.org/viewcvs/incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/tests/api/java/lang/ShortTest.java?rev=397123&r1=397122&r2=397123&view=diff
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/tests/api/java/lang/ShortTest.java (original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/tests/api/java/lang/ShortTest.java Wed Apr 26 00:12:16 2006
@@ -48,10 +48,10 @@
*/
public void test_byteValue() {
// Test for method byte java.lang.Short.byteValue()
- assertTrue("Returned incorrect byte value", new Short(Short.MIN_VALUE)
- .byteValue() == 0);
- assertTrue("Returned incorrect byte value", new Short(Short.MAX_VALUE)
- .byteValue() == -1);
+ assertEquals("Returned incorrect byte value", 0, new Short(Short.MIN_VALUE)
+ .byteValue());
+ assertEquals("Returned incorrect byte value", -1, new Short(Short.MAX_VALUE)
+ .byteValue());
}
/**
@@ -69,8 +69,8 @@
"Should have returned positive value when compared to lesser short",
s.compareTo(x) > 0);
x = new Short((short) 1);
- assertTrue("Should have returned zero when compared to equal short", s
- .compareTo(x) == 0);
+ assertEquals("Should have returned zero when compared to equal short",
+ 0, s.compareTo(x));
try {
new Short((short)0).compareTo(null);
@@ -152,10 +152,10 @@
*/
public void test_doubleValue() {
// Test for method double java.lang.Short.doubleValue()
- assertTrue("Returned incorrect double value",
- new Short(Short.MIN_VALUE).doubleValue() == -32768.0);
- assertTrue("Returned incorrect double value",
- new Short(Short.MAX_VALUE).doubleValue() == 32767.0);
+ assertEquals("Returned incorrect double value",
+ -32768.0, new Short(Short.MIN_VALUE).doubleValue());
+ assertEquals("Returned incorrect double value",
+ 32767.0, new Short(Short.MAX_VALUE).doubleValue());
}
/**
@@ -196,10 +196,10 @@
*/
public void test_intValue() {
// Test for method int java.lang.Short.intValue()
- assertTrue("Returned incorrect int value", new Short(Short.MIN_VALUE)
- .intValue() == -32768);
- assertTrue("Returned incorrect int value", new Short(Short.MAX_VALUE)
- .intValue() == 32767);
+ assertEquals("Returned incorrect int value", -32768, new Short(Short.MIN_VALUE)
+ .intValue());
+ assertEquals("Returned incorrect int value", 32767, new Short(Short.MAX_VALUE)
+ .intValue());
}
/**
@@ -207,10 +207,10 @@
*/
public void test_longValue() {
// Test for method long java.lang.Short.longValue()
- assertTrue("Returned incorrect long value", new Short(Short.MIN_VALUE)
- .longValue() == -32768);
- assertTrue("Returned incorrect long value", new Short(Short.MAX_VALUE)
- .longValue() == 32767);
+ assertEquals("Returned incorrect long value", -32768, new Short(Short.MIN_VALUE)
+ .longValue());
+ assertEquals("Returned incorrect long value", 32767, new Short(Short.MAX_VALUE)
+ .longValue());
}
/**
@@ -223,7 +223,7 @@
assertTrue("Incorrect parse of short", sp == (short) 32746
&& (sn == (short) -32746));
- assertTrue("Returned incorrect value for 0", Short.parseShort("0") == 0);
+ assertEquals("Returned incorrect value for 0", 0, Short.parseShort("0"));
assertTrue("Returned incorrect value for most negative value", Short
.parseShort("-32768") == (short) 0x8000);
assertTrue("Returned incorrect value for most positive value", Short
@@ -255,28 +255,28 @@
// Test for method short java.lang.Short.parseShort(java.lang.String,
// int)
boolean aThrow = true;
- assertTrue("Incorrectly parsed hex string",
- Short.parseShort("FF", 16) == 255);
- assertTrue("Incorrectly parsed oct string",
- Short.parseShort("20", 8) == 16);
- assertTrue("Incorrectly parsed dec string",
- Short.parseShort("20", 10) == 20);
- assertTrue("Incorrectly parsed bin string",
- Short.parseShort("100", 2) == 4);
- assertTrue("Incorrectly parsed -hex string", Short
- .parseShort("-FF", 16) == -255);
- assertTrue("Incorrectly parsed -oct string",
- Short.parseShort("-20", 8) == -16);
- assertTrue("Incorrectly parsed -bin string", Short
- .parseShort("-100", 2) == -4);
- assertTrue("Returned incorrect value for 0 hex", Short.parseShort("0",
- 16) == 0);
+ assertEquals("Incorrectly parsed hex string",
+ 255, Short.parseShort("FF", 16));
+ assertEquals("Incorrectly parsed oct string",
+ 16, Short.parseShort("20", 8));
+ assertEquals("Incorrectly parsed dec string",
+ 20, Short.parseShort("20", 10));
+ assertEquals("Incorrectly parsed bin string",
+ 4, Short.parseShort("100", 2));
+ assertEquals("Incorrectly parsed -hex string", -255, Short
+ .parseShort("-FF", 16));
+ assertEquals("Incorrectly parsed -oct string",
+ -16, Short.parseShort("-20", 8));
+ assertEquals("Incorrectly parsed -bin string", -4, Short
+ .parseShort("-100", 2));
+ assertEquals("Returned incorrect value for 0 hex", 0, Short.parseShort("0",
+ 16));
assertTrue("Returned incorrect value for most negative value hex",
Short.parseShort("-8000", 16) == (short) 0x8000);
assertTrue("Returned incorrect value for most positive value hex",
Short.parseShort("7fff", 16) == 0x7fff);
- assertTrue("Returned incorrect value for 0 decimal", Short.parseShort(
- "0", 10) == 0);
+ assertEquals("Returned incorrect value for 0 decimal", 0, Short.parseShort(
+ "0", 10));
assertTrue("Returned incorrect value for most negative value decimal",
Short.parseShort("-32768", 10) == (short) 0x8000);
assertTrue("Returned incorrect value for most positive value decimal",
@@ -357,12 +357,12 @@
// Test for method java.lang.String java.lang.Short.toString()
assertTrue("Invalid string returned", sp.toString().equals("18000")
&& (sn.toString().equals("-19000")));
- assertTrue("Returned incorrect string", new Short((short) 32767)
- .toString().equals("32767"));
- assertTrue("Returned incorrect string", new Short((short) -32767)
- .toString().equals("-32767"));
- assertTrue("Returned incorrect string", new Short((short) -32768)
- .toString().equals("-32768"));
+ assertEquals("Returned incorrect string", "32767", new Short((short) 32767)
+ .toString());
+ assertEquals("Returned incorrect string", "-32767", new Short((short) -32767)
+ .toString());
+ assertEquals("Returned incorrect string", "-32768", new Short((short) -32768)
+ .toString());
}
/**
@@ -370,12 +370,12 @@
*/
public void test_toStringS() {
// Test for method java.lang.String java.lang.Short.toString(short)
- assertTrue("Returned incorrect string", Short.toString((short) 32767)
- .equals("32767"));
- assertTrue("Returned incorrect string", Short.toString((short) -32767)
- .equals("-32767"));
- assertTrue("Returned incorrect string", Short.toString((short) -32768)
- .equals("-32768"));
+ assertEquals("Returned incorrect string", "32767", Short.toString((short) 32767)
+ );
+ assertEquals("Returned incorrect string", "-32767", Short.toString((short) -32767)
+ );
+ assertEquals("Returned incorrect string", "-32768", Short.toString((short) -32768)
+ );
}
/**
@@ -384,10 +384,10 @@
public void test_valueOfLjava_lang_String() {
// Test for method java.lang.Short
// java.lang.Short.valueOf(java.lang.String)
- assertTrue("Returned incorrect short", Short.valueOf("-32768")
- .shortValue() == -32768);
- assertTrue("Returned incorrect short", Short.valueOf("32767")
- .shortValue() == 32767);
+ assertEquals("Returned incorrect short", -32768, Short.valueOf("-32768")
+ .shortValue());
+ assertEquals("Returned incorrect short", 32767, Short.valueOf("32767")
+ .shortValue());
}
/**
@@ -397,20 +397,20 @@
// Test for method java.lang.Short
// java.lang.Short.valueOf(java.lang.String, int)
boolean aThrow = true;
- assertTrue("Incorrectly parsed hex string", Short.valueOf("FF", 16)
- .shortValue() == 255);
- assertTrue("Incorrectly parsed oct string", Short.valueOf("20", 8)
- .shortValue() == 16);
- assertTrue("Incorrectly parsed dec string", Short.valueOf("20", 10)
- .shortValue() == 20);
- assertTrue("Incorrectly parsed bin string", Short.valueOf("100", 2)
- .shortValue() == 4);
- assertTrue("Incorrectly parsed -hex string", Short.valueOf("-FF", 16)
- .shortValue() == -255);
- assertTrue("Incorrectly parsed -oct string", Short.valueOf("-20", 8)
- .shortValue() == -16);
- assertTrue("Incorrectly parsed -bin string", Short.valueOf("-100", 2)
- .shortValue() == -4);
+ assertEquals("Incorrectly parsed hex string", 255, Short.valueOf("FF", 16)
+ .shortValue());
+ assertEquals("Incorrectly parsed oct string", 16, Short.valueOf("20", 8)
+ .shortValue());
+ assertEquals("Incorrectly parsed dec string", 20, Short.valueOf("20", 10)
+ .shortValue());
+ assertEquals("Incorrectly parsed bin string", 4, Short.valueOf("100", 2)
+ .shortValue());
+ assertEquals("Incorrectly parsed -hex string", -255, Short.valueOf("-FF", 16)
+ .shortValue());
+ assertEquals("Incorrectly parsed -oct string", -16, Short.valueOf("-20", 8)
+ .shortValue());
+ assertEquals("Incorrectly parsed -bin string", -4, Short.valueOf("-100", 2)
+ .shortValue());
assertTrue("Did not decode 32767 correctly", Short.valueOf("32767", 10)
.shortValue() == (short) 32767);
assertTrue("Did not decode -32767 correctly", Short.valueOf("-32767",
Modified: incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/tests/api/java/lang/StrictMathTest.java
URL: http://svn.apache.org/viewcvs/incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/tests/api/java/lang/StrictMathTest.java?rev=397123&r1=397122&r2=397123&view=diff
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/tests/api/java/lang/StrictMathTest.java (original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/tests/api/java/lang/StrictMathTest.java Wed Apr 26 00:12:16 2006
@@ -114,9 +114,10 @@
*/
public void test_ceilD() {
// Test for method double java.lang.StrictMath.ceil(double)
- assertTrue("Incorrect ceiling for double", StrictMath.ceil(78.89) == 79);
- assertTrue("Incorrect ceiling for double",
- StrictMath.ceil(-78.89) == -78);
+ assertEquals("Incorrect ceiling for double",
+ 79, StrictMath.ceil(78.89), 0.0);
+ assertEquals("Incorrect ceiling for double",
+ -78, StrictMath.ceil(-78.89), 0.0);
}
/**
@@ -146,9 +147,10 @@
*/
public void test_floorD() {
// Test for method double java.lang.StrictMath.floor(double)
- assertTrue("Incorrect floor for double", StrictMath.floor(78.89) == 78);
- assertTrue("Incorrect floor for double",
- StrictMath.floor(-78.89) == -79);
+ assertEquals("Incorrect floor for double",
+ 78, StrictMath.floor(78.89), 0.0);
+ assertEquals("Incorrect floor for double",
+ -79, StrictMath.floor(-78.89), 0.0);
}
/**
@@ -157,8 +159,8 @@
public void test_IEEEremainderDD() {
// Test for method double java.lang.StrictMath.IEEEremainder(double,
// double)
- assertTrue("Incorrect remainder returned", StrictMath.IEEEremainder(
- 1.0, 1.0) == 0.0);
+ assertEquals("Incorrect remainder returned", 0.0, StrictMath.IEEEremainder(
+ 1.0, 1.0));
assertTrue(
"Incorrect remainder returned",
StrictMath.IEEEremainder(1.32, 89.765) >= 1.4705063220631647E-2
@@ -184,12 +186,12 @@
*/
public void test_maxDD() {
// Test for method double java.lang.StrictMath.max(double, double)
- assertTrue("Incorrect double max value", StrictMath.max(
- -1908897.6000089, 1908897.6000089) == 1908897.6000089);
- assertTrue("Incorrect double max value", StrictMath.max(2.0,
- 1908897.6000089) == 1908897.6000089);
- assertTrue("Incorrect double max value", StrictMath.max(-2.0,
- -1908897.6000089) == -2.0);
+ assertEquals("Incorrect double max value", 1908897.6000089, StrictMath.max(
+ -1908897.6000089, 1908897.6000089));
+ assertEquals("Incorrect double max value", 1908897.6000089, StrictMath.max(2.0,
+ 1908897.6000089));
+ assertEquals("Incorrect double max value", -2.0, StrictMath.max(-2.0,
+ -1908897.6000089));
}
@@ -211,12 +213,12 @@
*/
public void test_maxII() {
// Test for method int java.lang.StrictMath.max(int, int)
- assertTrue("Incorrect int max value", StrictMath.max(-19088976,
- 19088976) == 19088976);
- assertTrue("Incorrect int max value",
- StrictMath.max(20, 19088976) == 19088976);
- assertTrue("Incorrect int max value",
- StrictMath.max(-20, -19088976) == -20);
+ assertEquals("Incorrect int max value", 19088976, StrictMath.max(-19088976,
+ 19088976));
+ assertEquals("Incorrect int max value",
+ 19088976, StrictMath.max(20, 19088976));
+ assertEquals("Incorrect int max value",
+ -20, StrictMath.max(-20, -19088976));
}
/**
@@ -224,12 +226,12 @@
*/
public void test_maxJJ() {
// Test for method long java.lang.StrictMath.max(long, long)
- assertTrue("Incorrect long max value", StrictMath.max(-19088976000089L,
- 19088976000089L) == 19088976000089L);
- assertTrue("Incorrect long max value", StrictMath.max(20,
- 19088976000089L) == 19088976000089L);
- assertTrue("Incorrect long max value", StrictMath.max(-20,
- -19088976000089L) == -20);
+ assertEquals("Incorrect long max value", 19088976000089L, StrictMath.max(-19088976000089L,
+ 19088976000089L));
+ assertEquals("Incorrect long max value", 19088976000089L, StrictMath.max(20,
+ 19088976000089L));
+ assertEquals("Incorrect long max value", -20, StrictMath.max(-20,
+ -19088976000089L));
}
/**
@@ -237,12 +239,12 @@
*/
public void test_minDD() {
// Test for method double java.lang.StrictMath.min(double, double)
- assertTrue("Incorrect double min value", StrictMath.min(
- -1908897.6000089, 1908897.6000089) == -1908897.6000089);
- assertTrue("Incorrect double min value", StrictMath.min(2.0,
- 1908897.6000089) == 2.0);
- assertTrue("Incorrect double min value", StrictMath.min(-2.0,
- -1908897.6000089) == -1908897.6000089);
+ assertEquals("Incorrect double min value", -1908897.6000089, StrictMath.min(
+ -1908897.6000089, 1908897.6000089));
+ assertEquals("Incorrect double min value", 2.0, StrictMath.min(2.0,
+ 1908897.6000089));
+ assertEquals("Incorrect double min value", -1908897.6000089, StrictMath.min(-2.0,
+ -1908897.6000089));
}
/**
@@ -263,12 +265,12 @@
*/
public void test_minII() {
// Test for method int java.lang.StrictMath.min(int, int)
- assertTrue("Incorrect int min value", StrictMath.min(-19088976,
- 19088976) == -19088976);
- assertTrue("Incorrect int min value",
- StrictMath.min(20, 19088976) == 20);
- assertTrue("Incorrect int min value",
- StrictMath.min(-20, -19088976) == -19088976);
+ assertEquals("Incorrect int min value", -19088976, StrictMath.min(-19088976,
+ 19088976));
+ assertEquals("Incorrect int min value",
+ 20, StrictMath.min(20, 19088976));
+ assertEquals("Incorrect int min value",
+ -19088976, StrictMath.min(-20, -19088976));
}
@@ -277,12 +279,12 @@
*/
public void test_minJJ() {
// Test for method long java.lang.StrictMath.min(long, long)
- assertTrue("Incorrect long min value", StrictMath.min(-19088976000089L,
- 19088976000089L) == -19088976000089L);
- assertTrue("Incorrect long min value", StrictMath.min(20,
- 19088976000089L) == 20);
- assertTrue("Incorrect long min value", StrictMath.min(-20,
- -19088976000089L) == -19088976000089L);
+ assertEquals("Incorrect long min value", -19088976000089L, StrictMath.min(-19088976000089L,
+ 19088976000089L));
+ assertEquals("Incorrect long min value", 20, StrictMath.min(20,
+ 19088976000089L));
+ assertEquals("Incorrect long min value", -19088976000089L, StrictMath.min(-20,
+ -19088976000089L));
}
/**
@@ -301,12 +303,12 @@
*/
public void test_rintD() {
// Test for method double java.lang.StrictMath.rint(double)
- assertTrue("Failed to round properly - up to odd",
- StrictMath.rint(2.9) == 3.0);
+ assertEquals("Failed to round properly - up to odd",
+ 3.0, StrictMath.rint(2.9));
assertTrue("Failed to round properly - NaN", Double.isNaN(StrictMath
.rint(Double.NaN)));
- assertTrue("Failed to round properly down to even", StrictMath
- .rint(2.1) == 2.0);
+ assertEquals("Failed to round properly down to even", 2.0, StrictMath
+ .rint(2.1));
assertTrue("Failed to round properly " + 2.5 + " to even", StrictMath
.rint(2.5) == 2.0);
}
@@ -316,8 +318,8 @@
*/
public void test_roundD() {
// Test for method long java.lang.StrictMath.round(double)
- assertTrue("Incorrect rounding of a float",
- StrictMath.round(-90.89d) == -91);
+ assertEquals("Incorrect rounding of a float",
+ -91, StrictMath.round(-90.89d));
}
/**
@@ -325,8 +327,8 @@
*/
public void test_roundF() {
// Test for method int java.lang.StrictMath.round(float)
- assertTrue("Incorrect rounding of a float",
- StrictMath.round(-90.89f) == -91);
+ assertEquals("Incorrect rounding of a float",
+ -91, StrictMath.round(-90.89f));
}
/**
@@ -343,9 +345,9 @@
*/
public void test_sqrtD() {
// Test for method double java.lang.StrictMath.sqrt(double)
- assertTrue("Incorrect root returned1", StrictMath.sqrt(StrictMath.pow(
- StrictMath.sqrt(2), 4)) == 2);
- assertTrue("Incorrect root returned2", StrictMath.sqrt(49) == 7);
+ assertEquals("Incorrect root returned1",
+ 2, StrictMath.sqrt(StrictMath.pow(StrictMath.sqrt(2), 4)), 0.0);
+ assertEquals("Incorrect root returned2", 7, StrictMath.sqrt(49), 0.0);
}
/**
@@ -364,10 +366,10 @@
*/
public void test_random() {
// There isn't a place for these tests so just stick them here
- assertTrue("Wrong value E",
- Double.doubleToLongBits(StrictMath.E) == 4613303445314885481L);
- assertTrue("Wrong value PI",
- Double.doubleToLongBits(StrictMath.PI) == 4614256656552045848L);
+ assertEquals("Wrong value E",
+ 4613303445314885481L, Double.doubleToLongBits(StrictMath.E));
+ assertEquals("Wrong value PI",
+ 4614256656552045848L, Double.doubleToLongBits(StrictMath.PI));
for (int i = 500; i >= 0; i--) {
double d = StrictMath.random();