mirror of
https://github.com/unicode-org/icu.git
synced 2025-04-08 06:53:45 +00:00
ICU-3499 Increase code coverage
X-SVN-Rev: 15391
This commit is contained in:
parent
86383275f3
commit
6ff0093be3
2 changed files with 58 additions and 4 deletions
|
@ -250,6 +250,7 @@ static void TestLocalizedString(void) {
|
|||
UChar uBuffer[256];
|
||||
char cBuffer[256];
|
||||
int32_t numResult = -1;
|
||||
const char *locale;
|
||||
UFILE *strFile = u_fstropen(testStr, sizeof(testStr)/sizeof(testStr[0]), "en_US");
|
||||
|
||||
if (!strFile) {
|
||||
|
@ -259,14 +260,37 @@ static void TestLocalizedString(void) {
|
|||
u_fprintf(strFile, "%d", 1234);
|
||||
u_frewind(strFile);
|
||||
u_fscanf(strFile, "%d", &numResult);
|
||||
u_fclose(strFile);
|
||||
u_uastrcpy(uBuffer,"1,234");
|
||||
u_austrcpy(cBuffer,testStr);
|
||||
if (u_strcmp(testStr, uBuffer) != 0) {
|
||||
log_err("u_fprintf failed to work on a string Got: %s\n", cBuffer);
|
||||
log_err("u_fprintf failed to work on an en string Got: %s\n", cBuffer);
|
||||
}
|
||||
if (numResult != 1234) {
|
||||
log_err("u_fscanf failed to work on a string Got: %d\n", numResult);
|
||||
log_err("u_fscanf failed to work on an en string Got: %d\n", numResult);
|
||||
}
|
||||
|
||||
u_frewind(strFile);
|
||||
locale = u_fgetlocale(strFile);
|
||||
if (locale == NULL || strcmp(locale, "en_US") != 0) {
|
||||
log_err("u_fgetlocale didn't return \"en\" Got: %d\n", u_fgetlocale(strFile));
|
||||
}
|
||||
u_fsetlocale("de_DE", strFile);
|
||||
locale = u_fgetlocale(strFile);
|
||||
if (locale == NULL || strcmp(locale, "de_DE") != 0) {
|
||||
log_err("u_fgetlocale didn't return \"de\" Got: %d\n", u_fgetlocale(strFile));
|
||||
}
|
||||
|
||||
u_fprintf(strFile, "%d", 1234);
|
||||
u_frewind(strFile);
|
||||
u_fscanf(strFile, "%d", &numResult);
|
||||
u_fclose(strFile);
|
||||
u_uastrcpy(uBuffer,"1.234");
|
||||
u_austrcpy(cBuffer,testStr);
|
||||
if (u_strcmp(testStr, uBuffer) != 0) {
|
||||
log_err("u_fprintf failed to work on a de string Got: %s\n", cBuffer);
|
||||
}
|
||||
if (numResult != 1234) {
|
||||
log_err("u_fscanf failed to work on a de string Got: %d\n", numResult);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
32
icu4c/source/test/testdata/icuio.txt
vendored
32
icu4c/source/test/testdata/icuio.txt
vendored
|
@ -123,6 +123,21 @@ icuio {
|
|||
{
|
||||
"%hx", "8ace", "2", "8ace"
|
||||
}
|
||||
{
|
||||
"%lx", "8ace1234", "4", "8ace1234"
|
||||
}
|
||||
{
|
||||
"%llx", "123456789abcdef0", "8", "123456789abcdef0"
|
||||
}
|
||||
{
|
||||
"%lu", "2328760884", "4", "8ace1234"
|
||||
}
|
||||
{
|
||||
"%ld", "-1966206412", "4", "8ace1234"
|
||||
}
|
||||
{
|
||||
"%lld", "1311768467463790320", "8", "123456789abcdef0"
|
||||
}
|
||||
}
|
||||
}
|
||||
printfPrecision {
|
||||
|
@ -134,6 +149,15 @@ icuio {
|
|||
{
|
||||
"%+2.*e", "+1.234568e+000", "d", "1.2345678", :int{6}
|
||||
}
|
||||
{
|
||||
"%*d", "12345678", "4", "BC614E", :int{7}
|
||||
}
|
||||
{
|
||||
"%*d", "12345678", "4", "BC614E", :int{8}
|
||||
}
|
||||
{
|
||||
"%*d", " 12345678", "4", "BC614E", :int{9}
|
||||
}
|
||||
}
|
||||
}
|
||||
scanf {
|
||||
|
@ -179,7 +203,13 @@ icuio {
|
|||
"%[abce]", "abcd ef01", "S", "abc"
|
||||
}
|
||||
{
|
||||
"%*[abce]%[de\ ]", "abcd ef01", "S", "d e"
|
||||
"%*[abce]%[de\\ ]", "abcd ef01", "S", "d e"
|
||||
}
|
||||
{
|
||||
"%[a\U00010000]", "a\U00010000\U00010001b", "S", "a\U00010000"
|
||||
}
|
||||
{
|
||||
"%S", "a\U00010000b", "S", "a\U00010000b"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue