Skip to content

Commit

Permalink
test_enc_utf8: Suppress warnings
Browse files Browse the repository at this point in the history
* Comment out unused functions.
* Enable test_mbc_to_code().
  • Loading branch information
k-takata committed Jan 29, 2019
1 parent 4f1adda commit 8d958db
Showing 1 changed file with 19 additions and 18 deletions.
37 changes: 19 additions & 18 deletions test_enc_utf8.c
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@ static void x2(char* pattern, char* str, int from, int to)
xx(pattern, str, from, to, 0, 0);
}

#if 0
static void x3(char* pattern, char* str, int from, int to, int mem)
{
xx(pattern, str, from, to, mem, 0);
Expand All @@ -94,6 +95,7 @@ static void n(char* pattern, char* str)
{
xx(pattern, str, 0, 0, 0, 1);
}
#endif

const OnigEncodingType * target_encoding = ONIG_ENCODING_UTF8;

Expand Down Expand Up @@ -175,15 +177,15 @@ extern int main(int argc, char* argv[])
test_code_to_mbc(0x0080, "\xC2\x80", 0);
x2("\\x{0080}", "\xC2\x80", 0, 2);
x2("\xC2\x80", "\xC2\x80", 0, 2); // min 2 bytes

test_mbc_enc_len("\xC2\xC0", -1); // S0, S1, F

test_mbc_enc_len("\xDF\xBF", 2); // S0, S1, A
test_code_to_mbclen(0x07FF, 2);
test_code_to_mbc(0x07FF, "\xDF\xBF", 0);
x2("\\x{07FF}", "\xDF\xBF", 0, 2);
x2("\xDF\xBF", "\xDF\xBF", 0, 2); // max 2 bytes

test_mbc_enc_len("\xE0\xA0\x80", 3); // S0, S2, S1, A
test_code_to_mbclen(0x0800, 3);
test_code_to_mbc(0x0800, "\xE0\xA0\x80", 0);
Expand All @@ -197,23 +199,23 @@ extern int main(int argc, char* argv[])
test_code_to_mbc(0xFFFF, "\xEF\xBF\xBF", 0);
x2("\xEF\xBF\xBF", "\xEF\xBF\xBF", 0, 3);
x2("\\x{FFFF}", "\xEF\xBF\xBF", 0, 3); // max 3 bytes

test_mbc_enc_len("\xEF\xC0\xBF", -1); // S0, S3, F

test_mbc_enc_len("\xED\x80\x80", 3); // S0, S4, S1, A
test_code_to_mbclen(0xD000, 3);
test_code_to_mbc(0xD000, "\xED\x80\x80", 0);
x2("\xED\x80\x80", "\xED\x80\x80", 0, 3);
x2("\\x{D000}", "\xED\x80\x80", 0, 3);

test_mbc_enc_len("\xED\xA0\xA0", -1); // S0, S4, F

test_mbc_enc_len("\xF0\x90\x80\x80", 4); // S0, S5, S3, S1, A
test_code_to_mbclen(0x00010000, 4);
test_code_to_mbc(0x00010000, "\xF0\x90\x80\x80", 0);
x2("\xF0\x90\x80\x80", "\xF0\x90\x80\x80", 0, 4);
x2("\\x{00010000}", "\xF0\x90\x80\x80", 0, 4); // min 4 bytes

test_mbc_enc_len("\xF0\x80\x80\x80", -1); // S0, S5, F

test_mbc_enc_len("\xF4\x8F\xBF\xBF", 4); // S0, S7, S3, S1, A
Expand All @@ -230,39 +232,39 @@ extern int main(int argc, char* argv[])
test_code_to_mbc(0x001FFFFF, "\xF7\xBF\xBF\xBF", 0);
x2("\xF7\xBF\xBF\xBF", "\xF7\xBF\xBF\xBF", 0, 4);
x2("\\x{001FFFFF}", "\xF7\xBF\xBF\xBF", 0, 4); // max 4 bytes (21bits)

test_mbc_enc_len("\xF7\xC0\xBF\xBF", -1); // S0, S6, F

test_mbc_enc_len("\xF8\x88\x80\x80\x80", 5); // S0, S8, S6, S3, S1, A
test_code_to_mbclen(0x00200000, 5);
test_code_to_mbc(0x00200000, "\xF8\x88\x80\x80\x80", 0);
x2("\xF8\x88\x80\x80\x80", "\xF8\x88\x80\x80\x80", 0, 5);
x2("\\x{00200000}", "\xF8\x88\x80\x80\x80", 0, 5); // min 5 bytes

test_mbc_enc_len("\xF8\x80\x80\x80\x80", -1); // S0, S8, F

test_mbc_enc_len("\xFB\xBF\xBF\xBF\xBF", 5); // S0, S9, S6, S3, S1, A
test_code_to_mbclen(0x03FFFFFF, 5);
test_code_to_mbc(0x03FFFFFF, "\xFB\xBF\xBF\xBF\xBF", 0);
x2("\xFB\xBF\xBF\xBF\xBF", "\xFB\xBF\xBF\xBF\xBF", 0, 5);
x2("\\x{03FFFFFF}", "\xFB\xBF\xBF\xBF\xBF", 0, 5); // max 5 bytes

test_mbc_enc_len("\xFB\xC0\xBF\xBF\xBF", -1); // S0, S9, F

test_mbc_enc_len("\xFC\x84\x80\x80\x80\x80", 6); // S0, S10, S9, S6, S3, S1, A
test_code_to_mbclen(0x04000000, 6);
test_code_to_mbc(0x04000000, "\xFC\x84\x80\x80\x80\x80", 0);
x2("\xFC\x84\x80\x80\x80\x80", "\xFC\x84\x80\x80\x80\x80", 0, 6);
x2("\\x{04000000}", "\xFC\x84\x80\x80\x80\x80", 0, 6); // min 6 bytes

test_mbc_enc_len("\xFC\x80\x80\x80\x80\x80", -1); // S0, S10, F

test_mbc_enc_len("\xFD\xBF\xBF\xBF\xBF\xBF", 6); // S0, S11, S9, S6, S3, S1, A
test_code_to_mbclen(0x7FFFFFFF, 6);
test_code_to_mbc(0x7FFFFFFF, "\xFD\xBF\xBF\xBF\xBF\xBF", 0);
x2("\xFD\xBF\xBF\xBF\xBF\xBF", "\xFD\xBF\xBF\xBF\xBF\xBF", 0, 6);
x2("\\x{7FFFFFFF}", "\xFD\xBF\xBF\xBF\xBF\xBF", 0, 6); // max 6 bytes

test_mbc_enc_len("\xFD\xC0\xBF\xBF\xBF\xBF", -1); // S0, S11, F

test_code_to_mbclen(0x80000000, ONIGERR_TOO_BIG_WIDE_CHAR_VALUE);
Expand All @@ -273,12 +275,11 @@ extern int main(int argc, char* argv[])
test_code_to_mbc(0xFFFFFFFE, "\xFE", 0);
test_code_to_mbclen(0xFFFFFFFF, 1);
test_code_to_mbc(0xFFFFFFFF, "\xFF", 0);
#endif

test_mbc_to_code("\xFE", 0xFFFFFFFE);
test_mbc_to_code("\xFF", 0xFFFFFFFF);

#endif

fprintf(stdout,
"\nRESULT SUCC: %d, FAIL: %d, ERROR: %d (by Onigmo %s)\n",
nsucc, nfail, nerror, onig_version());
Expand Down

0 comments on commit 8d958db

Please sign in to comment.