From ca4c5623ce7e4ced1c1cc06717b08cbd0ecb9552 Mon Sep 17 00:00:00 2001 From: Jason Spieth Date: Tue, 24 Mar 2009 04:43:23 +0000 Subject: [PATCH] ICU-3785 Test case to expose the error. X-SVN-Rev: 25646 --- icu4c/source/test/intltest/caltest.cpp | 43 ++++++++++++++++++++++++++ icu4c/source/test/intltest/caltest.h | 2 +- 2 files changed, 44 insertions(+), 1 deletion(-) diff --git a/icu4c/source/test/intltest/caltest.cpp b/icu4c/source/test/intltest/caltest.cpp index a5d052a8de0..b49848562ae 100644 --- a/icu4c/source/test/intltest/caltest.cpp +++ b/icu4c/source/test/intltest/caltest.cpp @@ -14,6 +14,10 @@ #include "unicode/smpdtfmt.h" #include "unicode/simpletz.h" #include "unicode/dbgutil.h" +#include "unicode/udat.h" +#include "unicode/ustring.h" + +#define mkcstr(U) u_austrcpy(calloc(8, u_strlen(U) + 1), U) // ***************************************************************************** // class CalendarTest @@ -210,6 +214,13 @@ void CalendarTest::runIndexedTest( int32_t index, UBool exec, const char* &name, Test6703(); } break; + case 23: + name = "Test3785"; + if(exec) { + logln("Test3785---"); logln(""); + Test3785(); + } + break; default: name = ""; break; } } @@ -2013,6 +2024,38 @@ void CalendarTest::Test6703() return; } +void CalendarTest::Test3785() +{ + UErrorCode status = U_ZERO_ERROR; + UChar uzone[] = {'E', 'u', 'r', 'o', 'p', 'e', '/', 'P', 'a', 'r', 'i', 's', 0}; + + UDateFormat * df = udat_open(UDAT_NONE, UDAT_NONE, "en@calendar=islamic", uzone, + u_strlen(uzone), NULL, 0, &status); + if (NULL == df || U_FAILURE(status)) return; + + UChar upattern[64]; + u_uastrcpy(upattern, "EEE d MMMM y G, HH:mm:ss"); + udat_applyPattern(df, FALSE, upattern, u_strlen(upattern)); + + UChar ubuffer[1024]; + UDate ud0 = 1337557623000.0; + + status = U_ZERO_ERROR; + udat_format(df, ud0, ubuffer, 1024, NULL, &status); + if (U_FAILURE(status)) return; + //printf("formatted: '%s'\n", mkcstr(ubuffer)); + + ud0 += 1000.0; // add one second + + status = U_ZERO_ERROR; + udat_format(df, ud0, ubuffer, 1024, NULL, &status); + if (U_FAILURE(status)) return; + //printf("formatted: '%s'\n", mkcstr(ubuffer)); + + return; +} + + #endif /* #if !UCONFIG_NO_FORMATTING */ diff --git a/icu4c/source/test/intltest/caltest.h b/icu4c/source/test/intltest/caltest.h index 7613add94e4..7b07acf8318 100644 --- a/icu4c/source/test/intltest/caltest.h +++ b/icu4c/source/test/intltest/caltest.h @@ -217,7 +217,7 @@ public: // package // internal - for other test use public: void Test6703(void); - + void Test3785(void); }; #endif /* #if !UCONFIG_NO_FORMATTING */