From 41231627e3385b3160d6fa421de6bc3cbc94f96c Mon Sep 17 00:00:00 2001 From: Narayan Kamath Date: Fri, 5 Sep 2014 11:33:45 +0100 Subject: 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 (cherry picked from commit 2f3e9b30fb2646b9c9294825cf91d2b0dc3b57c5) Change-Id: I80411926b129b926cbbd115b22ee651f9d8f6d1b --- luni/src/test/java/libcore/java/util/CalendarTest.java | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) (limited to 'luni/src') 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); + } } -- cgit v1.1