diff options
| author | jvoisin | 2023-08-21 22:49:21 +0200 |
|---|---|---|
| committer | jvoisin | 2023-08-21 22:49:21 +0200 |
| commit | bc0c8a57cb13fb110b3f9e050d67ef2d5678f85f (patch) | |
| tree | 3ede82e4529428559a96a2092123dc58baee23a7 /tests | |
| parent | cceaaa8161eb8b0b39854215417b39a9703b7aa5 (diff) | |
Add tests for mbstowcs
Diffstat (limited to 'tests')
| -rw-r--r-- | tests/Makefile | 2 | ||||
| -rw-r--r-- | tests/test_mbstowcs_dynamic.c | 15 | ||||
| -rw-r--r-- | tests/test_mbstowcs_static.c | 15 |
3 files changed, 32 insertions, 0 deletions
diff --git a/tests/Makefile b/tests/Makefile index 5bc7fdb..be379cd 100644 --- a/tests/Makefile +++ b/tests/Makefile | |||
| @@ -35,6 +35,8 @@ TARGETS= \ | |||
| 35 | test_getlogin_r_static \ | 35 | test_getlogin_r_static \ |
| 36 | test_mbsrtowcs_dynamic \ | 36 | test_mbsrtowcs_dynamic \ |
| 37 | test_mbsrtowcs_static \ | 37 | test_mbsrtowcs_static \ |
| 38 | test_mbstowcs_dynamic \ | ||
| 39 | test_mbstowcs_static \ | ||
| 38 | test_memchr_dynamic_read \ | 40 | test_memchr_dynamic_read \ |
| 39 | test_memchr_static_read \ | 41 | test_memchr_static_read \ |
| 40 | test_memcpy_dynamic_read \ | 42 | test_memcpy_dynamic_read \ |
diff --git a/tests/test_mbstowcs_dynamic.c b/tests/test_mbstowcs_dynamic.c new file mode 100644 index 0000000..81db020 --- /dev/null +++ b/tests/test_mbstowcs_dynamic.c | |||
| @@ -0,0 +1,15 @@ | |||
| 1 | #include "common.h" | ||
| 2 | |||
| 3 | #include <wchar.h> | ||
| 4 | |||
| 5 | int main(int argc, char** argv) { | ||
| 6 | const char* mbstr = "z\u00df\u6c34\U0001f34c"; // or u8"zß水🍌" | ||
| 7 | wchar_t wstr[5]; | ||
| 8 | mbstowcs(wstr, mbstr, 4); | ||
| 9 | |||
| 10 | CHK_FAIL_START | ||
| 11 | mbstowcs(wstr, mbstr, argc); | ||
| 12 | CHK_FAIL_END | ||
| 13 | |||
| 14 | return ret; | ||
| 15 | } | ||
diff --git a/tests/test_mbstowcs_static.c b/tests/test_mbstowcs_static.c new file mode 100644 index 0000000..8dbdfa1 --- /dev/null +++ b/tests/test_mbstowcs_static.c | |||
| @@ -0,0 +1,15 @@ | |||
| 1 | #include "common.h" | ||
| 2 | |||
| 3 | #include <wchar.h> | ||
| 4 | |||
| 5 | int main(int argc, char** argv) { | ||
| 6 | const char* mbstr = "z\u00df\u6c34\U0001f34c"; // or u8"zß水🍌" | ||
| 7 | wchar_t wstr[5]; | ||
| 8 | mbstowcs(wstr, mbstr, 4); | ||
| 9 | |||
| 10 | CHK_FAIL_START | ||
| 11 | mbstowcs(wstr, mbstr, 16); | ||
| 12 | CHK_FAIL_END | ||
| 13 | |||
| 14 | return ret; | ||
| 15 | } | ||
