]> granicus.if.org Git - icu/commitdiff
ICU-21122 Fix flaky TestAdoptCalendarLeak
authorFrank Tang <ftang@chromium.org>
Thu, 14 May 2020 00:17:56 +0000 (17:17 -0700)
committerFrank Yung-Fong Tang <41213225+FrankYFTang@users.noreply.github.com>
Thu, 30 Jul 2020 03:39:55 +0000 (20:39 -0700)
icu4c/source/test/intltest/dtfmttst.cpp

index 59eb11ef145ec988f2d1a421a747e85ea9d67db6..945728d5e4f4fb70e838889326aac7be1e484151 100644 (file)
@@ -5576,14 +5576,19 @@ void DateFormatTest::TestAdoptCalendarLeak() {
     UErrorCode status = U_ZERO_ERROR;
     // This test relies on the locale fullName exceeding ULOC_FULLNAME_CAPACITY
     // in order for setKeywordValue to fail.
+    Calendar* cal = Calendar::createInstance(status);
+    ASSERT_OK(status);
     SimpleDateFormat sdf(
         "d.M.y",
         Locale("de__POSIX@colstrength=primary;currency=eur;em=default;"
                "hours=h23;lb=strict;lw=normal;measure=metric;numbers=latn;"
                "rg=atzzzz;sd=atat1;ss=none;timezone=Europe/Vienna"),
         status);
-    ASSERT_OK(status);
-    sdf.adoptCalendar(Calendar::createInstance(status));
+    // ASSERT_OK(status); Please do NOT add ASSERT_OK here. The point of this
+    // test is to ensure sdf.adoptCalendar won't leak AFTER the above FAILED.
+    // If the following caused crash we should fix the implementation not change
+    // this test.
+    sdf.adoptCalendar(cal);
 }
 
 /**