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 [6/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/util/CollectionsTest.java
URL: http://svn.apache.org/viewcvs/incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/tests/api/java/util/CollectionsTest.java?rev=397123&r1=397122&r2=397123&view=diff
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/tests/api/java/util/CollectionsTest.java (original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/tests/api/java/util/CollectionsTest.java Wed Apr 26 00:12:16 2006
@@ -403,13 +403,13 @@
assertTrue("Fill modified list size", size == ll.size());
Iterator i = ll.iterator();
while (i.hasNext())
- assertTrue("Failed to fill elements", i.next().equals("k"));
+ assertEquals("Failed to fill elements", "k", i.next());
Collections.fill(ll, null);
assertTrue("Fill with nulls modified list size", size == ll.size());
i = ll.iterator();
while (i.hasNext())
- assertTrue("Failed to fill with nulls", i.next() == null);
+ assertNull("Failed to fill with nulls", i.next());
}
/**
@@ -477,7 +477,7 @@
Iterator i = l.iterator();
Object first = i.next();
assertTrue("Returned list consists of copies not refs", first == o);
- assertTrue("Returned list of incorrect size", l.size() == 100);
+ assertEquals("Returned list of incorrect size", 100, l.size());
assertTrue("Contains", l.contains(o));
assertTrue("Contains null", !l.contains(null));
assertTrue("null nCopies contains", !Collections.nCopies(2, null)
@@ -488,7 +488,7 @@
i = l.iterator();
for (int counter = 0; i.hasNext(); counter++) {
assertTrue("List is too large", counter < 20);
- assertTrue("Element should be null: " + counter, i.next() == null);
+ assertNull("Element should be null: " + counter, i.next());
}
try {
l.add(o);
@@ -529,8 +529,8 @@
Collections.reverse(myList);
assertTrue("Did not reverse correctly--first element is: "
+ myList.get(0), myList.get(0).equals(new Integer(20)));
- assertTrue("Did not reverse correctly--second element is: "
- + myList.get(1), myList.get(1) == null);
+ assertNull("Did not reverse correctly--second element is: "
+ + myList.get(1), myList.get(1));
}
/**
@@ -633,7 +633,7 @@
// java.util.Collections.singleton(java.lang.Object)
Object o = new Object();
Set single = Collections.singleton(o);
- assertTrue("Wrong size", single.size() == 1);
+ assertEquals("Wrong size", 1, single.size());
assertTrue("Contains", single.contains(o));
assertTrue("Contains null", !single.contains(null));
assertTrue("null nCopies contains", !Collections.singleton(null)
@@ -1338,8 +1338,8 @@
fail(type + " list tests: join() interrupted");
}
synchList.set(25, null);
- assertTrue(type + " list tests: Trying to use nulls in list failed",
- synchList.get(25) == null);
+ assertNull(type + " list tests: Trying to use nulls in list failed",
+ synchList.get(25));
}
/**
@@ -1387,8 +1387,8 @@
// synchronized map does not have to permit null keys or values
synchMap.put(new Long(25), null);
synchMap.put(null, new Long(30));
- assertTrue("Trying to use a null value in map failed", synchMap
- .get(new Long(25)) == null);
+ assertNull("Trying to use a null value in map failed", synchMap
+ .get(new Long(25)));
assertTrue("Trying to use a null key in map failed", synchMap.get(null)
.equals(new Long(30)));
@@ -1399,12 +1399,12 @@
synchMap = Collections.synchronizedMap(smallMap);
new Support_UnmodifiableMapTest("", synchMap).runTest();
synchMap.keySet().remove(objArray[50].toString());
- assertTrue(
+ assertNull(
"Removing a key from the keySet of the synchronized map did not remove it from the synchronized map: ",
- synchMap.get(objArray[50].toString()) == null);
- assertTrue(
+ synchMap.get(objArray[50].toString()));
+ assertNull(
"Removing a key from the keySet of the synchronized map did not remove it from the original map",
- smallMap.get(objArray[50].toString()) == null);
+ smallMap.get(objArray[50].toString()));
}
/**
@@ -1510,12 +1510,12 @@
synchMap = Collections.synchronizedSortedMap(smallMap);
new Support_UnmodifiableMapTest("", synchMap).runTest();
synchMap.keySet().remove(objArray[50].toString());
- assertTrue(
+ assertNull(
"Removing a key from the keySet of the synchronized map did not remove it from the synchronized map",
- synchMap.get(objArray[50].toString()) == null);
- assertTrue(
+ synchMap.get(objArray[50].toString()));
+ assertNull(
"Removing a key from the keySet of the synchronized map did not remove it from the original map",
- smallMap.get(objArray[50].toString()) == null);
+ smallMap.get(objArray[50].toString()));
}
/**
@@ -1656,7 +1656,7 @@
smallList.add(null);
smallList.add("yoink");
c = Collections.unmodifiableList(smallList);
- assertTrue("First element should be null", c.get(0) == null);
+ assertNull("First element should be null", c.get(0));
assertTrue("List should contain null", c.contains(null));
assertTrue(
"T1. Returned List should implement Random Access interface",
@@ -1751,8 +1751,8 @@
smallMap.put(new Long(25), null);
Map unmodMap = Collections.unmodifiableMap(smallMap);
- assertTrue("Trying to use a null value in map failed", unmodMap
- .get(new Long(25)) == null);
+ assertNull("Trying to use a null value in map failed", unmodMap
+ .get(new Long(25)));
assertTrue("Trying to use a null key in map failed", unmodMap.get(null)
.equals(new Long(30)));
Modified: incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/tests/api/java/util/CurrencyTest.java
URL: http://svn.apache.org/viewcvs/incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/tests/api/java/util/CurrencyTest.java?rev=397123&r1=397122&r2=397123&view=diff
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/tests/api/java/util/CurrencyTest.java (original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/tests/api/java/util/CurrencyTest.java Wed Apr 26 00:12:16 2006
@@ -77,9 +77,9 @@
Locale loc = new Locale("", "AQ");
try {
Currency curr = Currency.getInstance(loc);
- assertTrue(
+ assertNull(
"Currency.getInstance(new Locale(\"\", \"AQ\")) did not return null",
- curr == null);
+ curr);
} catch (IllegalArgumentException e) {
fail("Unexpected IllegalArgumentException " + e);
}
Modified: incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/tests/api/java/util/DateTest.java
URL: http://svn.apache.org/viewcvs/incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/tests/api/java/util/DateTest.java?rev=397123&r1=397122&r2=397123&view=diff
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/tests/api/java/util/DateTest.java (original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/tests/api/java/util/DateTest.java Wed Apr 26 00:12:16 2006
@@ -157,16 +157,14 @@
Date d3 = new Date(someNumber + 1);
Date d4 = new Date(someNumber - 1);
Integer i = new Integer(0);
- assertTrue("Comparing a date to itself did not answer zero", d1
- .compareTo((Object) d1) == 0);
- assertTrue("Comparing equal dates did not answer zero", d1
- .compareTo((Object) d2) == 0);
- assertTrue(
- "date1.compareTo(date2), where date1 > date2, did not result in 1",
- d1.compareTo((Object) d4) == 1);
- assertTrue(
- "date1.compareTo(date2), where date1 < date2, did not result in -1",
- d1.compareTo((Object) d3) == -1);
+ assertEquals("Comparing a date to itself did not answer zero", 0, d1
+ .compareTo((Object) d1));
+ assertEquals("Comparing equal dates did not answer zero", 0, d1
+ .compareTo((Object) d2));
+ assertEquals("date1.compareTo(date2), where date1 > date2, did not result in 1",
+ 1, d1.compareTo((Object) d4));
+ assertEquals("date1.compareTo(date2), where date1 < date2, did not result in -1",
+ -1, d1.compareTo((Object) d3));
try {
d1.compareTo(i);
} catch (ClassCastException e) {
@@ -186,16 +184,14 @@
Date d2 = new Date(someNumber);
Date d3 = new Date(someNumber + 1);
Date d4 = new Date(someNumber - 1);
- assertTrue("Comparing a date to itself did not answer zero", d1
- .compareTo(d1) == 0);
- assertTrue("Comparing equal dates did not answer zero", d1
- .compareTo(d2) == 0);
- assertTrue(
- "date1.compareTo(date2), where date1 > date2, did not result in 1",
- d1.compareTo(d4) == 1);
- assertTrue(
- "date1.compareTo(date2), where date1 < date2, did not result in -1",
- d1.compareTo(d3) == -1);
+ assertEquals("Comparing a date to itself did not answer zero", 0, d1
+ .compareTo(d1));
+ assertEquals("Comparing equal dates did not answer zero", 0, d1
+ .compareTo(d2));
+ assertEquals("date1.compareTo(date2), where date1 > date2, did not result in 1",
+ 1, d1.compareTo(d4));
+ assertEquals("date1.compareTo(date2), where date1 < date2, did not result in -1",
+ -1, d1.compareTo(d3));
}
@@ -218,7 +214,7 @@
// Test for method int java.util.Date.getDate()
Date d = new GregorianCalendar(1998, Calendar.OCTOBER, 13, 19, 9)
.getTime();
- assertTrue("Returned incorrect date", d.getDate() == 13);
+ assertEquals("Returned incorrect date", 13, d.getDate());
}
/**
@@ -228,7 +224,7 @@
// Test for method int java.util.Date.getDay()
Date d = new GregorianCalendar(1998, Calendar.OCTOBER, 13, 19, 9)
.getTime();
- assertTrue("Returned incorrect day", d.getDay() == 2);
+ assertEquals("Returned incorrect day", 2, d.getDay());
}
/**
@@ -238,7 +234,7 @@
// Test for method int java.util.Date.getHours()
Date d = new GregorianCalendar(1998, Calendar.OCTOBER, 13, 19, 9)
.getTime();
- assertTrue("Returned incorrect hours", d.getHours() == 19);
+ assertEquals("Returned incorrect hours", 19, d.getHours());
}
/**
@@ -248,7 +244,7 @@
// Test for method int java.util.Date.getMinutes()
Date d = new GregorianCalendar(1998, Calendar.OCTOBER, 13, 19, 9)
.getTime();
- assertTrue("Returned incorrect minutes", d.getMinutes() == 9);
+ assertEquals("Returned incorrect minutes", 9, d.getMinutes());
}
/**
@@ -258,7 +254,7 @@
// Test for method int java.util.Date.getMonth()
Date d = new GregorianCalendar(1998, Calendar.OCTOBER, 13, 19, 9)
.getTime();
- assertTrue("Returned incorrect month", d.getMonth() == 9);
+ assertEquals("Returned incorrect month", 9, d.getMonth());
}
/**
@@ -268,7 +264,7 @@
// Test for method int java.util.Date.getSeconds()
Date d = new GregorianCalendar(1998, Calendar.OCTOBER, 13, 19, 9)
.getTime();
- assertTrue("Returned incorrect seconds", d.getSeconds() == 0);
+ assertEquals("Returned incorrect seconds", 0, d.getSeconds());
}
/**
@@ -278,8 +274,8 @@
// Test for method long java.util.Date.getTime()
Date d1 = new Date(0);
Date d2 = new Date(1900000);
- assertTrue("Returned incorrect time", d2.getTime() == 1900000);
- assertTrue("Returned incorrect time", d1.getTime() == 0);
+ assertEquals("Returned incorrect time", 1900000, d2.getTime());
+ assertEquals("Returned incorrect time", 0, d1.getTime());
}
/**
@@ -297,7 +293,7 @@
// Test for method int java.util.Date.getYear()
Date d = new GregorianCalendar(1998, Calendar.OCTOBER, 13, 19, 9)
.getTime();
- assertTrue("Returned incorrect year", d.getYear() == 98);
+ assertEquals("Returned incorrect year", 98, d.getYear());
}
/**
@@ -307,8 +303,8 @@
// Test for method int java.util.Date.hashCode()
Date d1 = new Date(0);
Date d2 = new Date(1900000);
- assertTrue("Returned incorrect hash", d2.hashCode() == 1900000);
- assertTrue("Returned incorrect hash", d1.hashCode() == 0);
+ assertEquals("Returned incorrect hash", 1900000, d2.hashCode());
+ assertEquals("Returned incorrect hash", 0, d1.hashCode());
}
/**
@@ -319,9 +315,9 @@
Date d = new Date(Date.parse("13 October 1998"));
GregorianCalendar cal = new GregorianCalendar();
cal.setTime(d);
- assertTrue("Parsed incorrect month", cal.get(Calendar.MONTH) == 9);
- assertTrue("Parsed incorrect year", cal.get(Calendar.YEAR) == 1998);
- assertTrue("Parsed incorrect date", cal.get(Calendar.DATE) == 13);
+ assertEquals("Parsed incorrect month", 9, cal.get(Calendar.MONTH));
+ assertEquals("Parsed incorrect year", 1998, cal.get(Calendar.YEAR));
+ assertEquals("Parsed incorrect date", 13, cal.get(Calendar.DATE));
d = new Date(Date.parse("Jan-12 1999"));
assertTrue("Wrong parsed date 1", d.equals(new GregorianCalendar(1999,
@@ -362,7 +358,7 @@
Date d = new GregorianCalendar(1998, Calendar.OCTOBER, 13, 19, 9)
.getTime();
d.setDate(23);
- assertTrue("Set incorrect date", d.getDate() == 23);
+ assertEquals("Set incorrect date", 23, d.getDate());
}
/**
@@ -373,7 +369,7 @@
Date d = new GregorianCalendar(1998, Calendar.OCTOBER, 13, 19, 9)
.getTime();
d.setHours(23);
- assertTrue("Set incorrect hours", d.getHours() == 23);
+ assertEquals("Set incorrect hours", 23, d.getHours());
}
/**
@@ -384,7 +380,7 @@
Date d = new GregorianCalendar(1998, Calendar.OCTOBER, 13, 19, 9)
.getTime();
d.setMinutes(45);
- assertTrue("Set incorrect mins", d.getMinutes() == 45);
+ assertEquals("Set incorrect mins", 45, d.getMinutes());
}
/**
@@ -395,7 +391,7 @@
Date d = new GregorianCalendar(1998, Calendar.OCTOBER, 13, 19, 9)
.getTime();
d.setMonth(0);
- assertTrue("Set incorrect month", d.getMonth() == 0);
+ assertEquals("Set incorrect month", 0, d.getMonth());
}
/**
@@ -406,7 +402,7 @@
Date d = new GregorianCalendar(1998, Calendar.OCTOBER, 13, 19, 9)
.getTime();
d.setSeconds(13);
- assertTrue("Set incorrect seconds", d.getSeconds() == 13);
+ assertEquals("Set incorrect seconds", 13, d.getSeconds());
}
/**
@@ -418,8 +414,8 @@
Date d2 = new Date(1900000);
d1.setTime(900);
d2.setTime(890000);
- assertTrue("Returned incorrect time", d2.getTime() == 890000);
- assertTrue("Returned incorrect time", d1.getTime() == 900);
+ assertEquals("Returned incorrect time", 890000, d2.getTime());
+ assertEquals("Returned incorrect time", 900, d1.getTime());
}
/**
@@ -430,7 +426,7 @@
Date d = new GregorianCalendar(1998, Calendar.OCTOBER, 13, 19, 9)
.getTime();
d.setYear(8);
- assertTrue("Set incorrect year", d.getYear() == 8);
+ assertEquals("Set incorrect year", 8, d.getYear());
}
/**
@@ -438,11 +434,11 @@
*/
public void test_toGMTString() {
// Test for method java.lang.String java.util.Date.toGMTString()
- assertTrue("Did not convert epoch to GMT string correctly", new Date(0)
- .toGMTString().equals("1 Jan 1970 00:00:00 GMT"));
- assertTrue("Did not convert epoch + 1yr to GMT string correctly",
- new Date((long) 365 * 24 * 60 * 60 * 1000).toGMTString()
- .equals("1 Jan 1971 00:00:00 GMT"));
+ assertEquals("Did not convert epoch to GMT string correctly", "1 Jan 1970 00:00:00 GMT", new Date(0)
+ .toGMTString());
+ assertEquals("Did not convert epoch + 1yr to GMT string correctly",
+ "1 Jan 1971 00:00:00 GMT", new Date((long) 365 * 24 * 60 * 60 * 1000).toGMTString()
+ );
}
/**
Modified: incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/tests/api/java/util/GregorianCalendarTest.java
URL: http://svn.apache.org/viewcvs/incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/tests/api/java/util/GregorianCalendarTest.java?rev=397123&r1=397122&r2=397123&view=diff
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/tests/api/java/util/GregorianCalendarTest.java (original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/tests/api/java/util/GregorianCalendarTest.java Wed Apr 26 00:12:16 2006
@@ -40,12 +40,12 @@
public void test_ConstructorIII() {
// Test for method java.util.GregorianCalendar(int, int, int)
GregorianCalendar gc = new GregorianCalendar(1972, Calendar.OCTOBER, 13);
- assertTrue("Incorrect calendar constructed 1",
- gc.get(Calendar.YEAR) == 1972);
+ assertEquals("Incorrect calendar constructed 1",
+ 1972, gc.get(Calendar.YEAR));
assertTrue("Incorrect calendar constructed 2",
gc.get(Calendar.MONTH) == Calendar.OCTOBER);
- assertTrue("Incorrect calendar constructed 3", gc
- .get(Calendar.DAY_OF_MONTH) == 13);
+ assertEquals("Incorrect calendar constructed 3", 13, gc
+ .get(Calendar.DAY_OF_MONTH));
assertTrue("Incorrect calendar constructed 4", gc.getTimeZone().equals(
TimeZone.getDefault()));
}
@@ -58,17 +58,17 @@
// Test for method java.util.GregorianCalendar(int, int, int, int, int)
GregorianCalendar gc = new GregorianCalendar(1972, Calendar.OCTOBER,
13, 19, 9);
- assertTrue("Incorrect calendar constructed",
- gc.get(Calendar.YEAR) == 1972);
+ assertEquals("Incorrect calendar constructed",
+ 1972, gc.get(Calendar.YEAR));
assertTrue("Incorrect calendar constructed",
gc.get(Calendar.MONTH) == Calendar.OCTOBER);
- assertTrue("Incorrect calendar constructed", gc
- .get(Calendar.DAY_OF_MONTH) == 13);
- assertTrue("Incorrect calendar constructed", gc.get(Calendar.HOUR) == 7);
- assertTrue("Incorrect calendar constructed",
- gc.get(Calendar.AM_PM) == 1);
- assertTrue("Incorrect calendar constructed",
- gc.get(Calendar.MINUTE) == 9);
+ assertEquals("Incorrect calendar constructed", 13, gc
+ .get(Calendar.DAY_OF_MONTH));
+ assertEquals("Incorrect calendar constructed", 7, gc.get(Calendar.HOUR));
+ assertEquals("Incorrect calendar constructed",
+ 1, gc.get(Calendar.AM_PM));
+ assertEquals("Incorrect calendar constructed",
+ 9, gc.get(Calendar.MINUTE));
assertTrue("Incorrect calendar constructed", gc.getTimeZone().equals(
TimeZone.getDefault()));
}
@@ -82,19 +82,19 @@
// int)
GregorianCalendar gc = new GregorianCalendar(1972, Calendar.OCTOBER,
13, 19, 9, 59);
- assertTrue("Incorrect calendar constructed",
- gc.get(Calendar.YEAR) == 1972);
+ assertEquals("Incorrect calendar constructed",
+ 1972, gc.get(Calendar.YEAR));
assertTrue("Incorrect calendar constructed",
gc.get(Calendar.MONTH) == Calendar.OCTOBER);
- assertTrue("Incorrect calendar constructed", gc
- .get(Calendar.DAY_OF_MONTH) == 13);
- assertTrue("Incorrect calendar constructed", gc.get(Calendar.HOUR) == 7);
- assertTrue("Incorrect calendar constructed",
- gc.get(Calendar.AM_PM) == 1);
- assertTrue("Incorrect calendar constructed",
- gc.get(Calendar.MINUTE) == 9);
- assertTrue("Incorrect calendar constructed",
- gc.get(Calendar.SECOND) == 59);
+ assertEquals("Incorrect calendar constructed", 13, gc
+ .get(Calendar.DAY_OF_MONTH));
+ assertEquals("Incorrect calendar constructed", 7, gc.get(Calendar.HOUR));
+ assertEquals("Incorrect calendar constructed",
+ 1, gc.get(Calendar.AM_PM));
+ assertEquals("Incorrect calendar constructed",
+ 9, gc.get(Calendar.MINUTE));
+ assertEquals("Incorrect calendar constructed",
+ 59, gc.get(Calendar.SECOND));
assertTrue("Incorrect calendar constructed", gc.getTimeZone().equals(
TimeZone.getDefault()));
}
@@ -167,72 +167,72 @@
// Test for method void java.util.GregorianCalendar.add(int, int)
GregorianCalendar gc1 = new GregorianCalendar(1998, 11, 6);
gc1.add(GregorianCalendar.YEAR, 1);
- assertTrue("Add failed to Increment",
- gc1.get(GregorianCalendar.YEAR) == 1999);
+ assertEquals("Add failed to Increment",
+ 1999, gc1.get(GregorianCalendar.YEAR));
gc1 = new GregorianCalendar(1999, Calendar.JULY, 31);
gc1.add(Calendar.MONTH, 7);
- assertTrue("Wrong result year 1", gc1.get(Calendar.YEAR) == 2000);
+ assertEquals("Wrong result year 1", 2000, gc1.get(Calendar.YEAR));
assertTrue("Wrong result month 1",
gc1.get(Calendar.MONTH) == Calendar.FEBRUARY);
- assertTrue("Wrong result date 1", gc1.get(Calendar.DATE) == 29);
+ assertEquals("Wrong result date 1", 29, gc1.get(Calendar.DATE));
gc1.add(Calendar.YEAR, -1);
- assertTrue("Wrong result year 2", gc1.get(Calendar.YEAR) == 1999);
+ assertEquals("Wrong result year 2", 1999, gc1.get(Calendar.YEAR));
assertTrue("Wrong result month 2",
gc1.get(Calendar.MONTH) == Calendar.FEBRUARY);
- assertTrue("Wrong result date 2", gc1.get(Calendar.DATE) == 28);
+ assertEquals("Wrong result date 2", 28, gc1.get(Calendar.DATE));
gc1 = new GregorianCalendar(TimeZone.getTimeZone("EST"));
gc1.set(1999, Calendar.APRIL, 3, 16, 0); // day before DST change
gc1.add(Calendar.MILLISECOND, 24 * 60 * 60 * 1000);
- assertTrue("Wrong time after MILLISECOND change", gc1
- .get(Calendar.HOUR_OF_DAY) == 17);
+ assertEquals("Wrong time after MILLISECOND change", 17, gc1
+ .get(Calendar.HOUR_OF_DAY));
gc1.set(1999, Calendar.APRIL, 3, 16, 0); // day before DST change
gc1.add(Calendar.SECOND, 24 * 60 * 60);
- assertTrue("Wrong time after SECOND change", gc1
- .get(Calendar.HOUR_OF_DAY) == 17);
+ assertEquals("Wrong time after SECOND change", 17, gc1
+ .get(Calendar.HOUR_OF_DAY));
gc1.set(1999, Calendar.APRIL, 3, 16, 0); // day before DST change
gc1.add(Calendar.MINUTE, 24 * 60);
- assertTrue("Wrong time after MINUTE change", gc1
- .get(Calendar.HOUR_OF_DAY) == 17);
+ assertEquals("Wrong time after MINUTE change", 17, gc1
+ .get(Calendar.HOUR_OF_DAY));
gc1.set(1999, Calendar.APRIL, 3, 16, 0); // day before DST change
gc1.add(Calendar.HOUR, 24);
- assertTrue("Wrong time after HOUR change", gc1
- .get(Calendar.HOUR_OF_DAY) == 17);
+ assertEquals("Wrong time after HOUR change", 17, gc1
+ .get(Calendar.HOUR_OF_DAY));
gc1.set(1999, Calendar.APRIL, 3, 16, 0); // day before DST change
gc1.add(Calendar.HOUR_OF_DAY, 24);
- assertTrue("Wrong time after HOUR_OF_DAY change", gc1
- .get(Calendar.HOUR_OF_DAY) == 17);
+ assertEquals("Wrong time after HOUR_OF_DAY change", 17, gc1
+ .get(Calendar.HOUR_OF_DAY));
gc1.set(1999, Calendar.APRIL, 3, 16, 0); // day before DST change
gc1.add(Calendar.AM_PM, 2);
- assertTrue("Wrong time after AM_PM change", gc1
- .get(Calendar.HOUR_OF_DAY) == 16);
+ assertEquals("Wrong time after AM_PM change", 16, gc1
+ .get(Calendar.HOUR_OF_DAY));
gc1.set(1999, Calendar.APRIL, 3, 16, 0); // day before DST change
gc1.add(Calendar.DATE, 1);
- assertTrue("Wrong time after DATE change", gc1
- .get(Calendar.HOUR_OF_DAY) == 16);
+ assertEquals("Wrong time after DATE change", 16, gc1
+ .get(Calendar.HOUR_OF_DAY));
gc1.set(1999, Calendar.APRIL, 3, 16, 0); // day before DST change
gc1.add(Calendar.DAY_OF_YEAR, 1);
- assertTrue("Wrong time after DAY_OF_YEAR change", gc1
- .get(Calendar.HOUR_OF_DAY) == 16);
+ assertEquals("Wrong time after DAY_OF_YEAR change", 16, gc1
+ .get(Calendar.HOUR_OF_DAY));
gc1.set(1999, Calendar.APRIL, 3, 16, 0); // day before DST change
gc1.add(Calendar.DAY_OF_WEEK, 1);
- assertTrue("Wrong time after DAY_OF_WEEK change", gc1
- .get(Calendar.HOUR_OF_DAY) == 16);
+ assertEquals("Wrong time after DAY_OF_WEEK change", 16, gc1
+ .get(Calendar.HOUR_OF_DAY));
gc1.set(1999, Calendar.APRIL, 3, 16, 0); // day before DST change
gc1.add(Calendar.WEEK_OF_YEAR, 1);
- assertTrue("Wrong time after WEEK_OF_YEAR change", gc1
- .get(Calendar.HOUR_OF_DAY) == 16);
+ assertEquals("Wrong time after WEEK_OF_YEAR change", 16, gc1
+ .get(Calendar.HOUR_OF_DAY));
gc1.set(1999, Calendar.APRIL, 3, 16, 0); // day before DST change
gc1.add(Calendar.WEEK_OF_MONTH, 1);
- assertTrue("Wrong time after WEEK_OF_MONTH change", gc1
- .get(Calendar.HOUR_OF_DAY) == 16);
+ assertEquals("Wrong time after WEEK_OF_MONTH change", 16, gc1
+ .get(Calendar.HOUR_OF_DAY));
gc1.set(1999, Calendar.APRIL, 3, 16, 0); // day before DST change
gc1.add(Calendar.DAY_OF_WEEK_IN_MONTH, 1);
- assertTrue("Wrong time after DAY_OF_WEEK_IN_MONTH change", gc1
- .get(Calendar.HOUR_OF_DAY) == 16);
+ assertEquals("Wrong time after DAY_OF_WEEK_IN_MONTH change", 16, gc1
+ .get(Calendar.HOUR_OF_DAY));
gc1.clear();
gc1.set(2000, Calendar.APRIL, 1, 23, 0);
@@ -269,26 +269,26 @@
GregorianCalendar gc4 = new GregorianCalendar(2000, 1, 1);
GregorianCalendar gc5 = new GregorianCalendar(2000, 9, 9);
GregorianCalendar gc6 = new GregorianCalendar(2000, 3, 3);
- assertTrue("Wrong actual maximum value for DAY_OF_MONTH for Feb 1900",
- gc1.getActualMaximum(Calendar.DAY_OF_MONTH) == 28);
- assertTrue("Wrong actual maximum value for DAY_OF_MONTH for Feb 1996",
- gc2.getActualMaximum(Calendar.DAY_OF_MONTH) == 29);
- assertTrue("Wrong actual maximum value for DAY_OF_MONTH for Feb 1998",
- gc3.getActualMaximum(Calendar.DAY_OF_MONTH) == 28);
- assertTrue("Wrong actual maximum value for DAY_OF_MONTH for Feb 2000",
- gc4.getActualMaximum(Calendar.DAY_OF_MONTH) == 29);
- assertTrue("Wrong actual maximum value for DAY_OF_MONTH for Oct 2000",
- gc5.getActualMaximum(Calendar.DAY_OF_MONTH) == 31);
- assertTrue("Wrong actual maximum value for DAY_OF_MONTH for Apr 2000",
- gc6.getActualMaximum(Calendar.DAY_OF_MONTH) == 30);
+ assertEquals("Wrong actual maximum value for DAY_OF_MONTH for Feb 1900",
+ 28, gc1.getActualMaximum(Calendar.DAY_OF_MONTH));
+ assertEquals("Wrong actual maximum value for DAY_OF_MONTH for Feb 1996",
+ 29, gc2.getActualMaximum(Calendar.DAY_OF_MONTH));
+ assertEquals("Wrong actual maximum value for DAY_OF_MONTH for Feb 1998",
+ 28, gc3.getActualMaximum(Calendar.DAY_OF_MONTH));
+ assertEquals("Wrong actual maximum value for DAY_OF_MONTH for Feb 2000",
+ 29, gc4.getActualMaximum(Calendar.DAY_OF_MONTH));
+ assertEquals("Wrong actual maximum value for DAY_OF_MONTH for Oct 2000",
+ 31, gc5.getActualMaximum(Calendar.DAY_OF_MONTH));
+ assertEquals("Wrong actual maximum value for DAY_OF_MONTH for Apr 2000",
+ 30, gc6.getActualMaximum(Calendar.DAY_OF_MONTH));
assertTrue("Wrong actual maximum value for MONTH", gc1
.getActualMaximum(Calendar.MONTH) == Calendar.DECEMBER);
- assertTrue("Wrong actual maximum value for HOUR_OF_DAY", gc1
- .getActualMaximum(Calendar.HOUR_OF_DAY) == 23);
- assertTrue("Wrong actual maximum value for HOUR", gc1
- .getActualMaximum(Calendar.HOUR) == 11);
- assertTrue("Wrong actual maximum value for DAY_OF_WEEK_IN_MONTH", gc6
- .getActualMaximum(Calendar.DAY_OF_WEEK_IN_MONTH) == 4);
+ assertEquals("Wrong actual maximum value for HOUR_OF_DAY", 23, gc1
+ .getActualMaximum(Calendar.HOUR_OF_DAY));
+ assertEquals("Wrong actual maximum value for HOUR", 11, gc1
+ .getActualMaximum(Calendar.HOUR));
+ assertEquals("Wrong actual maximum value for DAY_OF_WEEK_IN_MONTH", 4, gc6
+ .getActualMaximum(Calendar.DAY_OF_WEEK_IN_MONTH));
}
/**
@@ -302,16 +302,16 @@
new GregorianCalendar(2000, 1, 1);
new GregorianCalendar(2000, 9, 9);
GregorianCalendar gc6 = new GregorianCalendar(2000, 3, 3);
- assertTrue("Wrong actual minimum value for DAY_OF_MONTH for Feb 1900",
- gc1.getActualMinimum(Calendar.DAY_OF_MONTH) == 1);
+ assertEquals("Wrong actual minimum value for DAY_OF_MONTH for Feb 1900",
+ 1, gc1.getActualMinimum(Calendar.DAY_OF_MONTH));
assertTrue("Wrong actual minimum value for MONTH", gc1
.getActualMinimum(Calendar.MONTH) == Calendar.JANUARY);
- assertTrue("Wrong actual minimum value for HOUR_OF_DAY", gc1
- .getActualMinimum(Calendar.HOUR_OF_DAY) == 0);
- assertTrue("Wrong actual minimum value for HOUR", gc1
- .getActualMinimum(Calendar.HOUR) == 0);
- assertTrue("Wrong actual minimum value for DAY_OF_WEEK_IN_MONTH", gc6
- .getActualMinimum(Calendar.DAY_OF_WEEK_IN_MONTH) == -1);
+ assertEquals("Wrong actual minimum value for HOUR_OF_DAY", 0, gc1
+ .getActualMinimum(Calendar.HOUR_OF_DAY));
+ assertEquals("Wrong actual minimum value for HOUR", 0, gc1
+ .getActualMinimum(Calendar.HOUR));
+ assertEquals("Wrong actual minimum value for DAY_OF_WEEK_IN_MONTH", -1, gc6
+ .getActualMinimum(Calendar.DAY_OF_WEEK_IN_MONTH));
}
/**
@@ -321,14 +321,14 @@
// Test for method int
// java.util.GregorianCalendar.getGreatestMinimum(int)
GregorianCalendar gc = new GregorianCalendar();
- assertTrue("Wrong greatest minimum value for DAY_OF_MONTH", gc
- .getGreatestMinimum(Calendar.DAY_OF_MONTH) == 1);
+ assertEquals("Wrong greatest minimum value for DAY_OF_MONTH", 1, gc
+ .getGreatestMinimum(Calendar.DAY_OF_MONTH));
assertTrue("Wrong greatest minimum value for MONTH", gc
.getGreatestMinimum(Calendar.MONTH) == Calendar.JANUARY);
- assertTrue("Wrong greatest minimum value for HOUR_OF_DAY", gc
- .getGreatestMinimum(Calendar.HOUR_OF_DAY) == 0);
- assertTrue("Wrong greatest minimum value for HOUR", gc
- .getGreatestMinimum(Calendar.HOUR) == 0);
+ assertEquals("Wrong greatest minimum value for HOUR_OF_DAY", 0, gc
+ .getGreatestMinimum(Calendar.HOUR_OF_DAY));
+ assertEquals("Wrong greatest minimum value for HOUR", 0, gc
+ .getGreatestMinimum(Calendar.HOUR));
BitSet result = new BitSet();
int[] min = { 0, 1, 0, 1, 0, 1, 1, 1, -1, 0, 0, 0, 0, 0, 0, -43200000,
@@ -350,12 +350,12 @@
GregorianCalendar returnedChange = new GregorianCalendar(TimeZone
.getTimeZone("EST"));
returnedChange.setTime(gc.getGregorianChange());
- assertTrue("Returned incorrect year",
- returnedChange.get(Calendar.YEAR) == 1582);
+ assertEquals("Returned incorrect year",
+ 1582, returnedChange.get(Calendar.YEAR));
assertTrue("Returned incorrect month", returnedChange
.get(Calendar.MONTH) == Calendar.OCTOBER);
- assertTrue("Returned incorrect day of month", returnedChange
- .get(Calendar.DAY_OF_MONTH) == 4);
+ assertEquals("Returned incorrect day of month", 4, returnedChange
+ .get(Calendar.DAY_OF_MONTH));
}
/**
@@ -364,14 +364,14 @@
public void test_getLeastMaximumI() {
// Test for method int java.util.GregorianCalendar.getLeastMaximum(int)
GregorianCalendar gc = new GregorianCalendar();
- assertTrue("Wrong least maximum value for DAY_OF_MONTH", gc
- .getLeastMaximum(Calendar.DAY_OF_MONTH) == 28);
+ assertEquals("Wrong least maximum value for DAY_OF_MONTH", 28, gc
+ .getLeastMaximum(Calendar.DAY_OF_MONTH));
assertTrue("Wrong least maximum value for MONTH", gc
.getLeastMaximum(Calendar.MONTH) == Calendar.DECEMBER);
- assertTrue("Wrong least maximum value for HOUR_OF_DAY", gc
- .getLeastMaximum(Calendar.HOUR_OF_DAY) == 23);
- assertTrue("Wrong least maximum value for HOUR", gc
- .getLeastMaximum(Calendar.HOUR) == 11);
+ assertEquals("Wrong least maximum value for HOUR_OF_DAY", 23, gc
+ .getLeastMaximum(Calendar.HOUR_OF_DAY));
+ assertEquals("Wrong least maximum value for HOUR", 11, gc
+ .getLeastMaximum(Calendar.HOUR));
BitSet result = new BitSet();
Vector values = new Vector();
@@ -393,14 +393,14 @@
public void test_getMaximumI() {
// Test for method int java.util.GregorianCalendar.getMaximum(int)
GregorianCalendar gc = new GregorianCalendar();
- assertTrue("Wrong maximum value for DAY_OF_MONTH", gc
- .getMaximum(Calendar.DAY_OF_MONTH) == 31);
+ assertEquals("Wrong maximum value for DAY_OF_MONTH", 31, gc
+ .getMaximum(Calendar.DAY_OF_MONTH));
assertTrue("Wrong maximum value for MONTH", gc
.getMaximum(Calendar.MONTH) == Calendar.DECEMBER);
- assertTrue("Wrong maximum value for HOUR_OF_DAY", gc
- .getMaximum(Calendar.HOUR_OF_DAY) == 23);
- assertTrue("Wrong maximum value for HOUR",
- gc.getMaximum(Calendar.HOUR) == 11);
+ assertEquals("Wrong maximum value for HOUR_OF_DAY", 23, gc
+ .getMaximum(Calendar.HOUR_OF_DAY));
+ assertEquals("Wrong maximum value for HOUR",
+ 11, gc.getMaximum(Calendar.HOUR));
BitSet result = new BitSet();
Vector values = new Vector();
@@ -422,14 +422,14 @@
public void test_getMinimumI() {
// Test for method int java.util.GregorianCalendar.getMinimum(int)
GregorianCalendar gc = new GregorianCalendar();
- assertTrue("Wrong minimum value for DAY_OF_MONTH", gc
- .getMinimum(Calendar.DAY_OF_MONTH) == 1);
+ assertEquals("Wrong minimum value for DAY_OF_MONTH", 1, gc
+ .getMinimum(Calendar.DAY_OF_MONTH));
assertTrue("Wrong minimum value for MONTH", gc
.getMinimum(Calendar.MONTH) == Calendar.JANUARY);
- assertTrue("Wrong minimum value for HOUR_OF_DAY", gc
- .getMinimum(Calendar.HOUR_OF_DAY) == 0);
- assertTrue("Wrong minimum value for HOUR",
- gc.getMinimum(Calendar.HOUR) == 0);
+ assertEquals("Wrong minimum value for HOUR_OF_DAY", 0, gc
+ .getMinimum(Calendar.HOUR_OF_DAY));
+ assertEquals("Wrong minimum value for HOUR",
+ 0, gc.getMinimum(Calendar.HOUR));
BitSet result = new BitSet();
int[] min = { 0, 1, 0, 1, 0, 1, 1, 1, -1, 0, 0, 0, 0, 0, 0, -43200000,
@@ -507,14 +507,14 @@
} catch (IllegalArgumentException e) {
result = 1;
}
- assertTrue("ZONE_OFFSET roll", result == 1);
+ assertEquals("ZONE_OFFSET roll", 1, result);
try {
cal.roll(Calendar.DST_OFFSET, true);
result = 0;
} catch (IllegalArgumentException e) {
result = 1;
}
- assertTrue("ZONE_OFFSET roll", result == 1);
+ assertEquals("ZONE_OFFSET roll", 1, result);
cal.set(2004, Calendar.DECEMBER, 31, 5, 0, 0);
cal.roll(Calendar.WEEK_OF_YEAR, true);
Modified: incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/tests/api/java/util/HashMapTest.java
URL: http://svn.apache.org/viewcvs/incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/tests/api/java/util/HashMapTest.java?rev=397123&r1=397122&r2=397123&view=diff
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/tests/api/java/util/HashMapTest.java (original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/tests/api/java/util/HashMapTest.java Wed Apr 26 00:12:16 2006
@@ -54,7 +54,7 @@
new Support_MapTest2(new HashMap()).runTest();
HashMap hm2 = new HashMap();
- assertTrue("Created incorrect HashMap", hm2.size() == 0);
+ assertEquals("Created incorrect HashMap", 0, hm2.size());
}
/**
@@ -63,7 +63,7 @@
public void test_ConstructorI() {
// Test for method java.util.HashMap(int)
HashMap hm2 = new HashMap(5);
- assertTrue("Created incorrect HashMap", hm2.size() == 0);
+ assertEquals("Created incorrect HashMap", 0, hm2.size());
try {
new HashMap(-1);
} catch (IllegalArgumentException e) {
@@ -73,7 +73,7 @@
"Failed to throw IllegalArgumentException for initial capacity < 0");
HashMap empty = new HashMap(0);
- assertTrue("Empty hashmap access", empty.get("nothing") == null);
+ assertNull("Empty hashmap access", empty.get("nothing"));
empty.put("something", "here");
assertTrue("cannot get element", empty.get("something") == "here");
}
@@ -84,7 +84,7 @@
public void test_ConstructorIF() {
// Test for method java.util.HashMap(int, float)
HashMap hm2 = new HashMap(5, (float) 0.5);
- assertTrue("Created incorrect HashMap", hm2.size() == 0);
+ assertEquals("Created incorrect HashMap", 0, hm2.size());
try {
new HashMap(0, 0);
} catch (IllegalArgumentException e) {
@@ -94,7 +94,7 @@
"Failed to throw IllegalArgumentException for initial load factor <= 0");
HashMap empty = new HashMap(0, 0.75f);
- assertTrue("Empty hashtable access", empty.get("nothing") == null);
+ assertNull("Empty hashtable access", empty.get("nothing"));
empty.put("something", "here");
assertTrue("cannot get element", empty.get("something") == "here");
}
@@ -119,10 +119,10 @@
public void test_clear() {
// Test for method void java.util.HashMap.clear()
hm.clear();
- assertTrue("Clear failed to reset size", hm.size() == 0);
+ assertEquals("Clear failed to reset size", 0, hm.size());
for (int i = 0; i < hmSize; i++)
- assertTrue("Failed to clear all elements",
- hm.get(objArray2[i]) == null);
+ assertNull("Failed to clear all elements",
+ hm.get(objArray2[i]));
}
@@ -142,23 +142,23 @@
// get the keySet() and values() on the original Map
Set keys = map.keySet();
Collection values = map.values();
- assertTrue("values() does not work", values.iterator().next().equals(
- "value"));
- assertTrue("keySet() does not work", keys.iterator().next().equals(
- "key"));
+ assertEquals("values() does not work",
+ "value", values.iterator().next());
+ assertEquals("keySet() does not work",
+ "key", keys.iterator().next());
AbstractMap map2 = (AbstractMap) map.clone();
map2.put("key", "value2");
Collection values2 = map2.values();
assertTrue("values() is identical", values2 != values);
// values() and keySet() on the cloned() map should be different
- assertTrue("values() was not cloned", values2.iterator().next().equals(
- "value2"));
+ assertEquals("values() was not cloned",
+ "value2", values2.iterator().next());
map2.clear();
map2.put("key2", "value3");
Set key2 = map2.keySet();
assertTrue("keySet() is identical", key2 != keys);
- assertTrue("keySet() was not cloned", key2.iterator().next().equals(
- "key2"));
+ assertEquals("keySet() was not cloned",
+ "key2", key2.iterator().next());
}
/**
@@ -212,17 +212,17 @@
public void test_getLjava_lang_Object() {
// Test for method java.lang.Object
// java.util.HashMap.get(java.lang.Object)
- assertTrue("Get returned non-null for non existent key",
- hm.get("T") == null);
+ assertNull("Get returned non-null for non existent key",
+ hm.get("T"));
hm.put("T", "HELLO");
- assertTrue("Get returned incorecct value for existing key", hm.get("T")
- .equals("HELLO"));
+ assertEquals("Get returned incorecct value for existing key", "HELLO", hm.get("T")
+ );
HashMap m = new HashMap();
m.put(null, "test");
- assertTrue("Failed with null key", m.get(null).equals("test"));
- assertTrue("Failed with missing key matching null hash", m
- .get(new Integer(0)) == null);
+ assertEquals("Failed with null key", "test", m.get(null));
+ assertNull("Failed with missing key matching null hash", m
+ .get(new Integer(0)));
// Regression for HARMONY-206
ReusableKey k = new ReusableKey();
@@ -260,7 +260,7 @@
HashMap m = new HashMap();
m.put(null, "test");
assertTrue("Failed with null key", m.keySet().contains(null));
- assertTrue("Failed with null key", m.keySet().iterator().next() == null);
+ assertNull("Failed with null key", m.keySet().iterator().next());
Map map = new HashMap(101);
map.put(new Integer(1), "1");
@@ -277,7 +277,7 @@
list.remove(remove1);
list.remove(remove2);
assertTrue("Wrong result", it.next().equals(list.get(0)));
- assertTrue("Wrong size", map.size() == 1);
+ assertEquals("Wrong size", 1, map.size());
assertTrue("Wrong contents", map.keySet().iterator().next().equals(
list.get(0)));
@@ -294,7 +294,7 @@
it2.hasNext();
it2.remove();
assertTrue("Wrong result 2", it2.next().equals(next));
- assertTrue("Wrong size 2", map2.size() == 1);
+ assertEquals("Wrong size 2", 1, map2.size());
assertTrue("Wrong contents 2", map2.keySet().iterator().next().equals(
next));
}
@@ -306,17 +306,17 @@
// Test for method java.lang.Object
// java.util.HashMap.put(java.lang.Object, java.lang.Object)
hm.put("KEY", "VALUE");
- assertTrue("Failed to install key/value pair", hm.get("KEY").equals(
- "VALUE"));
+ assertEquals("Failed to install key/value pair",
+ "VALUE", hm.get("KEY"));
HashMap m = new HashMap();
m.put(new Short((short) 0), "short");
m.put(null, "test");
m.put(new Integer(0), "int");
- assertTrue("Failed adding to bucket containing null", m.get(
- new Short((short) 0)).equals("short"));
- assertTrue("Failed adding to bucket containing null2", m.get(
- new Integer(0)).equals("int"));
+ assertEquals("Failed adding to bucket containing null", "short", m.get(
+ new Short((short) 0)));
+ assertEquals("Failed adding to bucket containing null2", "int", m.get(
+ new Integer(0)));
}
/**
@@ -341,16 +341,16 @@
Integer y = new Integer(9);
Integer x = ((Integer) hm.remove(y.toString()));
assertTrue("Remove returned incorrect value", x.equals(new Integer(9)));
- assertTrue("Failed to remove given key", hm.get(new Integer(9)) == null);
+ assertNull("Failed to remove given key", hm.get(new Integer(9)));
assertTrue("Failed to decrement size", hm.size() == (size - 1));
- assertTrue("Remove of non-existent key returned non-null", hm
- .remove("LCLCLC") == null);
+ assertNull("Remove of non-existent key returned non-null", hm
+ .remove("LCLCLC"));
HashMap m = new HashMap();
m.put(null, "test");
- assertTrue("Failed with same hash as null",
- m.remove(new Integer(0)) == null);
- assertTrue("Failed with null key", m.remove(null).equals("test"));
+ assertNull("Failed with same hash as null",
+ m.remove(new Integer(0)));
+ assertEquals("Failed with null key", "test", m.remove(null));
}
/**
Modified: incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/tests/api/java/util/HashSetTest.java
URL: http://svn.apache.org/viewcvs/incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/tests/api/java/util/HashSetTest.java?rev=397123&r1=397122&r2=397123&view=diff
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/tests/api/java/util/HashSetTest.java (original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/tests/api/java/util/HashSetTest.java Wed Apr 26 00:12:16 2006
@@ -37,7 +37,7 @@
public void test_Constructor() {
// Test for method java.util.HashSet()
HashSet hs2 = new HashSet();
- assertTrue("Created incorrect HashSet", hs2.size() == 0);
+ assertEquals("Created incorrect HashSet", 0, hs2.size());
}
/**
@@ -46,7 +46,7 @@
public void test_ConstructorI() {
// Test for method java.util.HashSet(int)
HashSet hs2 = new HashSet(5);
- assertTrue("Created incorrect HashSet", hs2.size() == 0);
+ assertEquals("Created incorrect HashSet", 0, hs2.size());
try {
new HashSet(-1);
} catch (IllegalArgumentException e) {
@@ -62,7 +62,7 @@
public void test_ConstructorIF() {
// Test for method java.util.HashSet(int, float)
HashSet hs2 = new HashSet(5, (float) 0.5);
- assertTrue("Created incorrect HashSet", hs2.size() == 0);
+ assertEquals("Created incorrect HashSet", 0, hs2.size());
try {
new HashSet(0, 0);
} catch (IllegalArgumentException e) {
@@ -107,7 +107,7 @@
Set orgSet = (Set) hs.clone();
hs.clear();
Iterator i = orgSet.iterator();
- assertTrue("Returned non-zero size after clear", hs.size() == 0);
+ assertEquals("Returned non-zero size after clear", 0, hs.size());
while (i.hasNext())
assertTrue("Failed to clear set", !hs.contains(i.next()));
}
@@ -161,7 +161,7 @@
HashSet s = new HashSet();
s.add(null);
- assertTrue("Cannot handle null", s.iterator().next() == null);
+ assertNull("Cannot handle null", s.iterator().next());
}
/**
@@ -186,7 +186,7 @@
// Test for method int java.util.HashSet.size()
assertTrue("Returned incorrect size", hs.size() == (objArray.length + 1));
hs.clear();
- assertTrue("Cleared set returned non-zero size", hs.size() == 0);
+ assertEquals("Cleared set returned non-zero size", 0, hs.size());
}
/**
Modified: incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/tests/api/java/util/HashtableTest.java
URL: http://svn.apache.org/viewcvs/incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/tests/api/java/util/HashtableTest.java?rev=397123&r1=397122&r2=397123&view=diff
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/tests/api/java/util/HashtableTest.java (original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/tests/api/java/util/HashtableTest.java Wed Apr 26 00:12:16 2006
@@ -56,7 +56,7 @@
Hashtable h = new Hashtable();
- assertTrue("Created incorrect hashtable", h.size() == 0);
+ assertEquals("Created incorrect hashtable", 0, h.size());
}
/**
@@ -66,10 +66,10 @@
// Test for method java.util.Hashtable(int)
Hashtable h = new Hashtable(9);
- assertTrue("Created incorrect hashtable", h.size() == 0);
+ assertEquals("Created incorrect hashtable", 0, h.size());
Hashtable empty = new Hashtable(0);
- assertTrue("Empty hashtable access", empty.get("nothing") == null);
+ assertNull("Empty hashtable access", empty.get("nothing"));
empty.put("something", "here");
assertTrue("cannot get element", empty.get("something") == "here");
}
@@ -80,10 +80,10 @@
public void test_ConstructorIF() {
// Test for method java.util.Hashtable(int, float)
Hashtable h = new java.util.Hashtable(10, 0.5f);
- assertTrue("Created incorrect hashtable", h.size() == 0);
+ assertEquals("Created incorrect hashtable", 0, h.size());
Hashtable empty = new Hashtable(0, 0.75f);
- assertTrue("Empty hashtable access", empty.get("nothing") == null);
+ assertNull("Empty hashtable access", empty.get("nothing"));
empty.put("something", "here");
assertTrue("cannot get element", empty.get("something") == "here");
}
@@ -112,7 +112,7 @@
// Test for method void java.util.Hashtable.clear()
Hashtable h = hashtableClone(htfull);
h.clear();
- assertTrue("Hashtable was not cleared", h.size() == 0);
+ assertEquals("Hashtable was not cleared", 0, h.size());
Enumeration el = h.elements();
Enumeration keys = h.keys();
assertTrue("Hashtable improperly cleared", !el.hasMoreElements()
@@ -190,7 +190,7 @@
++i;
}
- assertTrue("All keys not retrieved", ht10.size() == 10);
+ assertEquals("All keys not retrieved", 10, ht10.size());
}
/**
@@ -216,10 +216,10 @@
try {
// cached "12"
Object result = en.nextElement();
- assertTrue("unexpected: " + result, result == null);
+ assertNull("unexpected: " + result, result);
// next is removed "9"
result = en.nextElement();
- assertTrue("unexpected: " + result, result == null);
+ assertNull("unexpected: " + result, result);
result = en.nextElement();
assertTrue("unexpected: " + result, "b".equals(result));
} catch (NoSuchElementException e) {
@@ -243,8 +243,8 @@
assertTrue("Returned incorrect entry set", s2.contains(e
.nextElement()));
- assertTrue("Not synchronized", s.getClass().getName().equals(
- "java.util.Collections$SynchronizedSet"));
+ assertEquals("Not synchronized",
+ "java.util.Collections$SynchronizedSet", s.getClass().getName());
boolean exception = false;
try {
@@ -274,8 +274,8 @@
// Test for method java.lang.Object
// java.util.Hashtable.get(java.lang.Object)
Hashtable h = hashtableClone(htfull);
- assertTrue("Could not retrieve element", ((String) h.get("FKey 2"))
- .equals("FVal 2"));
+ assertEquals("Could not retrieve element", "FVal 2", ((String) h.get("FKey 2"))
+ );
// Regression for HARMONY-262
@@ -357,7 +357,7 @@
++i;
}
- assertTrue("All keys not retrieved", ht10.size() == 10);
+ assertEquals("All keys not retrieved", 10, ht10.size());
}
/**
@@ -391,8 +391,8 @@
assertTrue("Returned incorrect key set", s
.contains(e.nextElement()));
- assertTrue("Not synchronized", s.getClass().getName().equals(
- "java.util.Collections$SynchronizedSet"));
+ assertEquals("Not synchronized",
+ "java.util.Collections$SynchronizedSet", s.getClass().getName());
Map map = new Hashtable(101);
map.put(new Integer(1), "1");
@@ -408,7 +408,7 @@
list.remove(remove1);
list.remove(remove2);
assertTrue("Wrong result", it.next().equals(list.get(0)));
- assertTrue("Wrong size", map.size() == 1);
+ assertEquals("Wrong size", 1, map.size());
assertTrue("Wrong contents", map.keySet().iterator().next().equals(
list.get(0)));
@@ -425,7 +425,7 @@
it2.hasNext();
it2.remove();
assertTrue("Wrong result 2", it2.next().equals(next));
- assertTrue("Wrong size 2", map2.size() == 1);
+ assertEquals("Wrong size 2", 1, map2.size());
assertTrue("Wrong contents 2", map2.keySet().iterator().next().equals(
next));
}
@@ -595,8 +595,8 @@
public void test_toString() {
// Test for method java.lang.String java.util.Hashtable.toString()
Hashtable h = new Hashtable();
- assertTrue("Incorrect toString for Empty table", h.toString().equals(
- "{}"));
+ assertEquals("Incorrect toString for Empty table",
+ "{}", h.toString());
h.put("one", "1");
h.put("two", h);
@@ -616,8 +616,8 @@
while (e.hasMoreElements())
assertTrue("Returned incorrect values", c.contains(e.nextElement()));
- assertTrue("Not synchronized", c.getClass().getName().equals(
- "java.util.Collections$SynchronizedCollection"));
+ assertEquals("Not synchronized",
+ "java.util.Collections$SynchronizedCollection", c.getClass().getName());
Hashtable myHashtable = new Hashtable();
for (int i = 0; i < 100; i++)
Modified: incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/tests/api/java/util/IdentityHashMap2Test.java
URL: http://svn.apache.org/viewcvs/incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/tests/api/java/util/IdentityHashMap2Test.java?rev=397123&r1=397122&r2=397123&view=diff
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/tests/api/java/util/IdentityHashMap2Test.java (original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/tests/api/java/util/IdentityHashMap2Test.java Wed Apr 26 00:12:16 2006
@@ -40,9 +40,9 @@
result = map.put(null, null);
assertTrue("testA can not find null key", map.containsKey(null));
assertTrue("testA can not find null value", map.containsValue(null));
- assertTrue("testA can not get null value for null key",
- map.get(null) == null);
- assertTrue("testA put returned wrong value", result == null);
+ assertNull("testA can not get null value for null key",
+ map.get(null));
+ assertNull("testA put returned wrong value", result);
// null value
String value = "a value";
@@ -52,7 +52,7 @@
.containsValue(value));
assertTrue("testB can not get value for null key",
map.get(null) == value);
- assertTrue("testB put returned wrong value", result == null);
+ assertNull("testB put returned wrong value", result);
// a null key
String key = "a key";
@@ -60,8 +60,8 @@
assertTrue("testC can not find a key with null value", map
.containsKey(key));
assertTrue("testC can not find null value", map.containsValue(null));
- assertTrue("testC can not get null value for key", map.get(key) == null);
- assertTrue("testC put returned wrong value", result == null);
+ assertNull("testC can not get null value for key", map.get(key));
+ assertNull("testC put returned wrong value", result);
// another null key
String anothervalue = "another value";
@@ -79,8 +79,8 @@
assertTrue("testE should not find null key", !map.containsKey(null));
assertTrue("testE should not find a value with null key", !map
.containsValue(anothervalue));
- assertTrue("testE should not get value for null key",
- map.get(null) == null);
+ assertNull("testE should not get value for null key",
+ map.get(null));
}
/**
@@ -100,7 +100,7 @@
assertTrue("Modified key2", map.get("key2") != null
&& map.get("key2") == "value2");
- assertTrue("Modified null entry", map.get(null) == null);
+ assertNull("Modified null entry", map.get(null));
}
/**
@@ -151,7 +151,7 @@
Set set = map.entrySet();
set.removeAll(set);
- assertTrue("did not remove all elements in the map", map.size() == 0);
+ assertEquals("did not remove all elements in the map", 0, map.size());
assertTrue("did not remove all elements in the entryset", set.isEmpty());
Iterator it = set.iterator();
@@ -170,7 +170,7 @@
Set set = map.keySet();
set.clear();
- assertTrue("did not remove all elements in the map", map.size() == 0);
+ assertEquals("did not remove all elements in the map", 0, map.size());
assertTrue("did not remove all elements in the keyset", set.isEmpty());
Iterator it = set.iterator();
@@ -224,7 +224,7 @@
.containsValue(value));
vals.clear();
- assertTrue("Did not remove all entries as expected", map.size() == 0);
+ assertEquals("Did not remove all entries as expected", 0, map.size());
}
/**
@@ -239,7 +239,7 @@
Set set = map.keySet();
set.removeAll(set);
- assertTrue("did not remove all elements in the map", map.size() == 0);
+ assertEquals("did not remove all elements in the map", 0, map.size());
assertTrue("did not remove all elements in the keyset", set.isEmpty());
Iterator it = set.iterator();
@@ -259,12 +259,12 @@
// retain all the elements
boolean result = set.retainAll(set);
assertTrue("retain all should return false", !result);
- assertTrue("did not retain all", set.size() == 1000);
+ assertEquals("did not retain all", 1000, set.size());
// send empty set to retainAll
result = set.retainAll(new TreeSet());
assertTrue("retain all should return true", result);
- assertTrue("did not remove all elements in the map", map.size() == 0);
+ assertEquals("did not remove all elements in the map", 0, map.size());
assertTrue("did not remove all elements in the keyset", set.isEmpty());
Iterator it = set.iterator();
Modified: incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/tests/api/java/util/IdentityHashMapTest.java
URL: http://svn.apache.org/viewcvs/incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/tests/api/java/util/IdentityHashMapTest.java?rev=397123&r1=397122&r2=397123&view=diff
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/tests/api/java/util/IdentityHashMapTest.java (original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/tests/api/java/util/IdentityHashMapTest.java Wed Apr 26 00:12:16 2006
@@ -59,7 +59,7 @@
new Support_MapTest2(new IdentityHashMap()).runTest();
IdentityHashMap hm2 = new IdentityHashMap();
- assertTrue("Created incorrect IdentityHashMap", hm2.size() == 0);
+ assertEquals("Created incorrect IdentityHashMap", 0, hm2.size());
}
/**
@@ -68,7 +68,7 @@
public void test_ConstructorI() {
// Test for method java.util.IdentityHashMap(int)
IdentityHashMap hm2 = new IdentityHashMap(5);
- assertTrue("Created incorrect IdentityHashMap", hm2.size() == 0);
+ assertEquals("Created incorrect IdentityHashMap", 0, hm2.size());
try {
new IdentityHashMap(-1);
} catch (IllegalArgumentException e) {
@@ -78,7 +78,7 @@
"Failed to throw IllegalArgumentException for initial capacity < 0");
IdentityHashMap empty = new IdentityHashMap(0);
- assertTrue("Empty IdentityHashMap access", empty.get("nothing") == null);
+ assertNull("Empty IdentityHashMap access", empty.get("nothing"));
empty.put("something", "here");
assertTrue("cannot get element", empty.get("something") == "here");
}
@@ -103,10 +103,10 @@
public void test_clear() {
// Test for method void java.util.IdentityHashMap.clear()
hm.clear();
- assertTrue("Clear failed to reset size", hm.size() == 0);
+ assertEquals("Clear failed to reset size", 0, hm.size());
for (int i = 0; i < hmSize; i++)
- assertTrue("Failed to clear all elements",
- hm.get(objArray2[i]) == null);
+ assertNull("Failed to clear all elements",
+ hm.get(objArray2[i]));
}
@@ -126,23 +126,23 @@
// get the keySet() and values() on the original Map
Set keys = map.keySet();
Collection values = map.values();
- assertTrue("values() does not work", values.iterator().next().equals(
- "value"));
- assertTrue("keySet() does not work", keys.iterator().next().equals(
- "key"));
+ assertEquals("values() does not work",
+ "value", values.iterator().next());
+ assertEquals("keySet() does not work",
+ "key", keys.iterator().next());
AbstractMap map2 = (AbstractMap) map.clone();
map2.put("key", "value2");
Collection values2 = map2.values();
assertTrue("values() is identical", values2 != values);
// values() and keySet() on the cloned() map should be different
- assertTrue("values() was not cloned", values2.iterator().next().equals(
- "value2"));
+ assertEquals("values() was not cloned",
+ "value2", values2.iterator().next());
map2.clear();
map2.put("key2", "value3");
Set key2 = map2.keySet();
assertTrue("keySet() is identical", key2 != keys);
- assertTrue("keySet() was not cloned", key2.iterator().next().equals(
- "key2"));
+ assertEquals("keySet() was not cloned",
+ "key2", key2.iterator().next());
}
/**
@@ -198,17 +198,17 @@
public void test_getLjava_lang_Object() {
// Test for method java.lang.Object
// java.util.IdentityHashMap.get(java.lang.Object)
- assertTrue("Get returned non-null for non existent key",
- hm.get("T") == null);
+ assertNull("Get returned non-null for non existent key",
+ hm.get("T"));
hm.put("T", "HELLO");
- assertTrue("Get returned incorecct value for existing key", hm.get("T")
- .equals("HELLO"));
+ assertEquals("Get returned incorecct value for existing key", "HELLO", hm.get("T")
+ );
IdentityHashMap m = new IdentityHashMap();
m.put(null, "test");
- assertTrue("Failed with null key", m.get(null).equals("test"));
- assertTrue("Failed with missing key matching null hash", m
- .get(new Integer(0)) == null);
+ assertEquals("Failed with null key", "test", m.get(null));
+ assertNull("Failed with missing key matching null hash", m
+ .get(new Integer(0)));
}
/**
@@ -236,7 +236,7 @@
IdentityHashMap m = new IdentityHashMap();
m.put(null, "test");
assertTrue("Failed with null key", m.keySet().contains(null));
- assertTrue("Failed with null key", m.keySet().iterator().next() == null);
+ assertNull("Failed with null key", m.keySet().iterator().next());
Map map = new IdentityHashMap(101);
map.put(new Integer(1), "1");
@@ -253,7 +253,7 @@
list.remove(remove1);
list.remove(remove2);
assertTrue("Wrong result", it.next().equals(list.get(0)));
- assertTrue("Wrong size", map.size() == 1);
+ assertEquals("Wrong size", 1, map.size());
assertTrue("Wrong contents", map.keySet().iterator().next().equals(
list.get(0)));
@@ -270,7 +270,7 @@
it2.hasNext();
it2.remove();
assertTrue("Wrong result 2", it2.next().equals(next));
- assertTrue("Wrong size 2", map2.size() == 1);
+ assertEquals("Wrong size 2", 1, map2.size());
assertTrue("Wrong contents 2", map2.keySet().iterator().next().equals(
next));
}
@@ -282,8 +282,8 @@
// Test for method java.lang.Object
// java.util.IdentityHashMap.put(java.lang.Object, java.lang.Object)
hm.put("KEY", "VALUE");
- assertTrue("Failed to install key/value pair", hm.get("KEY").equals(
- "VALUE"));
+ assertEquals("Failed to install key/value pair",
+ "VALUE", hm.get("KEY"));
IdentityHashMap m = new IdentityHashMap();
Short s0 = new Short((short) 0);
@@ -291,10 +291,10 @@
m.put(null, "test");
Integer i0 = new Integer(0);
m.put(i0, "int");
- assertTrue("Failed adding to bucket containing null", m.get(s0).equals(
- "short"));
- assertTrue("Failed adding to bucket containing null2", m.get(i0)
- .equals("int"));
+ assertEquals("Failed adding to bucket containing null",
+ "short", m.get(s0));
+ assertEquals("Failed adding to bucket containing null2", "int", m.get(i0)
+ );
}
/**
@@ -318,16 +318,16 @@
int size = hm.size();
Integer x = ((Integer) hm.remove(objArray2[9]));
assertTrue("Remove returned incorrect value", x.equals(new Integer(9)));
- assertTrue("Failed to remove given key", hm.get(objArray2[9]) == null);
+ assertNull("Failed to remove given key", hm.get(objArray2[9]));
assertTrue("Failed to decrement size", hm.size() == (size - 1));
- assertTrue("Remove of non-existent key returned non-null", hm
- .remove("LCLCLC") == null);
+ assertNull("Remove of non-existent key returned non-null", hm
+ .remove("LCLCLC"));
IdentityHashMap m = new IdentityHashMap();
m.put(null, "test");
- assertTrue("Failed with same hash as null",
- m.remove(objArray[0]) == null);
- assertTrue("Failed with null key", m.remove(null).equals("test"));
+ assertNull("Failed with same hash as null",
+ m.remove(objArray[0]));
+ assertEquals("Failed with null key", "test", m.remove(null));
}
/**
Modified: incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/tests/api/java/util/LinkedHashMapTest.java
URL: http://svn.apache.org/viewcvs/incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/tests/api/java/util/LinkedHashMapTest.java?rev=397123&r1=397122&r2=397123&view=diff
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/tests/api/java/util/LinkedHashMapTest.java (original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/tests/api/java/util/LinkedHashMapTest.java Wed Apr 26 00:12:16 2006
@@ -63,7 +63,7 @@
new Support_MapTest2(new LinkedHashMap()).runTest();
LinkedHashMap hm2 = new LinkedHashMap();
- assertTrue("Created incorrect LinkedHashMap", hm2.size() == 0);
+ assertEquals("Created incorrect LinkedHashMap", 0, hm2.size());
}
/**
@@ -72,7 +72,7 @@
public void test_ConstructorI() {
// Test for method java.util.LinkedHashMap(int)
LinkedHashMap hm2 = new LinkedHashMap(5);
- assertTrue("Created incorrect LinkedHashMap", hm2.size() == 0);
+ assertEquals("Created incorrect LinkedHashMap", 0, hm2.size());
try {
new LinkedHashMap(-1);
} catch (IllegalArgumentException e) {
@@ -82,7 +82,7 @@
"Failed to throw IllegalArgumentException for initial capacity < 0");
LinkedHashMap empty = new LinkedHashMap(0);
- assertTrue("Empty LinkedHashMap access", empty.get("nothing") == null);
+ assertNull("Empty LinkedHashMap access", empty.get("nothing"));
empty.put("something", "here");
assertTrue("cannot get element", empty.get("something") == "here");
}
@@ -93,7 +93,7 @@
public void test_ConstructorIF() {
// Test for method java.util.LinkedHashMap(int, float)
LinkedHashMap hm2 = new LinkedHashMap(5, (float) 0.5);
- assertTrue("Created incorrect LinkedHashMap", hm2.size() == 0);
+ assertEquals("Created incorrect LinkedHashMap", 0, hm2.size());
try {
new LinkedHashMap(0, 0);
} catch (IllegalArgumentException e) {
@@ -102,7 +102,7 @@
fail(
"Failed to throw IllegalArgumentException for initial load factor <= 0");
LinkedHashMap empty = new LinkedHashMap(0, 0.75f);
- assertTrue("Empty hashtable access", empty.get("nothing") == null);
+ assertNull("Empty hashtable access", empty.get("nothing"));
empty.put("something", "here");
assertTrue("cannot get element", empty.get("something") == "here");
}
@@ -127,17 +127,17 @@
public void test_getLjava_lang_Object() {
// Test for method java.lang.Object
// java.util.LinkedHashMap.get(java.lang.Object)
- assertTrue("Get returned non-null for non existent key",
- hm.get("T") == null);
+ assertNull("Get returned non-null for non existent key",
+ hm.get("T"));
hm.put("T", "HELLO");
- assertTrue("Get returned incorecct value for existing key", hm.get("T")
- .equals("HELLO"));
+ assertEquals("Get returned incorecct value for existing key", "HELLO", hm.get("T")
+ );
LinkedHashMap m = new LinkedHashMap();
m.put(null, "test");
- assertTrue("Failed with null key", m.get(null).equals("test"));
- assertTrue("Failed with missing key matching null hash", m
- .get(new Integer(0)) == null);
+ assertEquals("Failed with null key", "test", m.get(null));
+ assertNull("Failed with missing key matching null hash", m
+ .get(new Integer(0)));
}
/**
@@ -147,17 +147,17 @@
// Test for method java.lang.Object
// java.util.LinkedHashMap.put(java.lang.Object, java.lang.Object)
hm.put("KEY", "VALUE");
- assertTrue("Failed to install key/value pair", hm.get("KEY").equals(
- "VALUE"));
+ assertEquals("Failed to install key/value pair",
+ "VALUE", hm.get("KEY"));
LinkedHashMap m = new LinkedHashMap();
m.put(new Short((short) 0), "short");
m.put(null, "test");
m.put(new Integer(0), "int");
- assertTrue("Failed adding to bucket containing null", m.get(
- new Short((short) 0)).equals("short"));
- assertTrue("Failed adding to bucket containing null2", m.get(
- new Integer(0)).equals("int"));
+ assertEquals("Failed adding to bucket containing null", "short", m.get(
+ new Short((short) 0)));
+ assertEquals("Failed adding to bucket containing null2", "int", m.get(
+ new Integer(0)));
}
/**
@@ -202,7 +202,7 @@
LinkedHashMap m = new LinkedHashMap();
m.put(null, "test");
assertTrue("Failed with null key", m.keySet().contains(null));
- assertTrue("Failed with null key", m.keySet().iterator().next() == null);
+ assertNull("Failed with null key", m.keySet().iterator().next());
Map map = new LinkedHashMap(101);
map.put(new Integer(1), "1");
@@ -219,7 +219,7 @@
list.remove(remove1);
list.remove(remove2);
assertTrue("Wrong result", it.next().equals(list.get(0)));
- assertTrue("Wrong size", map.size() == 1);
+ assertEquals("Wrong size", 1, map.size());
assertTrue("Wrong contents", map.keySet().iterator().next().equals(
list.get(0)));
@@ -236,7 +236,7 @@
it2.hasNext();
it2.remove();
assertTrue("Wrong result 2", it2.next().equals(next));
- assertTrue("Wrong size 2", map2.size() == 1);
+ assertEquals("Wrong size 2", 1, map2.size());
assertTrue("Wrong contents 2", map2.keySet().iterator().next().equals(
next));
}
@@ -277,16 +277,16 @@
Integer y = new Integer(9);
Integer x = ((Integer) hm.remove(y.toString()));
assertTrue("Remove returned incorrect value", x.equals(new Integer(9)));
- assertTrue("Failed to remove given key", hm.get(new Integer(9)) == null);
+ assertNull("Failed to remove given key", hm.get(new Integer(9)));
assertTrue("Failed to decrement size", hm.size() == (size - 1));
- assertTrue("Remove of non-existent key returned non-null", hm
- .remove("LCLCLC") == null);
+ assertNull("Remove of non-existent key returned non-null", hm
+ .remove("LCLCLC"));
LinkedHashMap m = new LinkedHashMap();
m.put(null, "test");
- assertTrue("Failed with same hash as null",
- m.remove(new Integer(0)) == null);
- assertTrue("Failed with null key", m.remove(null).equals("test"));
+ assertNull("Failed with same hash as null",
+ m.remove(new Integer(0)));
+ assertEquals("Failed with null key", "test", m.remove(null));
}
/**
@@ -295,10 +295,10 @@
public void test_clear() {
// Test for method void java.util.LinkedHashMap.clear()
hm.clear();
- assertTrue("Clear failed to reset size", hm.size() == 0);
+ assertEquals("Clear failed to reset size", 0, hm.size());
for (int i = 0; i < hmSize; i++)
- assertTrue("Failed to clear all elements",
- hm.get(objArray2[i]) == null);
+ assertNull("Failed to clear all elements",
+ hm.get(objArray2[i]));
}
@@ -318,24 +318,24 @@
// get the keySet() and values() on the original Map
Set keys = map.keySet();
Collection values = map.values();
- assertTrue("values() does not work", values.iterator().next().equals(
- "value"));
- assertTrue("keySet() does not work", keys.iterator().next().equals(
- "key"));
+ assertEquals("values() does not work",
+ "value", values.iterator().next());
+ assertEquals("keySet() does not work",
+ "key", keys.iterator().next());
AbstractMap map2 = (AbstractMap) map.clone();
map2.put("key", "value2");
Collection values2 = map2.values();
assertTrue("values() is identical", values2 != values);
// values() and keySet() on the cloned() map should be different
- assertTrue("values() was not cloned", values2.iterator().next().equals(
- "value2"));
+ assertEquals("values() was not cloned",
+ "value2", values2.iterator().next());
map2.clear();
map2.put("key2", "value3");
Set key2 = map2.keySet();
assertTrue("keySet() is identical", key2 != keys);
- assertTrue("keySet() was not cloned", key2.iterator().next().equals(
- "key2"));
+ assertEquals("keySet() was not cloned",
+ "key2", key2.iterator().next());
}
/**
@@ -428,7 +428,7 @@
String ii = (String) lruhm.get(new Integer(i));
p = p + Integer.parseInt(ii);
}
- assertTrue("invalid sum of even numbers", p == 2450);
+ assertEquals("invalid sum of even numbers", 2450, p);
Set s2 = lruhm.entrySet();
Iterator it2 = s2.iterator();
@@ -487,7 +487,7 @@
String ii = (String) lruhm.get(new Integer(i));
p = p + Integer.parseInt(ii);
}
- assertTrue("invalid sum of even numbers", p == 2450);
+ assertEquals("invalid sum of even numbers", 2450, p);
Set s2 = lruhm.keySet();
Iterator it2 = s2.iterator();
Modified: incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/tests/api/java/util/LinkedHashSetTest.java
URL: http://svn.apache.org/viewcvs/incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/tests/api/java/util/LinkedHashSetTest.java?rev=397123&r1=397122&r2=397123&view=diff
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/tests/api/java/util/LinkedHashSetTest.java (original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/tests/api/java/util/LinkedHashSetTest.java Wed Apr 26 00:12:16 2006
@@ -40,7 +40,7 @@
public void test_Constructor() {
// Test for method java.util.LinkedHashSet()
LinkedHashSet hs2 = new LinkedHashSet();
- assertTrue("Created incorrect LinkedHashSet", hs2.size() == 0);
+ assertEquals("Created incorrect LinkedHashSet", 0, hs2.size());
}
/**
@@ -49,7 +49,7 @@
public void test_ConstructorI() {
// Test for method java.util.LinkedHashSet(int)
LinkedHashSet hs2 = new LinkedHashSet(5);
- assertTrue("Created incorrect LinkedHashSet", hs2.size() == 0);
+ assertEquals("Created incorrect LinkedHashSet", 0, hs2.size());
try {
new LinkedHashSet(-1);
} catch (IllegalArgumentException e) {
@@ -65,7 +65,7 @@
public void test_ConstructorIF() {
// Test for method java.util.LinkedHashSet(int, float)
LinkedHashSet hs2 = new LinkedHashSet(5, (float) 0.5);
- assertTrue("Created incorrect LinkedHashSet", hs2.size() == 0);
+ assertEquals("Created incorrect LinkedHashSet", 0, hs2.size());
try {
new LinkedHashSet(0, 0);
} catch (IllegalArgumentException e) {
@@ -110,7 +110,7 @@
Set orgSet = (Set) hs.clone();
hs.clear();
Iterator i = orgSet.iterator();
- assertTrue("Returned non-zero size after clear", hs.size() == 0);
+ assertEquals("Returned non-zero size after clear", 0, hs.size());
while (i.hasNext())
assertTrue("Failed to clear set", !hs.contains(i.next()));
}
@@ -172,7 +172,7 @@
LinkedHashSet s = new LinkedHashSet();
s.add(null);
- assertTrue("Cannot handle null", s.iterator().next() == null);
+ assertNull("Cannot handle null", s.iterator().next());
}
/**
@@ -198,7 +198,7 @@
// Test for method int java.util.LinkedHashSet.size()
assertTrue("Returned incorrect size", hs.size() == (objArray.length + 1));
hs.clear();
- assertTrue("Cleared set returned non-zero size", hs.size() == 0);
+ assertEquals("Cleared set returned non-zero size", 0, hs.size());
}
/**
Modified: incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/tests/api/java/util/LinkedListTest.java
URL: http://svn.apache.org/viewcvs/incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/tests/api/java/util/LinkedListTest.java?rev=397123&r1=397122&r2=397123&view=diff
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/tests/api/java/util/LinkedListTest.java (original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/tests/api/java/util/LinkedListTest.java Wed Apr 26 00:12:16 2006
@@ -70,7 +70,7 @@
assertTrue("Failed to fix up list after insert",
ll.get(51) == objArray[50] && (ll.get(52) == objArray[51]));
ll.add(50, null);
- assertTrue("Did not add null correctly", ll.get(50) == null);
+ assertNull("Did not add null correctly", ll.get(50));
}
/**
@@ -82,7 +82,7 @@
ll.add(o = new Object());
assertTrue("Failed to add Object", ll.getLast() == o);
ll.add(null);
- assertTrue("Did not add null correctly", ll.get(ll.size() - 1) == null);
+ assertNull("Did not add null correctly", ll.get(ll.size() - 1));
}
/**
@@ -92,8 +92,8 @@
// Test for method boolean java.util.LinkedList.addAll(int,
// java.util.Collection)
ll.addAll(50, (Collection) ll.clone());
- assertTrue("Returned incorrect size after adding to existing list", ll
- .size() == 200);
+ assertEquals("Returned incorrect size after adding to existing list", 200, ll
+ .size());
for (int i = 0; i < 50; i++)
assertTrue("Manipulated elements < index", ll.get(i) == objArray[i]);
for (int i = 0; i >= 50 && (i < 150); i++)
@@ -109,13 +109,13 @@
myList.add("Booga");
myList.add(null);
ll.addAll(50, myList);
- assertTrue("a) List w/nulls not added correctly", ll.get(50) == null);
- assertTrue("b) List w/nulls not added correctly", ll.get(51).equals(
- "Blah"));
- assertTrue("c) List w/nulls not added correctly", ll.get(52) == null);
- assertTrue("d) List w/nulls not added correctly", ll.get(53).equals(
- "Booga"));
- assertTrue("e) List w/nulls not added correctly", ll.get(54) == null);
+ assertNull("a) List w/nulls not added correctly", ll.get(50));
+ assertEquals("b) List w/nulls not added correctly",
+ "Blah", ll.get(51));
+ assertNull("c) List w/nulls not added correctly", ll.get(52));
+ assertEquals("d) List w/nulls not added correctly",
+ "Booga", ll.get(53));
+ assertNull("e) List w/nulls not added correctly", ll.get(54));
}
/**
@@ -130,8 +130,8 @@
assertTrue("Failed to add elements properly", l.get(i).equals(
ll.get(i)));
ll.addAll((Collection) ll.clone());
- assertTrue("Returned incorrect siZe after adding to existing list", ll
- .size() == 200);
+ assertEquals("Returned incorrect siZe after adding to existing list", 200, ll
+ .size());
for (int i = 0; i < 100; i++) {
assertTrue("Added to list in incorrect order", ll.get(i).equals(
l.get(i)));
@@ -145,13 +145,13 @@
myList.add("Booga");
myList.add(null);
ll.addAll(myList);
- assertTrue("a) List w/nulls not added correctly", ll.get(200) == null);
- assertTrue("b) List w/nulls not added correctly", ll.get(201).equals(
- "Blah"));
- assertTrue("c) List w/nulls not added correctly", ll.get(202) == null);
- assertTrue("d) List w/nulls not added correctly", ll.get(203).equals(
- "Booga"));
- assertTrue("e) List w/nulls not added correctly", ll.get(204) == null);
+ assertNull("a) List w/nulls not added correctly", ll.get(200));
+ assertEquals("b) List w/nulls not added correctly",
+ "Blah", ll.get(201));
+ assertNull("c) List w/nulls not added correctly", ll.get(202));
+ assertEquals("d) List w/nulls not added correctly",
+ "Booga", ll.get(203));
+ assertNull("e) List w/nulls not added correctly", ll.get(204));
}
/**
@@ -163,7 +163,7 @@
ll.addFirst(o = new Object());
assertTrue("Failed to add Object", ll.getFirst() == o);
ll.addFirst(null);
- assertTrue("Failed to add null", ll.getFirst() == null);
+ assertNull("Failed to add null", ll.getFirst());
}
/**
@@ -175,7 +175,7 @@
ll.addLast(o = new Object());
assertTrue("Failed to add Object", ll.getLast() == o);
ll.addLast(null);
- assertTrue("Failed to add null", ll.getLast() == null);
+ assertNull("Failed to add null", ll.getLast());
}
/**
@@ -185,7 +185,7 @@
// Test for method void java.util.LinkedList.clear()
ll.clear();
for (int i = 0; i < ll.size(); i++)
- assertTrue("Failed to clear list", ll.get(i) == null);
+ assertNull("Failed to clear list", ll.get(i));
}
/**
@@ -258,9 +258,9 @@
*/
public void test_indexOfLjava_lang_Object() {
// Test for method int java.util.LinkedList.indexOf(java.lang.Object)
- assertTrue("Returned incorrect index", ll.indexOf(objArray[87]) == 87);
- assertTrue("Returned index for invalid Object", ll
- .indexOf(new Object()) == -1);
+ assertEquals("Returned incorrect index", 87, ll.indexOf(objArray[87]));
+ assertEquals("Returned index for invalid Object", -1, ll
+ .indexOf(new Object()));
ll.add(20, null);
ll.add(24, null);
assertTrue("Index of null should be 20, but got: " + ll.indexOf(null),
@@ -274,10 +274,10 @@
// Test for method int
// java.util.LinkedList.lastIndexOf(java.lang.Object)
ll.add(new Integer(99));
- assertTrue("Returned incorrect index",
- ll.lastIndexOf(objArray[99]) == 100);
- assertTrue("Returned index for invalid Object", ll
- .lastIndexOf(new Object()) == -1);
+ assertEquals("Returned incorrect index",
+ 100, ll.lastIndexOf(objArray[99]));
+ assertEquals("Returned index for invalid Object", -1, ll
+ .lastIndexOf(new Object()));
ll.add(20, null);
ll.add(24, null);
assertTrue("Last index of null should be 20, but got: "
@@ -322,15 +322,15 @@
myList.add(null);
ListIterator li = myList.listIterator();
assertTrue("li.hasPrevious() should be false", !li.hasPrevious());
- assertTrue("li.next() should be null", li.next() == null);
+ assertNull("li.next() should be null", li.next());
assertTrue("li.hasPrevious() should be true", li.hasPrevious());
- assertTrue("li.prev() should be null", li.previous() == null);
- assertTrue("li.next() should be null", li.next() == null);
- assertTrue("li.next() should be Blah", li.next().equals("Blah"));
- assertTrue("li.next() should be null", li.next() == null);
- assertTrue("li.next() should be Booga", li.next().equals("Booga"));
+ assertNull("li.prev() should be null", li.previous());
+ assertNull("li.next() should be null", li.next());
+ assertEquals("li.next() should be Blah", "Blah", li.next());
+ assertNull("li.next() should be null", li.next());
+ assertEquals("li.next() should be Booga", "Booga", li.next());
assertTrue("li.hasNext() should be true", li.hasNext());
- assertTrue("li.next() should be null", li.next() == null);
+ assertNull("li.next() should be null", li.next());
assertTrue("li.hasNext() should be false", !li.hasNext());
}
@@ -340,7 +340,7 @@
public void test_removeI() {
// Test for method java.lang.Object java.util.LinkedList.remove(int)
ll.remove(10);
- assertTrue("Failed to remove element", ll.indexOf(objArray[10]) == -1);
+ assertEquals("Failed to remove element", -1, ll.indexOf(objArray[10]));
try {
ll.remove(999);
} catch (IndexOutOfBoundsException e) {
@@ -350,7 +350,7 @@
fail("Failed to throw expected exception when index out of range");
ll.add(20, null);
ll.remove(20);
- assertTrue("Should have removed null", ll.get(20) != null);
+ assertNotNull("Should have removed null", ll.get(20));
}
/**
@@ -360,7 +360,7 @@
// Test for method boolean java.util.LinkedList.remove(java.lang.Object)
assertTrue("Failed to remove valid Object", ll.remove(objArray[87]));
assertTrue("Removed invalid object", !ll.remove(new Object()));
- assertTrue("Found Object after removal", ll.indexOf(objArray[87]) == -1);
+ assertEquals("Found Object after removal", -1, ll.indexOf(objArray[87]));
ll.add(null);
ll.remove(null);
assertTrue("Should not contain null afrer removal", !ll.contains(null));
@@ -418,8 +418,8 @@
for (int i = 0; i < obj.length - 1; i++)
assertTrue("Returned incorrect array: " + i, obj[i] == objArray[i]);
- assertTrue("Returned incorrect array--end isn't null",
- obj[obj.length - 1] == null);
+ assertNull("Returned incorrect array--end isn't null",
+ obj[obj.length - 1]);
}
/**
@@ -439,8 +439,8 @@
assertTrue("Lists are not equal", li.next() == ri.next());
argArray = new Integer[1000];
retArray = ll.toArray(argArray);
- assertTrue("Failed to set first extra element to null", argArray[ll
- .size()] == null);
+ assertNull("Failed to set first extra element to null", argArray[ll
+ .size()]);
for (int i = 0; i < ll.size(); i++)
assertTrue("Returned incorrect array: " + i,
retArray[i] == objArray[i]);
Modified: incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/tests/api/java/util/LocaleTest.java
URL: http://svn.apache.org/viewcvs/incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/tests/api/java/util/LocaleTest.java?rev=397123&r1=397122&r2=397123&view=diff
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/tests/api/java/util/LocaleTest.java (original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/tests/api/java/util/LocaleTest.java Wed Apr 26 00:12:16 2006
@@ -99,7 +99,7 @@
Locale.setDefault(l);
Locale x = Locale.getDefault();
Locale.setDefault(org);
- assertTrue("Failed to get locale", x.toString().equals("fr_CA_WIN32"));
+ assertEquals("Failed to get locale", "fr_CA_WIN32", x.toString());
}
/**
@@ -118,8 +118,8 @@
public void test_getDisplayCountryLjava_util_Locale() {
// Test for method java.lang.String
// java.util.Locale.getDisplayCountry(java.util.Locale)
- assertTrue("Returned incorrect country", Locale.ITALY
- .getDisplayCountry(l).equals("Italie"));
+ assertEquals("Returned incorrect country", "Italie", Locale.ITALY
+ .getDisplayCountry(l));
}
/**
@@ -272,14 +272,14 @@
Locale.setDefault(l);
Locale x = Locale.getDefault();
Locale.setDefault(org);
- assertTrue("Failed to set locale", x.toString().equals("fr_CA_WIN32"));
+ assertEquals("Failed to set locale", "fr_CA_WIN32", x.toString());
Locale.setDefault(new Locale("tr", ""));
String res1 = "\u0069".toUpperCase();
String res2 = "\u0049".toLowerCase();
Locale.setDefault(org);
- assertTrue("Wrong toUppercase conversion", res1.equals("\u0130"));
- assertTrue("Wrong toLowercase conversion", res2.equals("\u0131"));
+ assertEquals("Wrong toUppercase conversion", "\u0130", res1);
+ assertEquals("Wrong toLowercase conversion", "\u0131", res2);
}
/**
@@ -287,21 +287,21 @@
*/
public void test_toString() {
// Test for method java.lang.String java.util.Locale.toString()
- assertTrue("Returned incorrect string representation", testLocale
- .toString().equals("en_CA_WIN32"));
+ assertEquals("Returned incorrect string representation", "en_CA_WIN32", testLocale
+ .toString());
Locale l = new Locale("en", "");
- assertTrue("Wrong representation 1", l.toString().equals("en"));
+ assertEquals("Wrong representation 1", "en", l.toString());
l = new Locale("", "CA");
- assertTrue("Wrong representation 2", l.toString().equals("_CA"));
+ assertEquals("Wrong representation 2", "_CA", l.toString());
l = new Locale("", "CA", "var");
- assertTrue("Wrong representation 2.5", l.toString().equals("_CA_var"));
+ assertEquals("Wrong representation 2.5", "_CA_var", l.toString());
l = new Locale("en", "", "WIN");
- assertTrue("Wrong representation 4", l.toString().equals("en__WIN"));
+ assertEquals("Wrong representation 4", "en__WIN", l.toString());
l = new Locale("en", "CA");
- assertTrue("Wrong representation 6", l.toString().equals("en_CA"));
+ assertEquals("Wrong representation 6", "en_CA", l.toString());
l = new Locale("en", "CA", "VAR");
- assertTrue("Wrong representation 7", l.toString().equals("en_CA_VAR"));
+ assertEquals("Wrong representation 7", "en_CA_VAR", l.toString());
}
/**
Modified: incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/tests/api/java/util/MissingResourceExceptionTest.java
URL: http://svn.apache.org/viewcvs/incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/tests/api/java/util/MissingResourceExceptionTest.java?rev=397123&r1=397122&r2=397123&view=diff
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/tests/api/java/util/MissingResourceExceptionTest.java (original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/tests/api/java/util/MissingResourceExceptionTest.java Wed Apr 26 00:12:16 2006
@@ -44,8 +44,8 @@
try {
ResourceBundle.getBundle("Non-ExistentBundle");
} catch (MissingResourceException e) {
- assertTrue("Returned incorrect class name", e.getClassName()
- .equals("Non-ExistentBundle"));
+ assertEquals("Returned incorrect class name", "Non-ExistentBundle", e.getClassName()
+ );
}
}