mirror of
https://github.com/unicode-org/icu.git
synced 2025-04-13 17:01:16 +00:00
ICU-3499 Add u_feof() test
X-SVN-Rev: 14993
This commit is contained in:
parent
95c021fb7c
commit
6977909227
2 changed files with 46 additions and 0 deletions
|
@ -81,6 +81,10 @@ static void TestFileFromICU(UFILE *myFile) {
|
|||
u_fprintf(myFile, "Percent %%P (non-ANSI): %P\n", myFloat);
|
||||
u_fprintf(myFile, "Spell Out %%V (non-ANSI): %V\n", myFloat);
|
||||
|
||||
if (u_feof(myFile)) {
|
||||
log_err("Got feof while writing the file.\n");
|
||||
}
|
||||
|
||||
*n = 1;
|
||||
u_fprintf(myFile, "\t\nPointer to integer (Count) %%n: n=%d %n n=%d\n", *n, n, *n);
|
||||
u_fprintf(myFile, "Pointer to integer Value: %d\n", *n);
|
||||
|
@ -97,6 +101,10 @@ static void TestFileFromICU(UFILE *myFile) {
|
|||
return;
|
||||
}
|
||||
|
||||
if (u_feof(myFile)) {
|
||||
log_err("Got feof while reading the file and not at the end of the file.\n");
|
||||
}
|
||||
|
||||
myUString[0] = u_fgetc(myFile);
|
||||
if (myUString[0] != 0x53 /* S */) {
|
||||
log_err("u_fgetc 1 returned %X. Expected 'S'.", myString[0]);
|
||||
|
@ -271,6 +279,24 @@ static void TestFileFromICU(UFILE *myFile) {
|
|||
log_err("u_fgets got \"%s\"\n", myString);
|
||||
}
|
||||
|
||||
u_austrncpy(myString, u_fgets(myUString, sizeof(myUString)/sizeof(*myUString), myFile),
|
||||
sizeof(myUString)/sizeof(*myUString));
|
||||
if (strcmp(myString, "Normal fprintf count: n=1 n=1\n") != 0) {
|
||||
log_err("u_fgets got \"%s\"\n", myString);
|
||||
}
|
||||
|
||||
if (u_feof(myFile)) {
|
||||
log_err("Got feof while reading the file and not at the end of the file.\n");
|
||||
}
|
||||
u_austrncpy(myString, u_fgets(myUString, sizeof(myUString)/sizeof(*myUString), myFile),
|
||||
sizeof(myUString)/sizeof(*myUString));
|
||||
if (strcmp(myString, "\tNormal fprintf count value: n=27\n") != 0) {
|
||||
log_err("u_fgets got \"%s\"\n", myString);
|
||||
}
|
||||
if (!u_feof(myFile)) {
|
||||
log_err("Got feof while reading the end of the file.\n");
|
||||
}
|
||||
|
||||
u_fclose(myFile);
|
||||
}
|
||||
|
||||
|
|
|
@ -570,6 +570,25 @@ static void TestSScanSetFormat(const char *format, const UChar *uValue, const ch
|
|||
}
|
||||
}
|
||||
|
||||
static void TestArgumentSkipping(void) {
|
||||
UChar uBuffer[256];
|
||||
char buffer[256];
|
||||
char compBuffer[256];
|
||||
int32_t uNumScanned;
|
||||
int32_t cNumScanned;
|
||||
char ch1 = 0, ch2 = 0;
|
||||
|
||||
/* Reinitialize the buffer to verify null termination works. */
|
||||
u_memset(uBuffer, 0x2a, sizeof(uBuffer)/sizeof(*uBuffer));
|
||||
uBuffer[sizeof(uBuffer)/sizeof(*uBuffer)-1] = 0;
|
||||
memset(buffer, 0x2a, sizeof(buffer)/sizeof(*buffer));
|
||||
buffer[sizeof(buffer)/sizeof(*buffer)-1] = 0;
|
||||
|
||||
strcpy(buffer, "123456789");
|
||||
u_uastrcpy(uBuffer, "123456789");
|
||||
uNumScanned = sscanf(buffer, "%*c%c", &ch1, &ch2);
|
||||
// uNumScanned = u_sscanf(uBuffer, NULL, "%*c%c", &ch1, &ch2);
|
||||
}
|
||||
static void TestSScanset(void) {
|
||||
static const UChar abcUChars[] = {0x61,0x62,0x63,0x63,0x64,0x65,0x66,0x67,0};
|
||||
static const char abcChars[] = "abccdefg";
|
||||
|
@ -618,6 +637,7 @@ addStringTest(TestNode** root) {
|
|||
addTest(root, &TestSprintfFormat, "string/TestSprintfFormat");
|
||||
addTest(root, &TestSnprintf, "string/TestSnprintf");
|
||||
addTest(root, &TestSScanset, "string/TestSScanset");
|
||||
addTest(root, &TestArgumentSkipping, "string/TestArgumentSkipping");
|
||||
addTest(root, &TestStringCompatibility, "string/TestStringCompatibility");
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue