summaryrefslogtreecommitdiff
path: root/test/tests.c
diff options
context:
space:
mode:
Diffstat (limited to 'test/tests.c')
-rw-r--r--test/tests.c27
1 files changed, 15 insertions, 12 deletions
diff --git a/test/tests.c b/test/tests.c
index bb0b0d3..be94789 100644
--- a/test/tests.c
+++ b/test/tests.c
@@ -23,10 +23,10 @@ main(void)
/* Make sure it can decode every character */
{
long failures = 0;
- for (long i = 0; i < 0x1ffffL; i++) {
+ for (unsigned long i = 0; i < 0x1ffff; i++) {
if (!IS_SURROGATE(i)) {
int e;
- long c;
+ uint32_t c;
unsigned char buf[8] = {0};
unsigned char *end = utf8_encode(buf, i);
unsigned char *res = utf8_decode(buf, &c, &e);
@@ -39,9 +39,9 @@ main(void)
/* Does it reject all surrogate halves? */
{
long failures = 0;
- for (long i = 0xd800; i <= 0xdfff; i++) {
+ for (unsigned long i = 0xd800; i <= 0xdfff; i++) {
int e;
- long c;
+ uint32_t c;
unsigned char buf[8] = {0};
utf8_encode(buf, i);
utf8_decode(buf, &c, &e);
@@ -53,46 +53,49 @@ main(void)
/* How about non-canonical encodings? */
{
int e;
- long c;
+ uint32_t c;
unsigned char *end;
unsigned char buf2[8] = {0xc0, 0xA4};
end = utf8_decode(buf2, &c, &e);
TEST(e, "non-canonical len 2, 0x%02x", e);
- TEST(end == buf2 + 2, "non-canonical recover 2, U+%04lx", c);
+ TEST(end == buf2 + 2, "non-canonical recover 2, U+%04lx",
+ (unsigned long)c);
unsigned char buf3[8] = {0xe0, 0x80, 0xA4};
end = utf8_decode(buf3, &c, &e);
TEST(e, "non-canonical len 3, 0x%02x", e);
- TEST(end == buf3 + 3, "non-canonical recover 3, U+%04lx", c);
+ TEST(end == buf3 + 3, "non-canonical recover 3, U+%04lx",
+ (unsigned long)c);
unsigned char buf4[8] = {0xf0, 0x80, 0x80, 0xA4};
end = utf8_decode(buf4, &c, &e);
TEST(e, "non-canonical encoding len 4, 0x%02x", e);
- TEST(end == buf4 + 4, "non-canonical recover 4, U+%04lx", c);
+ TEST(end == buf4 + 4, "non-canonical recover 4, U+%04lx",
+ (unsigned long)c);
}
/* Let's try some bogus byte sequences */
{
int len, e;
- long c;
+ uint32_t c;
/* Invalid first byte */
unsigned char buf0[4] = {0xff};
len = (unsigned char *)utf8_decode(buf0, &c, &e) - buf0;
- TEST(e, "bogus [ff] 0x%02x U+%04lx", e, c);
+ TEST(e, "bogus [ff] 0x%02x U+%04lx", e, (unsigned long)c);
TEST(len == 1, "bogus [ff] recovery %d", len);
/* Invalid first byte */
unsigned char buf1[4] = {0x80};
len = (unsigned char *)utf8_decode(buf1, &c, &e) - buf1;
- TEST(e, "bogus [80] 0x%02x U+%04lx", e, c);
+ TEST(e, "bogus [80] 0x%02x U+%04lx", e, (unsigned long)c);
TEST(len == 1, "bogus [80] recovery %d", len);
/* Looks like a two-byte sequence but second byte is wrong */
unsigned char buf2[4] = {0xc0, 0x0a};
len = (unsigned char *)utf8_decode(buf2, &c, &e) - buf2;
- TEST(e, "bogus [c0 0a] 0x%02x U+%04lx", e, c);
+ TEST(e, "bogus [c0 0a] 0x%02x U+%04lx", e, (unsigned long)c);
TEST(len == 2, "bogus [c0 0a] recovery %d", len);
}