[automerger skipped] DO NOT MERGE Use explicitly opened file with O_WRONLY in test_sendfile_errno am: f0324559dd -s ours am: b800078f99 -s ours am: 4c2c16a044 -s ours am: 014b3ea94b -s ours am: 1ee27cb06b -s ours am: 599728ca03 -s ours am: 85d156bc83 -s ours am: 7494b7391a -s ours
am skip reason: subject contains skip directive
Original change: https://android-review.googlesource.com/c/platform/libcore/+/2241795
Change-Id: Ia6ea15cab466cad9b9d71125a47ab6d6ee7ed5c4
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
diff --git a/luni/src/test/java/libcore/java/text/DateFormatSymbolsTest.java b/luni/src/test/java/libcore/java/text/DateFormatSymbolsTest.java
index 3ea4378..baa3344 100644
--- a/luni/src/test/java/libcore/java/text/DateFormatSymbolsTest.java
+++ b/luni/src/test/java/libcore/java/text/DateFormatSymbolsTest.java
@@ -156,21 +156,40 @@
}
// http://b/7955614
- public void test_getZoneStrings_Apia() throws Exception {
+ public void test_getZoneStrings_Apia() {
String[][] array = DateFormatSymbols.getInstance(Locale.US).getZoneStrings();
+
for (int i = 0; i < array.length; ++i) {
String[] row = array[i];
// Pacific/Apia is somewhat arbitrary; we just want a zone we have to generate
// "GMT" strings for the short names.
if (row[0].equals("Pacific/Apia")) {
+ TimeZone apiaTz = TimeZone.getTimeZone("Pacific/Apia");
assertEquals("Apia Standard Time", row[1]);
- assertEquals("GMT+13:00", row[2]);
+ assertEquals(formattedStandardTimeOffset(apiaTz), row[2]);
assertEquals("Apia Daylight Time", row[3]);
- assertEquals("GMT+14:00", row[4]);
+ assertEquals(formattedDstOffset(apiaTz), row[4]);
}
}
}
+ private static String formattedStandardTimeOffset(TimeZone tz) {
+ return formattedOffset(tz.getRawOffset());
+ }
+
+ private static String formattedDstOffset(TimeZone tz) {
+ return formattedOffset(tz.getRawOffset() + tz.getDSTSavings());
+ }
+
+ private static String formattedOffset(int offset) {
+ String pattern = "GMT%+d:%02d";
+ int millisInHour = 60 * 60 * 1_000;
+ int hours = offset / millisInHour;
+ int minutes = (offset - hours * millisInHour) / 1_000 / 60;
+
+ return String.format(pattern, hours, minutes);
+ }
+
public void test_setZoneStrings_checks_dimensions() throws Exception {
DateFormatSymbols dfs = DateFormatSymbols.getInstance();
String[][] zoneStrings = dfs.getZoneStrings();
diff --git a/luni/src/test/java/libcore/java/util/TimeZoneTest.java b/luni/src/test/java/libcore/java/util/TimeZoneTest.java
index a686534..9b8ea47 100644
--- a/luni/src/test/java/libcore/java/util/TimeZoneTest.java
+++ b/luni/src/test/java/libcore/java/util/TimeZoneTest.java
@@ -319,12 +319,16 @@
}
// http://b/7955614
- public void testApia() throws Exception {
+ public void testApia() {
TimeZone tz = TimeZone.getTimeZone("Pacific/Apia");
assertEquals("Apia Daylight Time", tz.getDisplayName(true, TimeZone.LONG, Locale.US));
assertEquals("Apia Standard Time", tz.getDisplayName(false, TimeZone.LONG, Locale.US));
- assertEquals("GMT+14:00", tz.getDisplayName(true, TimeZone.SHORT, Locale.US));
- assertEquals("GMT+13:00", tz.getDisplayName(false, TimeZone.SHORT, Locale.US));
+
+ long samoaStandardTime = 1630315635000L; // 30 Aug 2021
+ long samoaDst = 1614504435000L; // 28 Feb 2021
+
+ assertEquals(13 * 60 * 60 * 1_000, tz.getOffset(samoaStandardTime));
+ assertEquals(14 * 60 * 60 * 1_000, tz.getOffset(samoaDst));
}
private static boolean isGmtString(String s) {