From: Richard Russon Date: Mon, 29 Apr 2019 13:46:56 +0000 (+0100) Subject: test: add mbyte tests for degenerate cases X-Git-Tag: 2019-10-25~233^2~61 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=7572850fd0d425dcac421d51bdc96bb664c84731;p=neomutt test: add mbyte tests for degenerate cases --- diff --git a/test/mbyte/mutt_mb_charlen.c b/test/mbyte/mutt_mb_charlen.c index 7288bd8d1..7165029e3 100644 --- a/test/mbyte/mutt_mb_charlen.c +++ b/test/mbyte/mutt_mb_charlen.c @@ -28,4 +28,13 @@ void test_mutt_mb_charlen(void) { // int mutt_mb_charlen(const char *s, int *width); + + { + int width = 0; + TEST_CHECK(mutt_mb_charlen(NULL, &width) == 0); + } + + { + TEST_CHECK(mutt_mb_charlen("apple", NULL) != 0); + } } diff --git a/test/mbyte/mutt_mb_filter_unprintable.c b/test/mbyte/mutt_mb_filter_unprintable.c index c217f8552..837effba1 100644 --- a/test/mbyte/mutt_mb_filter_unprintable.c +++ b/test/mbyte/mutt_mb_filter_unprintable.c @@ -28,4 +28,13 @@ void test_mutt_mb_filter_unprintable(void) { // int mutt_mb_filter_unprintable(char **s); + + { + TEST_CHECK(mutt_mb_filter_unprintable(NULL) != 0); + } + + { + char *s = NULL; + TEST_CHECK(mutt_mb_filter_unprintable(&s) != 0); + } } diff --git a/test/mbyte/mutt_mb_get_initials.c b/test/mbyte/mutt_mb_get_initials.c index 07748af03..da520d567 100644 --- a/test/mbyte/mutt_mb_get_initials.c +++ b/test/mbyte/mutt_mb_get_initials.c @@ -28,4 +28,13 @@ void test_mutt_mb_get_initials(void) { // bool mutt_mb_get_initials(const char *name, char *buf, size_t buflen); + + { + char buf[32] = { 0 }; + TEST_CHECK(!mutt_mb_get_initials(NULL, buf, sizeof(buf))); + } + + { + TEST_CHECK(!mutt_mb_get_initials("apple", NULL, 10)); + } } diff --git a/test/mbyte/mutt_mb_is_lower.c b/test/mbyte/mutt_mb_is_lower.c index 51cc317ab..7be1e6153 100644 --- a/test/mbyte/mutt_mb_is_lower.c +++ b/test/mbyte/mutt_mb_is_lower.c @@ -28,4 +28,8 @@ void test_mutt_mb_is_lower(void) { // bool mutt_mb_is_lower(const char *s); + + { + TEST_CHECK(!mutt_mb_is_lower(NULL)); + } } diff --git a/test/mbyte/mutt_mb_mbstowcs.c b/test/mbyte/mutt_mb_mbstowcs.c index 1030a5e69..ed95022bd 100644 --- a/test/mbyte/mutt_mb_mbstowcs.c +++ b/test/mbyte/mutt_mb_mbstowcs.c @@ -28,4 +28,20 @@ void test_mutt_mb_mbstowcs(void) { // size_t mutt_mb_mbstowcs(wchar_t **pwbuf, size_t *pwbuflen, size_t i, char *buf); + + { + size_t pwbuflen = 0; + TEST_CHECK(mutt_mb_mbstowcs(NULL, &pwbuflen, 0, "apple") == 0); + } + + { + wchar_t *wbuf = NULL; + TEST_CHECK(mutt_mb_mbstowcs(&wbuf, NULL, 0, "apple") == 0); + } + + { + wchar_t *wbuf = NULL; + size_t pwbuflen = 0; + TEST_CHECK(mutt_mb_mbstowcs(&wbuf, &pwbuflen, 0, NULL) == 0); + } } diff --git a/test/mbyte/mutt_mb_wcstombs.c b/test/mbyte/mutt_mb_wcstombs.c index d316336f2..ed7ce0fa5 100644 --- a/test/mbyte/mutt_mb_wcstombs.c +++ b/test/mbyte/mutt_mb_wcstombs.c @@ -28,4 +28,16 @@ void test_mutt_mb_wcstombs(void) { // void mutt_mb_wcstombs(char *dest, size_t dlen, const wchar_t *src, size_t slen); + + { + wchar_t src[32] = L"apple"; + mutt_mb_wcstombs(NULL, 10, src, 3); + TEST_CHECK_(1, "mutt_mb_wcstombs(&buf, sizeof(buf), src, 3)"); + } + + { + char buf[32] = { 0 }; + mutt_mb_wcstombs(buf, sizeof(buf), NULL, 3); + TEST_CHECK_(1, "mutt_mb_wcstombs(&buf, sizeof(buf), NULL, 3)"); + } } diff --git a/test/mbyte/mutt_mb_wcswidth.c b/test/mbyte/mutt_mb_wcswidth.c index e83e160ab..d378bb31a 100644 --- a/test/mbyte/mutt_mb_wcswidth.c +++ b/test/mbyte/mutt_mb_wcswidth.c @@ -28,4 +28,8 @@ void test_mutt_mb_wcswidth(void) { // int mutt_mb_wcswidth(const wchar_t *s, size_t n); + + { + TEST_CHECK(mutt_mb_wcswidth(NULL, 0) == 0); + } } diff --git a/test/mbyte/mutt_mb_width.c b/test/mbyte/mutt_mb_width.c index 92ddd732c..65c5d6083 100644 --- a/test/mbyte/mutt_mb_width.c +++ b/test/mbyte/mutt_mb_width.c @@ -28,4 +28,8 @@ void test_mutt_mb_width(void) { // int mutt_mb_width(const char *str, int col, bool display); + + { + TEST_CHECK(mutt_mb_width(NULL, 0, false) == 0); + } } diff --git a/test/mbyte/mutt_mb_width_ceiling.c b/test/mbyte/mutt_mb_width_ceiling.c index 64a5a0e4f..3590ed6c2 100644 --- a/test/mbyte/mutt_mb_width_ceiling.c +++ b/test/mbyte/mutt_mb_width_ceiling.c @@ -28,4 +28,8 @@ void test_mutt_mb_width_ceiling(void) { // size_t mutt_mb_width_ceiling(const wchar_t *s, size_t n, int w1); + + { + TEST_CHECK(mutt_mb_width_ceiling(NULL, 0, 0) == 0); + } }