summaryrefslogtreecommitdiffstats
path: root/luni/src
diff options
context:
space:
mode:
authorNarayan Kamath <narayan@google.com>2014-09-05 11:33:45 +0100
committerNarayan Kamath <narayan@google.com>2014-09-05 11:54:11 +0100
commit2f3e9b30fb2646b9c9294825cf91d2b0dc3b57c5 (patch)
treeb6278c8224207b515dc956c5926f87f179d25d73 /luni/src
parent32adcb4a34b40479154390a4f92d85805712b58c (diff)
downloadlibcore-2f3e9b30fb2646b9c9294825cf91d2b0dc3b57c5.zip
libcore-2f3e9b30fb2646b9c9294825cf91d2b0dc3b57c5.tar.gz
libcore-2f3e9b30fb2646b9c9294825cf91d2b0dc3b57c5.tar.bz2
Make sure calendars are compared correctly.
The calendars will use System.currentTimeMillis if we don't explicitly call setTimeMillis or setTime. We don't particularly care about time here, we just need to check that all Locale derived fields are equal. bug: 17377252 Change-Id: Ibd5e74c237e5520580f1f44b4e98b021000639fa
Diffstat (limited to 'luni/src')
-rw-r--r--luni/src/test/java/libcore/java/util/CalendarTest.java14
1 files changed, 11 insertions, 3 deletions
diff --git a/luni/src/test/java/libcore/java/util/CalendarTest.java b/luni/src/test/java/libcore/java/util/CalendarTest.java
index b2f6b94..e0e1a35 100644
--- a/luni/src/test/java/libcore/java/util/CalendarTest.java
+++ b/luni/src/test/java/libcore/java/util/CalendarTest.java
@@ -17,6 +17,7 @@
package libcore.java.util;
import java.util.Calendar;
+import java.util.Date;
import java.util.GregorianCalendar;
import java.util.Locale;
import java.util.TimeZone;
@@ -245,14 +246,21 @@ public class CalendarTest extends junit.framework.TestCase {
// here. We should add a targetSdkVersion based check and throw for each of these
// cases.
public void test_nullLocale() {
- assertEquals(
+ assertCalendarConfigEquals(
Calendar.getInstance(Locale.getDefault()),
Calendar.getInstance((Locale) null));
- assertEquals(
+ assertCalendarConfigEquals(
Calendar.getInstance(TimeZone.getDefault(), Locale.getDefault()),
Calendar.getInstance(TimeZone.getDefault(), null));
- assertEquals(
+ assertCalendarConfigEquals(
new GregorianCalendar(Locale.getDefault()),
new GregorianCalendar((Locale) null));
}
+
+ public void assertCalendarConfigEquals(Calendar a, Calendar b) {
+ Date d = new Date();
+ a.setTime(d);
+ b.setTime(d);
+ assertEquals(a, b);
+ }
}