Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
W
wine-winehq
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
wine
wine-winehq
Commits
38027cda
Commit
38027cda
authored
Dec 12, 2014
by
Alex Henrie
Committed by
Alexandre Julliard
Dec 23, 2014
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
kernel32/tests: Add tabular UTF-7 encoding tests.
parent
9598a39b
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
136 additions
and
0 deletions
+136
-0
codepage.c
dlls/kernel32/tests/codepage.c
+136
-0
No files found.
dlls/kernel32/tests/codepage.c
View file @
38027cda
...
...
@@ -433,6 +433,114 @@ static void test_utf7_encoding(void)
static
const
char
base64_encoding_table
[]
=
"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"
;
const
struct
{
/* inputs */
WCHAR
src
[
16
];
int
srclen
;
char
*
dst
;
int
dstlen
;
/* expected outputs */
char
expected_dst
[
16
];
int
chars_written
;
int
len
;
}
tests
[]
=
{
/* tests string conversion with srclen=-1 */
{
{
0x4F60
,
0x597D
,
0x5417
,
0
},
-
1
,
output
,
sizeof
(
output
)
-
1
,
"+T2BZfVQX-"
,
11
,
11
},
/* tests string conversion with srclen=-2 */
{
{
0x4F60
,
0x597D
,
0x5417
,
0
},
-
2
,
output
,
sizeof
(
output
)
-
1
,
"+T2BZfVQX-"
,
11
,
11
},
/* tests string conversion with dstlen=strlen(expected_dst) */
{
{
0x4F60
,
0x597D
,
0x5417
,
0
},
-
1
,
output
,
10
,
"+T2BZfVQX-"
,
10
,
0
},
/* tests string conversion with dstlen=strlen(expected_dst)+1 */
{
{
0x4F60
,
0x597D
,
0x5417
,
0
},
-
1
,
output
,
11
,
"+T2BZfVQX-"
,
11
,
11
},
/* tests string conversion with dstlen=strlen(expected_dst)+2 */
{
{
0x4F60
,
0x597D
,
0x5417
,
0
},
-
1
,
output
,
12
,
"+T2BZfVQX-"
,
11
,
11
},
/* tests dry run with dst=NULL and dstlen=0 */
{
{
0x4F60
,
0x597D
,
0x5417
,
0
},
-
1
,
NULL
,
0
,
{},
0
,
11
},
/* tests dry run with dst!=NULL and dstlen=0 */
{
{
0x4F60
,
0x597D
,
0x5417
,
0
},
-
1
,
output
,
0
,
{},
0
,
11
},
/* tests srclen < strlenW(src) with directly encodable chars */
{
{
'h'
,
'e'
,
'l'
,
'l'
,
'o'
,
0
},
2
,
output
,
sizeof
(
output
)
-
1
,
"he"
,
2
,
2
},
/* tests srclen < strlenW(src) with non-directly encodable chars */
{
{
0x4F60
,
0x597D
,
0x5417
,
0
},
2
,
output
,
sizeof
(
output
)
-
1
,
"+T2BZfQ-"
,
8
,
8
},
/* tests a single null char */
{
{
0
},
-
1
,
output
,
sizeof
(
output
)
-
1
,
""
,
1
,
1
},
/* tests a buffer that runs out while not encoding a UTF-7 sequence */
{
{
'h'
,
'e'
,
'l'
,
'l'
,
'o'
,
0
},
-
1
,
output
,
2
,
"he"
,
2
,
0
},
/* tests a buffer that runs out after writing 1 base64 character */
{
{
0x4F60
,
0x0001
,
0
},
-
1
,
output
,
2
,
"+T"
,
2
,
0
},
/* tests a buffer that runs out after writing 2 base64 characters */
{
{
0x4F60
,
0x0001
,
0
},
-
1
,
output
,
3
,
"+T2"
,
3
,
0
},
/* tests a buffer that runs out after writing 3 base64 characters */
{
{
0x4F60
,
0x0001
,
0
},
-
1
,
output
,
4
,
"+T2A"
,
4
,
0
},
/* tests a buffer that runs out just after writing the + sign */
{
{
0x4F60
,
0
},
-
1
,
output
,
1
,
"+"
,
1
,
0
},
/* tests a buffer that runs out just before writing the - sign
* the number of bits to encode here is evenly divisible by 6 */
{
{
0x4F60
,
0x597D
,
0x5417
,
0
},
-
1
,
output
,
9
,
"+T2BZfVQX"
,
9
,
0
},
/* tests a buffer that runs out just before writing the - sign
* the number of bits to encode here is NOT evenly divisible by 6 */
{
{
0x4F60
,
0
},
-
1
,
output
,
4
,
"+T2"
,
3
,
0
},
/* tests a buffer that runs out in the middle of escaping a + sign */
{
{
'+'
,
0
},
-
1
,
output
,
1
,
"+"
,
1
,
0
}
};
if
(
WideCharToMultiByte
(
CP_UTF7
,
0
,
foobarW
,
-
1
,
NULL
,
0
,
NULL
,
NULL
)
==
0
&&
GetLastError
()
==
ERROR_CALL_NOT_IMPLEMENTED
)
{
...
...
@@ -525,6 +633,34 @@ static void test_utf7_encoding(void)
ok
(
output
[
expected_len
]
==
'#'
,
"i=0x%04x: expected output[%i]='#', got output[%i]=%i
\n
"
,
i
,
expected_len
,
expected_len
,
output
[
expected_len
]);
}
for
(
i
=
0
;
i
<
sizeof
(
tests
)
/
sizeof
(
tests
[
0
]);
i
++
)
{
memset
(
output
,
'#'
,
sizeof
(
output
)
-
1
);
output
[
sizeof
(
output
)
-
1
]
=
0
;
SetLastError
(
0xdeadbeef
);
len
=
WideCharToMultiByte
(
CP_UTF7
,
0
,
tests
[
i
].
src
,
tests
[
i
].
srclen
,
tests
[
i
].
dst
,
tests
[
i
].
dstlen
,
NULL
,
NULL
);
if
(
!
tests
[
i
].
len
)
{
ok
(
GetLastError
()
==
ERROR_INSUFFICIENT_BUFFER
,
"tests[%i]: expected error=0x%x, got error=0x%x
\n
"
,
i
,
ERROR_INSUFFICIENT_BUFFER
,
GetLastError
());
}
ok
(
len
==
tests
[
i
].
len
,
"tests[%i]: expected len=%i, got len=%i
\n
"
,
i
,
tests
[
i
].
len
,
len
);
if
(
tests
[
i
].
dst
)
{
ok
(
memcmp
(
tests
[
i
].
dst
,
tests
[
i
].
expected_dst
,
tests
[
i
].
chars_written
)
==
0
,
"tests[%i]: expected dst='%s', got dst='%s'
\n
"
,
i
,
tests
[
i
].
expected_dst
,
tests
[
i
].
dst
);
ok
(
tests
[
i
].
dst
[
tests
[
i
].
chars_written
]
==
'#'
,
"tests[%i]: expected dst[%i]='#', got dst[%i]=%i
\n
"
,
i
,
tests
[
i
].
chars_written
,
tests
[
i
].
chars_written
,
tests
[
i
].
dst
[
tests
[
i
].
chars_written
]);
}
}
}
static
void
test_utf7_decoding
(
void
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment