diff options
author | tjr <tjr@FreeBSD.org> | 2002-12-19 02:01:39 +0000 |
---|---|---|
committer | tjr <tjr@FreeBSD.org> | 2002-12-19 02:01:39 +0000 |
commit | 2aa20c1a1efd4c21dc2f5fd41dadfc7d73779199 (patch) | |
tree | bfd59e9d4d5640b4673ad9729a92e03e54c629fe /tools | |
parent | 3f31cbe67cd067fcd32b9c61eeba4277c4dc7c92 (diff) | |
download | FreeBSD-src-2aa20c1a1efd4c21dc2f5fd41dadfc7d73779199.zip FreeBSD-src-2aa20c1a1efd4c21dc2f5fd41dadfc7d73779199.tar.gz |
Test that if the buffer argument (`s') to wcrtomb() is NULL then
the value of the supplied wide character is ignored and L'\0' is used
instead. Remove incorrect comments about "internal buffer" since wcrtomb()
does not have one (wctomb() does).
Diffstat (limited to 'tools')
-rw-r--r-- | tools/regression/lib/libc/locale/test-wcrtomb.c | 34 |
1 files changed, 15 insertions, 19 deletions
diff --git a/tools/regression/lib/libc/locale/test-wcrtomb.c b/tools/regression/lib/libc/locale/test-wcrtomb.c index 3c16dff..c00792b 100644 --- a/tools/regression/lib/libc/locale/test-wcrtomb.c +++ b/tools/regression/lib/libc/locale/test-wcrtomb.c @@ -57,12 +57,12 @@ main(int argc, char *argv[]) assert(MB_CUR_MAX == 1); - /* Null wide character, internal state, internal buffer. */ + /* + * If the buffer argument is NULL, wc is implicitly L'\0', + * wcrtomb() resets its internal state. + */ assert(wcrtomb(NULL, L'\0', NULL) == 1); - - /* Null wide character, internal buffer. */ - memset(&s, 0, sizeof(s)); - assert(wcrtomb(NULL, L'\0', &s) == 1); + assert(wcrtomb(NULL, UCHAR_MAX + 1, NULL) == 1); /* Null wide character. */ memset(&s, 0, sizeof(s)); @@ -71,13 +71,10 @@ main(int argc, char *argv[]) assert(len == 1); assert((unsigned char)buf[0] == 0 && (unsigned char)buf[1] == 0xcc); - /* Latin letter A, internal state, internal buffer. */ + /* Latin letter A, internal state. */ + assert(wcrtomb(NULL, L'\0', NULL) == 1); assert(wcrtomb(NULL, L'A', NULL) == 1); - /* Latin letter A, internal buffer. */ - memset(&s, 0, sizeof(s)); - assert(wcrtomb(NULL, L'A', &s) == 1); - /* Latin letter A. */ memset(&s, 0, sizeof(s)); memset(buf, 0xcc, sizeof(buf)); @@ -86,7 +83,7 @@ main(int argc, char *argv[]) assert((unsigned char)buf[0] == 'A' && (unsigned char)buf[1] == 0xcc); /* Invalid code. */ - assert(wcrtomb(NULL, UCHAR_MAX + 1, NULL) == (size_t)-1); + assert(wcrtomb(buf, UCHAR_MAX + 1, NULL) == (size_t)-1); assert(errno == EILSEQ); /* @@ -96,9 +93,11 @@ main(int argc, char *argv[]) assert(strcmp(setlocale(LC_CTYPE, "ja_JP.eucJP"), "ja_JP.eucJP") == 0); assert(MB_CUR_MAX == 3); - /* Null wide character, internal buffer. */ - memset(&s, 0, sizeof(s)); - assert(wcrtomb(NULL, L'\0', &s) == 1); + /* + * If the buffer argument is NULL, wc is implicitly L'\0', + * wcrtomb() resets its internal state. + */ + assert(wcrtomb(NULL, L'\0', NULL) == 1); /* Null wide character. */ memset(&s, 0, sizeof(s)); @@ -107,13 +106,10 @@ main(int argc, char *argv[]) assert(len == 1); assert((unsigned char)buf[0] == 0 && (unsigned char)buf[1] == 0xcc); - /* Latin letter A, internal state, internal buffer. */ + /* Latin letter A, internal state. */ + assert(wcrtomb(NULL, L'\0', NULL) == 1); assert(wcrtomb(NULL, L'A', NULL) == 1); - /* Latin letter A, internal buffer. */ - memset(&s, 0, sizeof(s)); - assert(wcrtomb(NULL, L'A', &s) == 1); - /* Latin letter A. */ memset(&s, 0, sizeof(s)); memset(buf, 0xcc, sizeof(buf)); |