fixing precedence issue in test
This commit is contained in:
parent
b053379db2
commit
e0599bad23
12
README.md
12
README.md
|
@ -6,12 +6,12 @@ Each creole line consists of pseudo-UTF-8 characters. The first byte
|
||||||
is an unsigned number between 0 and 127 (the high bit is clear). Each
|
is an unsigned number between 0 and 127 (the high bit is clear). Each
|
||||||
suceeding pseudo-UTF-8 character is encoded as follows:
|
suceeding pseudo-UTF-8 character is encoded as follows:
|
||||||
|
|
||||||
* `110xxxxx 10xxxxxx`
|
* `110HHHHx 10xxxxxx`
|
||||||
* `1110xxxx 10xxxxxx 10xxxxxx`
|
* `1110HHHH 10xxxxxx 10xxxxxx`
|
||||||
* `11110xxx 10xxxxxx 10xxxxxx 10xxxxxx`
|
* `11110HHH 10Hxxxxx 10xxxxxx 10xxxxxx`
|
||||||
* `111110xx 10xxxxxx 10xxxxxx 10xxxxxx 10xxxxxx`
|
* `111110HH 10HHxxxx 10xxxxxx 10xxxxxx 10xxxxxx`
|
||||||
* `1111110x 10xxxxxx 10xxxxxx 10xxxxxx 10xxxxxx 10xxxxxx`
|
* `1111110H 10HHHxxx 10xxxxxx 10xxxxxx 10xxxxxx 10xxxxxx`
|
||||||
* `11111110 10xxxxxx 10xxxxxx 10xxxxxx 10xxxxxx 10xxxxxx 10xxxxxx`
|
* `11111110 10HHHHxx 10xxxxxx 10xxxxxx 10xxxxxx 10xxxxxx 10xxxxxx`
|
||||||
|
|
||||||
The first four bytes determine the type:
|
The first four bytes determine the type:
|
||||||
|
|
||||||
|
|
|
@ -81,11 +81,9 @@ TEST encode_byte_seq(struct seq *s) {
|
||||||
unsigned char buf[7];
|
unsigned char buf[7];
|
||||||
|
|
||||||
for (;;) {
|
for (;;) {
|
||||||
/*
|
|
||||||
printf("0x%X ", i);
|
printf("0x%X ", i);
|
||||||
bprintb(s->minbuf, s->encode_to);
|
bprintb(s->minbuf, s->encode_to);
|
||||||
printf("\n");
|
printf("\n");
|
||||||
*/
|
|
||||||
|
|
||||||
ASSERT_EQ(creole_encode(i, s->encode_to, s->high_bits,
|
ASSERT_EQ(creole_encode(i, s->encode_to, s->high_bits,
|
||||||
buf), 1);
|
buf), 1);
|
||||||
|
@ -151,6 +149,7 @@ SUITE(pseudo_utf8_encode_all) {
|
||||||
for (s.high_bits = 0; s.high_bits < 16; s.high_bits++) {
|
for (s.high_bits = 0; s.high_bits < 16; s.high_bits++) {
|
||||||
memset(s.maxbuf, 0xBF, sizeof(s.maxbuf));
|
memset(s.maxbuf, 0xBF, sizeof(s.maxbuf));
|
||||||
|
|
||||||
|
memset(s.minbuf, 0x80, sizeof(s.minbuf));
|
||||||
s.max = 0x7F;
|
s.max = 0x7F;
|
||||||
s.encode_to = 2;
|
s.encode_to = 2;
|
||||||
s.maxbuf[0] = s.minbuf[0] = 0xC0 | (s.high_bits << 1);
|
s.maxbuf[0] = s.minbuf[0] = 0xC0 | (s.high_bits << 1);
|
||||||
|
@ -158,54 +157,43 @@ SUITE(pseudo_utf8_encode_all) {
|
||||||
s.minbuf[1] = 0x80;
|
s.minbuf[1] = 0x80;
|
||||||
RUN_TEST1(encode_byte_seq, &s);
|
RUN_TEST1(encode_byte_seq, &s);
|
||||||
|
|
||||||
|
memset(s.minbuf, 0x80, sizeof(s.minbuf));
|
||||||
s.max = 0xFFF;
|
s.max = 0xFFF;
|
||||||
s.encode_to = 3;
|
s.encode_to = 3;
|
||||||
s.minbuf[0] = 0xE0 | s.high_bits;
|
s.minbuf[0] = 0xE0 | s.high_bits;
|
||||||
s.maxbuf[0] = 0xE0 | s.high_bits;
|
s.maxbuf[0] = 0xE0 | s.high_bits;
|
||||||
s.minbuf[1] = 0x80;
|
s.minbuf[1] = 0x80;
|
||||||
s.minbuf[2] = 0x80;
|
|
||||||
RUN_TEST1(encode_byte_seq, &s);
|
RUN_TEST1(encode_byte_seq, &s);
|
||||||
|
|
||||||
|
memset(s.minbuf, 0x80, sizeof(s.minbuf));
|
||||||
s.max = 0x1FFFF;
|
s.max = 0x1FFFF;
|
||||||
s.encode_to = 4;
|
s.encode_to = 4;
|
||||||
s.maxbuf[0] = s.minbuf[0] = 0xF0 | (s.high_bits >> 1);
|
s.maxbuf[0] = s.minbuf[0] = 0xF0 | (s.high_bits >> 1);
|
||||||
s.minbuf[1] = 0x80 | (s.high_bits & 0x1 << 5);
|
s.minbuf[1] = 0x80 | ((s.high_bits & 0x1) << 5);
|
||||||
s.maxbuf[1] = 0x9F | (s.high_bits & 0x1 << 5);
|
s.maxbuf[1] = 0x9F | ((s.high_bits & 0x1) << 5);
|
||||||
s.minbuf[2] = 0x80;
|
|
||||||
s.minbuf[3] = 0x80;
|
|
||||||
RUN_TEST1(encode_byte_seq, &s);
|
RUN_TEST1(encode_byte_seq, &s);
|
||||||
|
|
||||||
|
memset(s.minbuf, 0x80, sizeof(s.minbuf));
|
||||||
s.max = 0x3FFFFF;
|
s.max = 0x3FFFFF;
|
||||||
s.encode_to = 5;
|
s.encode_to = 5;
|
||||||
s.maxbuf[0] = s.minbuf[0] = 0xF8 | (s.high_bits >> 2);
|
s.maxbuf[0] = s.minbuf[0] = 0xF8 | (s.high_bits >> 2);
|
||||||
s.minbuf[1] = 0x80 | (s.high_bits & 0x3 << 4);
|
s.minbuf[1] = 0x80 | ((s.high_bits & 0x3) << 4);
|
||||||
s.maxbuf[1] = 0x8F | (s.high_bits & 0x3 << 4);
|
s.maxbuf[1] = 0x8F | ((s.high_bits & 0x3) << 4);
|
||||||
s.minbuf[2] = 0x80;
|
|
||||||
s.minbuf[3] = 0x80;
|
|
||||||
s.minbuf[4] = 0x80;
|
|
||||||
RUN_TEST1(encode_byte_seq, &s);
|
|
||||||
|
|
||||||
|
memset(s.minbuf, 0x80, sizeof(s.minbuf));
|
||||||
s.max = 0x7FFFFFF;
|
s.max = 0x7FFFFFF;
|
||||||
s.encode_to = 6;
|
s.encode_to = 6;
|
||||||
s.maxbuf[0] = s.minbuf[0] = 0xFC | (s.high_bits >> 3);
|
s.maxbuf[0] = s.minbuf[0] = 0xFC | (s.high_bits >> 3);
|
||||||
s.minbuf[1] = 0x80 | (s.high_bits & 0x7 << 3);
|
s.minbuf[1] = 0x80 | ((s.high_bits & 0x7) << 3);
|
||||||
s.maxbuf[1] = 0x87 | (s.high_bits & 0x7 << 3);
|
s.maxbuf[1] = 0x87 | ((s.high_bits & 0x7) << 3);
|
||||||
s.minbuf[2] = 0x80;
|
|
||||||
s.minbuf[3] = 0x80;
|
|
||||||
s.minbuf[4] = 0x80;
|
|
||||||
s.minbuf[5] = 0x80;
|
|
||||||
RUN_TEST1(encode_byte_seq, &s);
|
RUN_TEST1(encode_byte_seq, &s);
|
||||||
|
|
||||||
|
memset(s.minbuf, 0x80, sizeof(s.minbuf));
|
||||||
s.max = 0xFFFFFFFF;
|
s.max = 0xFFFFFFFF;
|
||||||
s.encode_to = 7;
|
s.encode_to = 7;
|
||||||
s.maxbuf[0] = s.minbuf[0] = 0xFE;
|
s.maxbuf[0] = s.minbuf[0] = 0xFE;
|
||||||
s.minbuf[1] = 0x80 | (s.high_bits << 2);
|
s.minbuf[1] = 0x80 | (s.high_bits << 2);
|
||||||
s.maxbuf[1] = 0x83 | (s.high_bits << 2);
|
s.maxbuf[1] = 0x83 | (s.high_bits << 2);
|
||||||
s.minbuf[2] = 0x80;
|
|
||||||
s.minbuf[3] = 0x80;
|
|
||||||
s.minbuf[4] = 0x80;
|
|
||||||
s.minbuf[5] = 0x80;
|
|
||||||
s.minbuf[6] = 0x80;
|
|
||||||
RUN_TEST1(encode_byte_seq, &s);
|
RUN_TEST1(encode_byte_seq, &s);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue