fortify-headers

standalone fortify-source implementation
git clone git://git.2f30.org/fortify-headers
Log | Files | Refs | README | LICENSE

commit bc0c8a57cb13fb110b3f9e050d67ef2d5678f85f
parent cceaaa8161eb8b0b39854215417b39a9703b7aa5
Author: jvoisin <julien.voisin@dustri.org>
Date:   Mon, 21 Aug 2023 22:49:21 +0200

Add tests for mbstowcs

Diffstat:
Mtests/Makefile | 2++
Atests/test_mbstowcs_dynamic.c | 15+++++++++++++++
Atests/test_mbstowcs_static.c | 15+++++++++++++++
3 files changed, 32 insertions(+), 0 deletions(-)

diff --git a/tests/Makefile b/tests/Makefile @@ -35,6 +35,8 @@ TARGETS= \ test_getlogin_r_static \ test_mbsrtowcs_dynamic \ test_mbsrtowcs_static \ + test_mbstowcs_dynamic \ + test_mbstowcs_static \ test_memchr_dynamic_read \ test_memchr_static_read \ test_memcpy_dynamic_read \ diff --git a/tests/test_mbstowcs_dynamic.c b/tests/test_mbstowcs_dynamic.c @@ -0,0 +1,15 @@ +#include "common.h" + +#include <wchar.h> + +int main(int argc, char** argv) { + const char* mbstr = "z\u00df\u6c34\U0001f34c"; // or u8"zß水🍌" + wchar_t wstr[5]; + mbstowcs(wstr, mbstr, 4); + + CHK_FAIL_START + mbstowcs(wstr, mbstr, argc); + CHK_FAIL_END + + return ret; +} diff --git a/tests/test_mbstowcs_static.c b/tests/test_mbstowcs_static.c @@ -0,0 +1,15 @@ +#include "common.h" + +#include <wchar.h> + +int main(int argc, char** argv) { + const char* mbstr = "z\u00df\u6c34\U0001f34c"; // or u8"zß水🍌" + wchar_t wstr[5]; + mbstowcs(wstr, mbstr, 4); + + CHK_FAIL_START + mbstowcs(wstr, mbstr, 16); + CHK_FAIL_END + + return ret; +}