1/*-
2 * Copyright (c) 2002 Tim J. Robbins
3 * All rights reserved.
4 *
5 * Copyright (c) 2013 Ed Schouten <ed@FreeBSD.org>
6 * All rights reserved.
7 *
8 * Redistribution and use in source and binary forms, with or without
--- 17 unchanged lines hidden (view full) ---
26 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
27 * SUCH DAMAGE.
28 */
29/*
30 * Test program for mbrtoc16() as specified by ISO/IEC 9899:2011.
31 */
32
33#include <sys/cdefs.h>
34__FBSDID("$FreeBSD: head/tools/regression/lib/libc/locale/test-mbrtoc16.c 250883 2013-05-21 19:59:37Z ed $");
35
36#include <assert.h>
37#include <errno.h>
38#include <limits.h>
39#include <locale.h>
40#include <stdio.h>
41#include <string.h>
42#include <uchar.h>
--- 37 unchanged lines hidden (view full) ---
80 assert(c16 == L'z');
81
82 /* Check that mbrtoc16() doesn't access the buffer when n == 0. */
83 c16 = L'z';
84 memset(&s, 0, sizeof(s));
85 assert(mbrtoc16(&c16, "", 0, &s) == (size_t)-2);
86 assert(c16 == L'z');
87
88 /*
89 * UTF-8.
90 */
91
92 assert(strcmp(setlocale(LC_CTYPE, "en_US.UTF-8"), "en_US.UTF-8") == 0);
93
94 /* Null wide character, internal state. */
95 assert(mbrtoc16(NULL, 0, 0, NULL) == 0);
96 assert(mbrtoc16(&c16, "", 1, NULL) == 0);
--- 42 unchanged lines hidden (view full) ---
139 /* Surrogate pair. */
140 memset(&s, 0, sizeof(s));
141 c16 = 0;
142 assert(mbrtoc16(&c16, "\xf0\x9f\x92\xa9", 4, &s) == 4);
143 assert(c16 == 0xd83d);
144 assert(mbrtoc16(&c16, "", 0, &s) == (size_t)-3);
145 assert(c16 == 0xdca9);
146
147 printf("ok 1 - mbrtoc16()\n");
148
149 return (0);
150}
2 * Copyright (c) 2002 Tim J. Robbins
3 * All rights reserved.
4 *
5 * Copyright (c) 2013 Ed Schouten <ed@FreeBSD.org>
6 * All rights reserved.
7 *
8 * Redistribution and use in source and binary forms, with or without
--- 17 unchanged lines hidden (view full) ---
26 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
27 * SUCH DAMAGE.
28 */
29/*
30 * Test program for mbrtoc16() as specified by ISO/IEC 9899:2011.
31 */
32
33#include <sys/cdefs.h>
34__FBSDID("$FreeBSD: head/tools/regression/lib/libc/locale/test-mbrtoc16.c 250883 2013-05-21 19:59:37Z ed $");
35
36#include <assert.h>
37#include <errno.h>
38#include <limits.h>
39#include <locale.h>
40#include <stdio.h>
41#include <string.h>
42#include <uchar.h>
--- 37 unchanged lines hidden (view full) ---
80 assert(c16 == L'z');
81
82 /* Check that mbrtoc16() doesn't access the buffer when n == 0. */
83 c16 = L'z';
84 memset(&s, 0, sizeof(s));
85 assert(mbrtoc16(&c16, "", 0, &s) == (size_t)-2);
86 assert(c16 == L'z');
87
88 /*
89 * UTF-8.
90 */
91
92 assert(strcmp(setlocale(LC_CTYPE, "en_US.UTF-8"), "en_US.UTF-8") == 0);
93
94 /* Null wide character, internal state. */
95 assert(mbrtoc16(NULL, 0, 0, NULL) == 0);
96 assert(mbrtoc16(&c16, "", 1, NULL) == 0);
--- 42 unchanged lines hidden (view full) ---
139 /* Surrogate pair. */
140 memset(&s, 0, sizeof(s));
141 c16 = 0;
142 assert(mbrtoc16(&c16, "\xf0\x9f\x92\xa9", 4, &s) == 4);
143 assert(c16 == 0xd83d);
144 assert(mbrtoc16(&c16, "", 0, &s) == (size_t)-3);
145 assert(c16 == 0xdca9);
146
147 printf("ok 1 - mbrtoc16()\n");
148
149 return (0);
150}