81 |
|
|
82 |
free(characters); |
free(characters); |
83 |
|
|
84 |
|
#ifndef _WIN32 |
85 |
uint8_t utf16be[] = { |
uint8_t utf16be[] = { |
86 |
0, 'e', |
0, 'e', |
87 |
0, 0xe8, |
0, 0xe8, |
155 |
assert(characters[3] == 0xea); |
assert(characters[3] == 0xea); |
156 |
|
|
157 |
free(characters); |
free(characters); |
158 |
|
#endif |
159 |
|
|
160 |
/* bogus encoding */ |
/* bogus encoding */ |
161 |
uint8_t bogus[] = {'b', 'o', 'g', 'u', 's'}; |
uint8_t bogus[] = {'b', 'o', 'g', 'u', 's'}; |
164 |
|
|
165 |
assert(result == JSCOVERAGE_ERROR_ENCODING_NOT_SUPPORTED); |
assert(result == JSCOVERAGE_ERROR_ENCODING_NOT_SUPPORTED); |
166 |
|
|
167 |
|
#ifndef _WIN32 |
168 |
/* malformed US-ASCII */ |
/* malformed US-ASCII */ |
169 |
|
/* NOTE: Windows simply discards the high bit */ |
170 |
uint8_t malformed_ascii[] = { |
uint8_t malformed_ascii[] = { |
171 |
'e', |
'e', |
172 |
0xe8, |
0xe8, |
179 |
assert(result == JSCOVERAGE_ERROR_INVALID_BYTE_SEQUENCE); |
assert(result == JSCOVERAGE_ERROR_INVALID_BYTE_SEQUENCE); |
180 |
|
|
181 |
/* malformed UTF-8 */ |
/* malformed UTF-8 */ |
182 |
|
/* NOTE: Windows simply decodes as many bytes as it can, then it stops */ |
183 |
uint8_t malformed_utf8[] = { |
uint8_t malformed_utf8[] = { |
184 |
'e', |
'e', |
185 |
0xe8, |
0xe8, |
190 |
result = jscoverage_bytes_to_characters("UTF-8", malformed_utf8, 4, &characters, &num_characters); |
result = jscoverage_bytes_to_characters("UTF-8", malformed_utf8, 4, &characters, &num_characters); |
191 |
|
|
192 |
assert(result == JSCOVERAGE_ERROR_INVALID_BYTE_SEQUENCE); |
assert(result == JSCOVERAGE_ERROR_INVALID_BYTE_SEQUENCE); |
193 |
|
#endif |
194 |
|
|
195 |
return 0; |
return 0; |
196 |
} |
} |