c16rtomb_test.c (250883) | c16rtomb_test.c (251314) |
---|---|
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 c16rtomb() as specified by ISO/IEC 9899:2011. 31 */ 32 33#include <sys/cdefs.h> | 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 c16rtomb() as specified by ISO/IEC 9899:2011. 31 */ 32 33#include <sys/cdefs.h> |
34__FBSDID("$FreeBSD: head/tools/regression/lib/libc/locale/test-c16rtomb.c 250883 2013-05-21 19:59:37Z ed $"); | 34__FBSDID("$FreeBSD: head/tools/regression/lib/libc/locale/test-c16rtomb.c 251314 2013-06-03 17:17:56Z 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> --- 34 unchanged lines hidden (view full) --- 77 assert((unsigned char)buf[0] == 'A' && (unsigned char)buf[1] == 0xcc); 78 79 /* Unicode character 'Pile of poo'. */ 80 memset(&s, 0, sizeof(s)); 81 memset(buf, 0xcc, sizeof(buf)); 82 assert(c16rtomb(buf, 0xd83d, &s) == 0); 83 assert(c16rtomb(buf, 0xdca9, &s) == (size_t)-1); 84 assert(errno == EILSEQ); | 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> --- 34 unchanged lines hidden (view full) --- 77 assert((unsigned char)buf[0] == 'A' && (unsigned char)buf[1] == 0xcc); 78 79 /* Unicode character 'Pile of poo'. */ 80 memset(&s, 0, sizeof(s)); 81 memset(buf, 0xcc, sizeof(buf)); 82 assert(c16rtomb(buf, 0xd83d, &s) == 0); 83 assert(c16rtomb(buf, 0xdca9, &s) == (size_t)-1); 84 assert(errno == EILSEQ); |
85 assert((unsigned char)buf[0] == 0xcc); |
|
85 86 /* | 86 87 /* |
88 * ISO8859-1. 89 */ 90 91 assert(strcmp(setlocale(LC_CTYPE, "en_US.ISO8859-1"), 92 "en_US.ISO8859-1") == 0); 93 94 /* Unicode character 'Euro sign'. */ 95 memset(&s, 0, sizeof(s)); 96 memset(buf, 0xcc, sizeof(buf)); 97 assert(c16rtomb(buf, 0x20ac, &s) == (size_t)-1); 98 assert(errno == EILSEQ); 99 assert((unsigned char)buf[0] == 0xcc); 100 101 /* 102 * ISO8859-15. 103 */ 104 105 assert(strcmp(setlocale(LC_CTYPE, "en_US.ISO8859-15"), 106 "en_US.ISO8859-15") == 0); 107 108 /* Unicode character 'Euro sign'. */ 109 memset(&s, 0, sizeof(s)); 110 memset(buf, 0xcc, sizeof(buf)); 111 assert(c16rtomb(buf, 0x20ac, &s) == 1); 112 assert((unsigned char)buf[0] == 0xa4 && (unsigned char)buf[1] == 0xcc); 113 114 /* |
|
87 * UTF-8. 88 */ 89 90 assert(strcmp(setlocale(LC_CTYPE, "en_US.UTF-8"), "en_US.UTF-8") == 0); 91 92 /* Unicode character 'Pile of poo'. */ 93 memset(&s, 0, sizeof(s)); 94 memset(buf, 0xcc, sizeof(buf)); --- 4 unchanged lines hidden (view full) --- 99 (unsigned char)buf[4] == 0xcc); 100 101 /* Invalid code; 'Pile of poo' without the trail surrogate. */ 102 memset(&s, 0, sizeof(s)); 103 memset(buf, 0xcc, sizeof(buf)); 104 assert(c16rtomb(buf, 0xd83d, &s) == 0); 105 assert(c16rtomb(buf, L'A', &s) == (size_t)-1); 106 assert(errno == EILSEQ); | 115 * UTF-8. 116 */ 117 118 assert(strcmp(setlocale(LC_CTYPE, "en_US.UTF-8"), "en_US.UTF-8") == 0); 119 120 /* Unicode character 'Pile of poo'. */ 121 memset(&s, 0, sizeof(s)); 122 memset(buf, 0xcc, sizeof(buf)); --- 4 unchanged lines hidden (view full) --- 127 (unsigned char)buf[4] == 0xcc); 128 129 /* Invalid code; 'Pile of poo' without the trail surrogate. */ 130 memset(&s, 0, sizeof(s)); 131 memset(buf, 0xcc, sizeof(buf)); 132 assert(c16rtomb(buf, 0xd83d, &s) == 0); 133 assert(c16rtomb(buf, L'A', &s) == (size_t)-1); 134 assert(errno == EILSEQ); |
135 assert((unsigned char)buf[0] == 0xcc); |
|
107 108 /* Invalid code; 'Pile of poo' without the lead surrogate. */ 109 memset(&s, 0, sizeof(s)); 110 memset(buf, 0xcc, sizeof(buf)); 111 assert(c16rtomb(buf, 0xdca9, &s) == (size_t)-1); 112 assert(errno == EILSEQ); | 136 137 /* Invalid code; 'Pile of poo' without the lead surrogate. */ 138 memset(&s, 0, sizeof(s)); 139 memset(buf, 0xcc, sizeof(buf)); 140 assert(c16rtomb(buf, 0xdca9, &s) == (size_t)-1); 141 assert(errno == EILSEQ); |
142 assert((unsigned char)buf[0] == 0xcc); |
|
113 114 printf("ok 1 - c16rtomb()\n"); 115} | 143 144 printf("ok 1 - c16rtomb()\n"); 145} |