From 26775d7d13c71f39e00c66928171eca9c2899491 Mon Sep 17 00:00:00 2001 From: Jeff Genovy <29107334+jefgen@users.noreply.github.com> Date: Tue, 18 Aug 2020 11:00:46 -0700 Subject: [PATCH] ICU-21159 Fix memory leaks in cintltst TestUsingDefaultWarning. --- icu4c/source/test/cintltst/cloctst.c | 38 ++++++++++++++-------------- 1 file changed, 19 insertions(+), 19 deletions(-) diff --git a/icu4c/source/test/cintltst/cloctst.c b/icu4c/source/test/cintltst/cloctst.c index e3385b316ad..b6bc201034f 100644 --- a/icu4c/source/test/cintltst/cloctst.c +++ b/icu4c/source/test/cintltst/cloctst.c @@ -6747,70 +6747,70 @@ static void TestBug20149() { static void TestUsingDefaultWarning() { UChar buff[256]; - char cbuff[256]; + char errorOutputBuff[256]; UErrorCode status = U_ZERO_ERROR; const char* language = "jJj"; int32_t length = uloc_getDisplayLanguage(language, "de", buff, 256, &status); if (status != U_USING_DEFAULT_WARNING || - u_strcmp(buff, CharsToUChars("jjj")) != 0 || + u_strcmp(buff, u"jjj") != 0 || length != 3) { - u_UCharsToChars(buff, cbuff, length+1); + u_UCharsToChars(buff, errorOutputBuff, length+1); log_err("ERROR: in uloc_getDisplayLanguage %s return len:%d %s with status %d %s\n", - language, length, cbuff, status, myErrorName(status)); + language, length, errorOutputBuff, status, myErrorName(status)); } status = U_ZERO_ERROR; const char* script = "und-lALA"; length = uloc_getDisplayScript(script, "de", buff, 256, &status); if (status != U_USING_DEFAULT_WARNING || - u_strcmp(buff, CharsToUChars("Lala")) != 0 || + u_strcmp(buff, u"Lala") != 0 || length != 4) { - u_UCharsToChars(buff, cbuff, length+1); + u_UCharsToChars(buff, errorOutputBuff, length+1); log_err("ERROR: in uloc_getDisplayScript %s return len:%d %s with status %d %s\n", - script, length, cbuff, status, myErrorName(status)); + script, length, errorOutputBuff, status, myErrorName(status)); } status = U_ZERO_ERROR; const char* region = "und-wt"; length = uloc_getDisplayCountry(region, "de", buff, 256, &status); if (status != U_USING_DEFAULT_WARNING || - u_strcmp(buff, CharsToUChars("WT")) != 0 || + u_strcmp(buff, u"WT") != 0 || length != 2) { - u_UCharsToChars(buff, cbuff, length+1); + u_UCharsToChars(buff, errorOutputBuff, length+1); log_err("ERROR: in uloc_getDisplayCountry %s return len:%d %s with status %d %s\n", - region, length, cbuff, status, myErrorName(status)); + region, length, errorOutputBuff, status, myErrorName(status)); } status = U_ZERO_ERROR; const char* variant = "und-abcde"; length = uloc_getDisplayVariant(variant, "de", buff, 256, &status); if (status != U_USING_DEFAULT_WARNING || - u_strcmp(buff, CharsToUChars("ABCDE")) != 0 || + u_strcmp(buff, u"ABCDE") != 0 || length != 5) { - u_UCharsToChars(buff, cbuff, length+1); + u_UCharsToChars(buff, errorOutputBuff, length+1); log_err("ERROR: in uloc_getDisplayVariant %s return len:%d %s with status %d %s\n", - variant, length, cbuff, status, myErrorName(status)); + variant, length, errorOutputBuff, status, myErrorName(status)); } status = U_ZERO_ERROR; const char* keyword = "postCODE"; length = uloc_getDisplayKeyword(keyword, "de", buff, 256, &status); if (status != U_USING_DEFAULT_WARNING || - u_strcmp(buff, CharsToUChars("postCODE")) != 0 || + u_strcmp(buff, u"postCODE") != 0 || length != 8) { - u_UCharsToChars(buff, cbuff, length+1); + u_UCharsToChars(buff, errorOutputBuff, length+1); log_err("ERROR: in uloc_getDisplayKeyword %s return len:%d %s with status %d %s\n", - keyword, length, cbuff, status, myErrorName(status)); + keyword, length, errorOutputBuff, status, myErrorName(status)); } status = U_ZERO_ERROR; const char* keyword_value = "de_DE@postCode=fOObAR"; length = uloc_getDisplayKeywordValue(keyword_value, keyword, "de", buff, 256, &status); if (status != U_USING_DEFAULT_WARNING || - u_strcmp(buff, CharsToUChars("fOObAR")) != 0 || + u_strcmp(buff, u"fOObAR") != 0 || length != 6) { - u_UCharsToChars(buff, cbuff, length+1); + u_UCharsToChars(buff, errorOutputBuff, length+1); log_err("ERROR: in uloc_getDisplayKeywordValue %s %s return len:%d %s with status %d %s\n", - keyword_value, keyword, length, cbuff, status, myErrorName(status)); + keyword_value, keyword, length, errorOutputBuff, status, myErrorName(status)); } } -- 2.40.0