ICU-6610 don't use macros as argument for U_STRING_INIT (fix and doc)
X-SVN-Rev: 24912
This commit is contained in:
parent
2b474170c5
commit
46fb1b9b1f
@ -917,6 +917,20 @@ u_memrchr32(const UChar *s, UChar32 c, int32_t count);
|
||||
* return u_strcmp(ustringVar1, ustringVar2);
|
||||
* }
|
||||
* </pre>
|
||||
*
|
||||
* Note that the macros will NOT consistently work if their argument is another
|
||||
* #define. The following will not work on all platforms, don't use it.
|
||||
*
|
||||
* <pre>
|
||||
* #define GLUCK "Mr. Gluck"
|
||||
* U_STRING_DECL(var, GLUCK, 9)
|
||||
* U_STRING_INIT(var, GLUCK, 9)
|
||||
* </pre>
|
||||
*
|
||||
* Instead, use the string literal "Mr. Gluck" as the argument to both macro
|
||||
* calls.
|
||||
*
|
||||
*
|
||||
* @stable ICU 2.0
|
||||
*/
|
||||
#if defined(U_DECLARE_UTF16)
|
||||
|
@ -204,17 +204,6 @@ testString(
|
||||
}
|
||||
}
|
||||
|
||||
#define EOF_TESTCASE_1 ""
|
||||
#define EOF_TESTCASE_2 "foo"
|
||||
#define EOF_TESTCASE_3 " "
|
||||
#define EOF_TESTCASE_4 " bar"
|
||||
#define EOF_TESTCASE_5 "bar "
|
||||
#define EOF_TESTCASE_6 " bar "
|
||||
|
||||
#define EOF_RESULT_EXPECTED_A ""
|
||||
#define EOF_RESULT_EXPECTED_B "foo"
|
||||
#define EOF_RESULT_EXPECTED_C "unchanged"
|
||||
#define EOF_RESULT_EXPECTED_D "bar"
|
||||
|
||||
static void U_CALLCONV TestStreamEOF(void)
|
||||
{
|
||||
@ -252,30 +241,30 @@ static void U_CALLCONV TestStreamEOF(void)
|
||||
|
||||
log_verbose("Testing operator >> for UnicodeString...\n");
|
||||
|
||||
/* The test cases needs to be converted to the default codepage. However, the stream operator needs char* so u_austrcpy is called. */
|
||||
U_STRING_DECL(testCase1, EOF_TESTCASE_1, 0);
|
||||
U_STRING_DECL(testCase2, EOF_TESTCASE_2, 3);
|
||||
U_STRING_DECL(testCase3, EOF_TESTCASE_3, 3);
|
||||
U_STRING_DECL(testCase4, EOF_TESTCASE_4, 6);
|
||||
U_STRING_DECL(testCase5, EOF_TESTCASE_5, 6);
|
||||
U_STRING_DECL(testCase6, EOF_TESTCASE_6, 9);
|
||||
/* The test cases needs to be converted to the default codepage. However, the stream operator needs char* so U_STRING_* is called. */
|
||||
U_STRING_DECL(testCase1, "", 0);
|
||||
U_STRING_INIT(testCase1, "", 0);
|
||||
U_STRING_DECL(testCase2, "foo", 3);
|
||||
U_STRING_INIT(testCase2, "foo", 3);
|
||||
U_STRING_DECL(testCase3, " ", 3);
|
||||
U_STRING_INIT(testCase3, " ", 3);
|
||||
U_STRING_DECL(testCase4, " bar", 6);
|
||||
U_STRING_INIT(testCase4, " bar", 6);
|
||||
U_STRING_DECL(testCase5, "bar ", 6);
|
||||
U_STRING_INIT(testCase5, "bar ", 6);
|
||||
U_STRING_DECL(testCase6, " bar ", 9);
|
||||
U_STRING_INIT(testCase6, " bar ", 9);
|
||||
|
||||
U_STRING_INIT(testCase1, EOF_TESTCASE_1, 0);
|
||||
U_STRING_INIT(testCase2, EOF_TESTCASE_2, 3);
|
||||
U_STRING_INIT(testCase3, EOF_TESTCASE_3, 3);
|
||||
U_STRING_INIT(testCase4, EOF_TESTCASE_4, 6);
|
||||
U_STRING_INIT(testCase5, EOF_TESTCASE_5, 6);
|
||||
U_STRING_INIT(testCase6, EOF_TESTCASE_6, 9);
|
||||
|
||||
U_STRING_DECL(expectedResultA, EOF_RESULT_EXPECTED_A, 0);
|
||||
U_STRING_DECL(expectedResultB, EOF_RESULT_EXPECTED_B, 3);
|
||||
U_STRING_DECL(expectedResultC, EOF_RESULT_EXPECTED_C, 9);
|
||||
U_STRING_DECL(expectedResultD, EOF_RESULT_EXPECTED_D, 3);
|
||||
U_STRING_DECL(expectedResultA, "", 0);
|
||||
U_STRING_INIT(expectedResultA, "", 0);
|
||||
U_STRING_DECL(expectedResultB, "foo", 3);
|
||||
U_STRING_INIT(expectedResultB, "foo", 3);
|
||||
U_STRING_DECL(expectedResultC, "unchanged", 9);
|
||||
U_STRING_INIT(expectedResultC, "unchanged", 9);
|
||||
U_STRING_DECL(expectedResultD, "bar", 3);
|
||||
U_STRING_INIT(expectedResultD, "bar", 3);
|
||||
|
||||
U_STRING_INIT(expectedResultA, EOF_RESULT_EXPECTED_A, 0);
|
||||
U_STRING_INIT(expectedResultB, EOF_RESULT_EXPECTED_B, 3);
|
||||
U_STRING_INIT(expectedResultC, EOF_RESULT_EXPECTED_C, 9);
|
||||
U_STRING_INIT(expectedResultD, EOF_RESULT_EXPECTED_D, 3);
|
||||
|
||||
UnicodeString UStr;
|
||||
UnicodeString expectedResults;
|
||||
|
Loading…
Reference in New Issue
Block a user