gen-options.awk: Avoid translation context for help strings.
[dxcommon.git] / t / copysym.c
blob90416c3724f9189220dd3ae202bfeb9373181bea
1 /*
2 * Copyright © 2023-2024 Nick Bowler
4 * Tests for the copyright_symbol function.
6 * License WTFPL2: Do What The Fuck You Want To Public License, version 2.
7 * This is free software: you are free to do what the fuck you want to.
8 * There is NO WARRANTY, to the extent permitted by law.
9 */
11 #include <string.h>
12 #include "tap.h"
14 #define ENABLE_NLS 1
15 #include "copysym.h"
17 static const char *format_str(const char *s)
19 static char buf[100];
20 size_t pos = 0;
22 for (; *s && pos < sizeof buf - 4; s++) {
23 if (*s == '(' || *s == 'C' || *s == ')') {
24 buf[pos++] = *s;
25 } else {
26 static const char xdigits[16] = "0123456789abcdef";
27 unsigned char c = *s;
29 buf[pos++] = '\\';
30 buf[pos++] = 'x';
31 buf[pos++] = xdigits[(c >> 4) & 0xf];
32 buf[pos++] = xdigits[c & 0xf];
36 buf[pos] = 0;
37 return buf;
40 static void do_test(const char *charset, char *expected)
42 const char *sym = copyright_symbol(charset);
43 char *quote = charset ? "\"" : "";
45 if (!tap_result(!strcmp(sym, expected), "copyright_symbol(%s%s%s)",
46 quote, charset ? charset : "NULL", quote))
48 tap_diag("Failed, unexpected result");
49 tap_diag(" Received: %s", format_str(sym));
50 tap_diag(" Expected: %s", format_str(expected));
54 int main(void)
56 do_test(NULL, "(C)");
57 do_test("ANSI_X3.4-1968", "(C)");
58 do_test("ARMSCII-8", "(C)");
59 do_test("ASCII", "(C)");
60 do_test("BIG5", "(C)");
61 do_test("BIG5-HKSCS", "(C)");
62 do_test("CP1046", "(C)");
63 do_test("CP1124", "(C)");
64 do_test("CP1125", "(C)");
65 do_test("CP1129", "\xa9");
66 do_test("CP1131", "(C)");
67 do_test("CP1250", "\xa9");
68 do_test("CP1251", "\xa9");
69 do_test("CP1252", "\xa9");
70 do_test("CP1253", "\xa9");
71 do_test("CP1254", "\xa9");
72 do_test("CP1255", "\xa9");
73 do_test("CP1256", "\xa9");
74 do_test("CP1257", "\xa9");
75 do_test("CP437", "(C)");
76 do_test("CP775", "\xa8");
77 do_test("CP850", "\xb8");
78 do_test("CP852", "(C)");
79 do_test("CP855", "(C)");
80 do_test("CP856", "\xb8");
81 do_test("CP857", "\xb8");
82 do_test("CP861", "(C)");
83 do_test("CP862", "(C)");
84 do_test("CP864", "(C)");
85 do_test("CP865", "(C)");
86 do_test("CP866", "(C)");
87 do_test("CP869", "\x97");
88 do_test("CP874", "(C)");
89 do_test("CP922", "\xa9");
90 do_test("CP932", "(C)");
91 do_test("CP943", "(C)");
92 do_test("CP949", "(C)");
93 do_test("CP950", "(C)");
94 do_test("DEC-HANYU", "(C)");
95 do_test("DEC-KANJI", "(C)");
96 do_test("EUC-JP", "\x8f\xa2\xed");
97 do_test("EUC-KR", "(C)");
98 do_test("EUC-TW", "(C)");
99 do_test("GB18030", "\x81\x30\x84\x38");
100 do_test("GB2312", "(C)");
101 do_test("GBK", "(C)");
102 do_test("GEORGIAN-PS", "\xa9");
103 do_test("HP-ARABIC8", "(C)");
104 do_test("HP-GREEK8", "(C)");
105 do_test("HP-HEBREW8", "(C)");
106 do_test("HP-KANA8", "(C)");
107 do_test("HP-ROMAN8", "(C)");
108 do_test("HP-TURKISH8", "(C)");
109 do_test("ISO-8859-1", "\xa9");
110 do_test("ISO-8859-10", "(C)");
111 do_test("ISO-8859-11", "(C)");
112 do_test("ISO-8859-13", "\xa9");
113 do_test("ISO-8859-14", "\xa9");
114 do_test("ISO-8859-15", "\xa9");
115 do_test("ISO-8859-2", "(C)");
116 do_test("ISO-8859-3", "(C)");
117 do_test("ISO-8859-4", "(C)");
118 do_test("ISO-8859-5", "(C)");
119 do_test("ISO-8859-6", "(C)");
120 do_test("ISO-8859-7", "\xa9");
121 do_test("ISO-8859-8", "\xa9");
122 do_test("ISO-8859-9", "\xa9");
123 do_test("JOHAB", "(C)");
124 do_test("KOI8-R", "\xbf");
125 do_test("KOI8-T", "\xbf");
126 do_test("KOI8-U", "\xbf");
127 do_test("PT154", "\xa9");
128 do_test("SHIFT_JIS", "(C)");
129 do_test("TCVN5712-1", "(C)");
130 do_test("TIS-620", "(C)");
131 do_test("UTF-8", "\xc2\xa9");
132 do_test("VISCII", "(C)");
134 do_test("CP1026", "(C)"); /* EBCDIC B4 */
135 do_test("CP1047", "(C)"); /* EBCDIC B4 */
136 do_test("CP1112", "(C)"); /* EBCDIC B4 */
137 do_test("CP1122", "(C)"); /* EBCDIC B4 */
138 do_test("CP1130", "(C)"); /* EBCDIC B4 */
139 do_test("CP1140", "(C)"); /* EBCDIC B4 */
140 do_test("CP1141", "(C)"); /* EBCDIC B4 */
141 do_test("CP1142", "(C)"); /* EBCDIC B4 */
142 do_test("CP1143", "(C)"); /* EBCDIC B4 */
143 do_test("CP1144", "(C)"); /* EBCDIC B4 */
144 do_test("CP1145", "(C)"); /* EBCDIC B4 */
145 do_test("CP1146", "(C)"); /* EBCDIC B4 */
146 do_test("CP1147", "(C)"); /* EBCDIC B4 */
147 do_test("CP1148", "(C)"); /* EBCDIC B4 */
148 do_test("CP1149", "(C)"); /* EBCDIC B4 */
149 do_test("CP1155", "(C)"); /* EBCDIC B4 */
150 do_test("CP1156", "(C)"); /* EBCDIC B4 */
151 do_test("CP1157", "(C)"); /* EBCDIC B4 */
152 do_test("CP1164", "(C)"); /* EBCDIC B4 */
153 do_test("CP273", "(C)"); /* EBCDIC B4 */
154 do_test("CP277", "(C)"); /* EBCDIC B4 */
155 do_test("CP278", "(C)"); /* EBCDIC B4 */
156 do_test("CP280", "(C)"); /* EBCDIC B4 */
157 do_test("CP284", "(C)"); /* EBCDIC B4 */
158 do_test("CP285", "(C)"); /* EBCDIC B4 */
159 do_test("CP297", "(C)"); /* EBCDIC B4 */
160 do_test("CP424", "(C)"); /* EBCDIC B4 */
161 do_test("CP500", "(C)"); /* EBCDIC B4 */
162 do_test("CP871", "(C)"); /* EBCDIC B4 */
163 do_test("CP875", "(C)"); /* EBCDIC FB */
165 tap_done();