diff options
author | Mattias Andrée <maandree@kth.se> | 2022-06-12 20:13:23 +0200 |
---|---|---|
committer | Mattias Andrée <maandree@kth.se> | 2022-06-12 20:13:23 +0200 |
commit | 3d6482b0949159c33d6ac2972a69868bdda766f2 (patch) | |
tree | 722cf9ab069d75af63664eeae0c35c63aa73c51c /strnisutf8.c | |
parent | Fix warnings (diff) | |
download | libsimple-3d6482b0949159c33d6ac2972a69868bdda766f2.tar.gz libsimple-3d6482b0949159c33d6ac2972a69868bdda766f2.tar.bz2 libsimple-3d6482b0949159c33d6ac2972a69868bdda766f2.tar.xz |
Move some test code to newline created .c files
Signed-off-by: Mattias Andrée <maandree@kth.se>
Diffstat (limited to 'strnisutf8.c')
-rw-r--r-- | strnisutf8.c | 60 |
1 files changed, 60 insertions, 0 deletions
diff --git a/strnisutf8.c b/strnisutf8.c index dc76fd5..8c775ee 100644 --- a/strnisutf8.c +++ b/strnisutf8.c @@ -12,6 +12,66 @@ extern inline int libsimple_strnisutf8(const char *, size_t, int); int main(void) { +#define ASSERT(STRING, GOOD)\ + do {\ + assert(libsimple_strnisutf8(STRING, sizeof(STRING) - 1, i) == (GOOD));\ + assert(libsimple_strnisutf8(STRING "\xFF", sizeof(STRING) - 1, i) == (GOOD));\ + assert(libsimple_strnisutf8(STRING "\x00", sizeof(STRING) - 1, i) == (GOOD));\ + } while (0) + + int i; + for (i = 0; i < 2; i++) { + ASSERT("", 1); + ASSERT("a", 1); + ASSERT("abc", 1); + ASSERT("123", 1); + ASSERT("åäö", 1); + ASSERT("𝖆𝖇𝖈", 1); + ASSERT("\x1b", 1); + ASSERT("\n\r\t\f", 1); + ASSERT("\xFF", 0); + ASSERT("\x01", 1); + ASSERT("\x7F", 1); + ASSERT("\x80", 0); + ASSERT("\xC0", 0); + ASSERT("\xC0\x80", i); + ASSERT("\xC0\x81", 0); + ASSERT("\xCF", 0); + ASSERT("\xEF", 0); + ASSERT("\xEF\x8F", 0); + ASSERT("\xF7", 0); + ASSERT("\xF7\x8F", 0); + ASSERT("\xF7\x8F\x8F", 0); + ASSERT("\xFA", 0); + ASSERT("\xFA\x8F", 0); + ASSERT("\xFA\x8F\x8F", 0); + ASSERT("\xFA\x8F\x8F\x8F", 0); + ASSERT("\xFD", 0); + ASSERT("\xFD\x8F", 0); + ASSERT("\xFD\x8F\x8F", 0); + ASSERT("\xFD\x8F\x8F\x8F", 0); + ASSERT("\xFD\x8F\x8F\x8F\x8F", 0); + ASSERT("\xFE", 0); + ASSERT("\xFE\x8F", 0); + ASSERT("\xFE\x8F\x8F", 0); + ASSERT("\xFE\x8F\x8F\x8F", 0); + ASSERT("\xFE\x8F\x8F\x8F\x8F", 0); + ASSERT("\xFE\x8F\x8F\x8F\x8F\x8F", 0); + ASSERT("\xFF", 0); + ASSERT("\xFF\x8F", 0); + ASSERT("\xFF\x8F\x8F", 0); + ASSERT("\xFF\x8F\x8F\x8F", 0); + ASSERT("\xFF\x8F\x8F\x8F\x8F", 0); + ASSERT("\xFF\x8F\x8F\x8F\x8F\x8F", 0); + ASSERT("\xFF\x8F\x8F\x8F\x8F\x8F\x8F", 0); + ASSERT("\xC1\x80", 0); + ASSERT("\xC2\x80", 1); + ASSERT("\xE1\x80\x80\x80", 0); + ASSERT("\xE1\x80\xC0\x80", 0); + ASSERT("\xE1\x80\x00\x80", 0); + ASSERT("\xF1\x80\x80\x80", 1); + ASSERT("\xFF\x80\x80\x80\x80\x80\x80\x80", 0); + } return 0; } |