1 /*
2 * Copyright (c) 2021 Huawei Device Co., Ltd.
3 * Licensed under the Apache License, Version 2.0 (the "License");
4 * you may not use this file except in compliance with the License.
5 * You may obtain a copy of the License at
6 *
7 * http://www.apache.org/licenses/LICENSE-2.0
8 *
9 * Unless required by applicable law or agreed to in writing, software
10 * distributed under the License is distributed on an "AS IS" BASIS,
11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 * See the License for the specific language governing permissions and
13 * limitations under the License.
14 */
15
16 #include "napi/native_api.h"
17 #include <unicode/uidna.h>
18 #include <cstdio>
19 #include <string>
20 #include "unicode/ustring.h"
21 #include "unicode/utext.h"
22 #include "unicode/utypes.h"
23 #include "unicode/uloc.h"
24 #include "hilog/log.h"
25 #include <cstdint>
26
TestUidna_openUTS46(napi_env env,napi_callback_info)27 static napi_value TestUidna_openUTS46(napi_env env, napi_callback_info)
28 {
29 UErrorCode errorCode = U_ZERO_ERROR;
30 UIDNA *uts461 = uidna_openUTS46(UIDNA_USE_STD3_RULES | UIDNA_NONTRANSITIONAL_TO_UNICODE, &errorCode);
31 bool flagA = (uts461 != NULL);
32 bool flag = (flagA & U_SUCCESS(errorCode));
33 napi_value result = nullptr;
34 napi_get_boolean(env, flag, &result);
35 return result;
36 }
37
testUidna_close(napi_env env,napi_callback_info)38 static napi_value testUidna_close(napi_env env, napi_callback_info)
39 {
40 UErrorCode errorCode = U_ZERO_ERROR;
41 UIDNA *uts461 = uidna_openUTS46(UIDNA_USE_STD3_RULES | UIDNA_NONTRANSITIONAL_TO_UNICODE, &errorCode);
42 uidna_close(uts461);
43 bool flag = (uts461 != NULL);
44 napi_value result = nullptr;
45 napi_get_boolean(env, flag, &result);
46 return result;
47 }
48
testUidna_labelToASCII(napi_env env,napi_callback_info)49 static napi_value testUidna_labelToASCII(napi_env env, napi_callback_info)
50 {
51 UErrorCode errorCode = U_ZERO_ERROR;
52 UIDNA *uts46 = uidna_openUTS46(UIDNA_USE_STD3_RULES | UIDNA_NONTRANSITIONAL_TO_UNICODE, &errorCode);
53 static const UChar sharps16[] = {0x66, 0x41, 0xdf, 0};
54 UChar dest16[10];
55 UIDNAInfo info1 = UIDNA_INFO_INITIALIZER;
56 int32_t capacity = 10;
57 uidna_labelToASCII(uts46, sharps16, -1, dest16, capacity, &info1, &errorCode);
58 bool flagA = (uts46 != NULL);
59 bool flag = (flagA & U_SUCCESS(errorCode));
60 napi_value result = nullptr;
61 napi_get_boolean(env, flag, &result);
62 return result;
63 }
64
testUidna_labelToUnicode(napi_env env,napi_callback_info)65 static napi_value testUidna_labelToUnicode(napi_env env, napi_callback_info)
66 {
67 UErrorCode errorCode = U_ZERO_ERROR;
68 UErrorCode errorCode1 = U_ZERO_ERROR;
69 const int32_t compareZero = 0;
70 UIDNA *uts46 = uidna_openUTS46(UIDNA_USE_STD3_RULES | UIDNA_NONTRANSITIONAL_TO_UNICODE, &errorCode);
71 static const UChar sharps[] = {0x66, 0x41, 0xc3, 0x9f, 0};
72 UIDNAInfo plnfo = UIDNA_INFO_INITIALIZER;
73
74 int32_t data1 = uidna_labelToUnicode(uts46, sharps, -1, NULL, -1, &plnfo, &errorCode1);
75 bool flagA = (data1 == compareZero);
76 bool flag = (flagA & U_SUCCESS(errorCode));
77 napi_value result = nullptr;
78 napi_get_boolean(env, flag, &result);
79 return result;
80 }
81
testUidna_nameToASCII(napi_env env,napi_callback_info)82 static napi_value testUidna_nameToASCII(napi_env env, napi_callback_info)
83 {
84 UErrorCode errorCode = U_ZERO_ERROR;
85 UErrorCode errorCode1 = U_ZERO_ERROR;
86 const int32_t compareZero = 0;
87 UIDNA *uts46 = uidna_openUTS46(UIDNA_USE_STD3_RULES | UIDNA_NONTRANSITIONAL_TO_UNICODE, &errorCode);
88 UChar dest16[10];
89 UIDNAInfo plnfo = UIDNA_INFO_INITIALIZER;
90
91 int32_t data1 = uidna_nameToASCII(uts46, NULL, -1, dest16, 0, &plnfo, &errorCode1);
92 bool flagA = (data1 == compareZero);
93 bool flag = (flagA & U_SUCCESS(errorCode));
94 napi_value result = nullptr;
95 napi_get_boolean(env, flag, &result);
96 return result;
97 }
98
testUidna_nameToUnicode(napi_env env,napi_callback_info)99 static napi_value testUidna_nameToUnicode(napi_env env, napi_callback_info)
100 {
101 UErrorCode errorCode = U_ZERO_ERROR;
102 UErrorCode errorCode1 = U_ZERO_ERROR;
103 const int32_t compareZero = 0;
104 UIDNA *uts46 = uidna_openUTS46(UIDNA_USE_STD3_RULES | UIDNA_NONTRANSITIONAL_TO_UNICODE, &errorCode);
105 static const UChar sharps16[] = {0x66, 0x41, 0xdf, 0};
106 int32_t length = -1;
107 UChar dest16[10];
108 UIDNAInfo plnfo = UIDNA_INFO_INITIALIZER;
109 int32_t capacity = 3;
110
111 int32_t data1 = uidna_nameToUnicode(uts46, sharps16, length, dest16, capacity, &plnfo, &errorCode1);
112 bool flagA = (data1 > compareZero);
113 bool flag = (flagA & U_SUCCESS(errorCode));
114 napi_value result = nullptr;
115 napi_get_boolean(env, flag, &result);
116 return result;
117 }
118
testUidna_labelToASCLL_UTF8(napi_env env,napi_callback_info)119 static napi_value testUidna_labelToASCLL_UTF8(napi_env env, napi_callback_info)
120 {
121 UErrorCode errorCode = U_ZERO_ERROR;
122 UErrorCode errorCode1 = U_ZERO_ERROR;
123 const int32_t compareZero = 0;
124 UIDNA *uts46 = uidna_openUTS46(UIDNA_USE_STD3_RULES | UIDNA_NONTRANSITIONAL_TO_UNICODE, &errorCode);
125 const char sharps[] = {0x66, 0x41, static_cast<char>(0xc3), static_cast<char>(0x9f), 0};
126 int32_t length = -1;
127 char dest = '\0';
128 UIDNAInfo plnfo = UIDNA_INFO_INITIALIZER;
129 int32_t capacity = 0;
130 int32_t data1 = uidna_labelToASCII_UTF8(uts46, sharps, length, &dest, capacity, &plnfo, &errorCode1);
131 bool flagA = (data1 > compareZero);
132 bool flag = (flagA & U_SUCCESS(errorCode));
133 napi_value result = nullptr;
134 napi_get_boolean(env, flag, &result);
135 return result;
136 }
137
testUidna_labelToUnicodeUTF8(napi_env env,napi_callback_info)138 static napi_value testUidna_labelToUnicodeUTF8(napi_env env, napi_callback_info)
139 {
140 UErrorCode errorCode = U_ZERO_ERROR;
141 UErrorCode errorCode1 = U_ZERO_ERROR;
142 const int32_t compareZero = 0;
143 UIDNA *uts46 = uidna_openUTS46(UIDNA_USE_STD3_RULES | UIDNA_NONTRANSITIONAL_TO_UNICODE, &errorCode);
144 const char sharps[] = {0x66, 0x41, static_cast<char>(0xc3), static_cast<char>(0x9f), 0};
145 int32_t length = -1;
146 char dest = '\0';
147 UIDNAInfo plnfo = UIDNA_INFO_INITIALIZER;
148 int32_t capacity = 0;
149
150 int32_t data1 = uidna_labelToUnicodeUTF8(uts46, sharps, length, &dest, capacity, &plnfo, &errorCode1);
151 bool flagA = (data1 > compareZero);
152 bool flag = (flagA & U_SUCCESS(errorCode));
153 napi_value result = nullptr;
154 napi_get_boolean(env, flag, &result);
155 return result;
156 }
157
testUidna_nameToASCII_UTF8(napi_env env,napi_callback_info)158 static napi_value testUidna_nameToASCII_UTF8(napi_env env, napi_callback_info)
159 {
160 UErrorCode errorCode = U_ZERO_ERROR;
161 UErrorCode errorCode1 = U_ZERO_ERROR;
162 const int32_t compareZero = 0;
163 UIDNA *uts46 = uidna_openUTS46(UIDNA_USE_STD3_RULES | UIDNA_NONTRANSITIONAL_TO_UNICODE, &errorCode);
164 const char sharps[] = {0x66, 0x41, static_cast<char>(0xc3), static_cast<char>(0x9f), 0};
165 int32_t length = -1;
166 char dest = '\0';
167 UIDNAInfo plnfo = UIDNA_INFO_INITIALIZER;
168 int32_t capacity = 0;
169 int32_t data1 = uidna_nameToASCII_UTF8(uts46, sharps, length, &dest, capacity, &plnfo, &errorCode1);
170 bool flagA = (data1 > compareZero);
171 bool flag = (flagA & U_SUCCESS(errorCode));
172 napi_value result = nullptr;
173 napi_get_boolean(env, flag, &result);
174 return result;
175 }
176
testUidna_nameToUnicodeUTF8(napi_env env,napi_callback_info)177 static napi_value testUidna_nameToUnicodeUTF8(napi_env env, napi_callback_info)
178 {
179 UErrorCode errorCode = U_ZERO_ERROR;
180 UErrorCode errorCode1 = U_ZERO_ERROR;
181 const int32_t compareZero = 0;
182 UIDNA *uts46 = uidna_openUTS46(UIDNA_USE_STD3_RULES | UIDNA_NONTRANSITIONAL_TO_UNICODE, &errorCode);
183 const char sharps[] = {0x66, 0x41, static_cast<char>(0xc3), static_cast<char>(0x9f), 0};
184 int32_t length = -1;
185 char dest = '\0';
186 UIDNAInfo plnfo = UIDNA_INFO_INITIALIZER;
187 int32_t capacity = 0;
188 int32_t data1 = uidna_nameToUnicodeUTF8(uts46, sharps, length, &dest, capacity, &plnfo, &errorCode1);
189 bool flagA = (data1 > compareZero);
190 bool flag = (flagA & U_SUCCESS(errorCode));
191 napi_value result = nullptr;
192 napi_get_boolean(env, flag, &result);
193 return result;
194 }
195
testUtext_openUTF8(napi_env env,napi_callback_info)196 static napi_value testUtext_openUTF8(napi_env env, napi_callback_info)
197 {
198 const char *uSting = "\x41\xc3\x85\x5A\x20\x41\x52\x69\x6E\x67";
199 UErrorCode status = U_ZERO_ERROR;
200 UText *ut = utext_openUTF8(NULL, uSting, -1, &status);
201 utext_close(ut);
202 bool flag = U_FAILURE(status);
203 napi_value result = nullptr;
204 napi_get_boolean(env, flag, &result);
205 return result;
206 }
207
testUtext_openUTF8_close(napi_env env,napi_callback_info)208 static napi_value testUtext_openUTF8_close(napi_env env, napi_callback_info)
209 {
210 UChar testStr[] = {0x20, 0x41, 0x20, 0x42, 0x20, 0x43, 0x20, 0x44, 0x0};
211 UErrorCode status = U_ZERO_ERROR;
212 UText *ut = utext_openUChars(NULL, testStr, -1, &status);
213 utext_close(ut);
214 bool flag = U_FAILURE(status);
215 napi_value result = nullptr;
216 napi_get_boolean(env, flag, &result);
217 return result;
218 }
219
testUtext_clone(napi_env env,napi_callback_info)220 static napi_value testUtext_clone(napi_env env, napi_callback_info)
221 {
222 UChar testStr[] = {0x20, 0x41, 0x20, 0x42, 0x20, 0x43, 0x20, 0x44, 0x0};
223 UErrorCode status = U_ZERO_ERROR;
224 UText *uta = utext_openUChars(NULL, testStr, -1, &status);
225 bool flagA = U_FAILURE(status);
226 UText *utb = utext_clone(NULL, uta, false, false, &status);
227 bool flagB = U_FAILURE(status);
228 utext_close(uta);
229 utext_close(utb);
230
231 bool flag = (flagA || flagB);
232 napi_value result = nullptr;
233 napi_get_boolean(env, flag, &result);
234 return result;
235 }
236
testUtext_equals(napi_env env,napi_callback_info)237 static napi_value testUtext_equals(napi_env env, napi_callback_info)
238 {
239 UErrorCode status = U_ZERO_ERROR;
240 const UChar *charS = u"aßカ";
241 UText *utOne = utext_openUChars(NULL, charS, -1, &status);
242 UText *utTwo = utext_openUChars(NULL, charS, 5, &status);
243 bool flagA = U_FAILURE(status);
244 bool flagB = !utext_equals(utOne, utTwo);
245 utext_close(utOne);
246 utext_close(utTwo);
247 bool flag = (flagA || flagB);
248 napi_value result = nullptr;
249 napi_get_boolean(env, flag, &result);
250 return result;
251 }
252
testUtext_nativeLength(napi_env env,napi_callback_info)253 static napi_value testUtext_nativeLength(napi_env env, napi_callback_info)
254 {
255 UChar uString[] = {0x41, 0x42, 0x43, 0};
256 UErrorCode status = U_ZERO_ERROR;
257 int64_t len;
258 const int32_t stringLen = 3;
259 UText *uta = utext_openUChars(NULL, uString, -1, &status);
260 bool flagA = U_FAILURE(status);
261 len = utext_nativeLength(uta);
262 bool flagB = (len != stringLen);
263 utext_close(uta);
264 bool flag = (flagA || flagB);
265 napi_value result = nullptr;
266 napi_get_boolean(env, flag, &result);
267 return result;
268 }
269
testUtext_char32At(napi_env env,napi_callback_info)270 static napi_value testUtext_char32At(napi_env env, napi_callback_info)
271 {
272 UChar uString[] = {0x41, 0x42, 0x43, 0};
273 UErrorCode status = U_ZERO_ERROR;
274 UText *uta = utext_openUChars(NULL, uString, -1, &status);
275 bool flagA = U_FAILURE(status);
276 UChar32 charC = utext_char32At(uta, 0);
277 bool flagB = (charC != uString[0]);
278 utext_close(uta);
279 bool flag = (flagA || flagB);
280 napi_value result = nullptr;
281 napi_get_boolean(env, flag, &result);
282 return result;
283 }
284
testUtext_current32(napi_env env,napi_callback_info)285 static napi_value testUtext_current32(napi_env env, napi_callback_info)
286 {
287 UChar uString[] = {0x41, 0x42, 0x43, 0};
288 UErrorCode status = U_ZERO_ERROR;
289 UText *uta = utext_openUChars(NULL, uString, -1, &status);
290 bool flagA = U_FAILURE(status);
291 UChar32 testChar = utext_current32(uta);
292 bool flagB = (testChar != uString[0]);
293 utext_close(uta);
294 bool flag = (flagA || flagB);
295 napi_value result = nullptr;
296 napi_get_boolean(env, flag, &result);
297 return result;
298 }
299
testUtext_next32(napi_env env,napi_callback_info)300 static napi_value testUtext_next32(napi_env env, napi_callback_info)
301 {
302 UChar uString[] = {0x41, 0x42, 0x43, 0};
303 UErrorCode status = U_ZERO_ERROR;
304 UText *uta = utext_openUChars(NULL, uString, -1, &status);
305 bool flagA = U_FAILURE(status);
306 UChar32 nextC = utext_next32(uta);
307 bool flagB = (nextC != uString[0]);
308 utext_close(uta);
309 bool flag = (flagA || flagB);
310 napi_value result = nullptr;
311 napi_get_boolean(env, flag, &result);
312 return result;
313 }
314
testUtext_previous32(napi_env env,napi_callback_info)315 static napi_value testUtext_previous32(napi_env env, napi_callback_info)
316 {
317 UChar uString[] = {0x41, 0x42, 0x43, 0};
318 UErrorCode status = U_ZERO_ERROR;
319 UText *uta = utext_openUChars(NULL, uString, -1, &status);
320 bool flagA = U_FAILURE(status);
321 UChar32 previousC = utext_next32(uta);
322 previousC = utext_previous32(uta);
323 bool flagB = (previousC != uString[0]);
324 utext_close(uta);
325 bool flag = (flagA || flagB);
326 napi_value result = nullptr;
327 napi_get_boolean(env, flag, &result);
328 return result;
329 }
330
testUtext_next32From(napi_env env,napi_callback_info)331 static napi_value testUtext_next32From(napi_env env, napi_callback_info)
332 {
333 UChar uString[] = {0x41, 0x42, 0x43, 0};
334 UErrorCode status = U_ZERO_ERROR;
335 UText *uta = utext_openUChars(NULL, uString, -1, &status);
336 bool flagA = U_FAILURE(status);
337 UChar32 nextFromC = utext_next32From(uta, 1);
338 bool flagB = (nextFromC != uString[1]);
339 utext_close(uta);
340 bool flag = (flagA || flagB);
341 napi_value result = nullptr;
342 napi_get_boolean(env, flag, &result);
343 return result;
344 }
345
testUtext_previous32From(napi_env env,napi_callback_info)346 static napi_value testUtext_previous32From(napi_env env, napi_callback_info)
347 {
348 UChar uString[] = {0x41, 0x42, 0x43, 0};
349 UErrorCode status = U_ZERO_ERROR;
350 UText *uta = utext_openUChars(NULL, uString, -1, &status);
351 bool flagA = U_FAILURE(status);
352 UChar32 previousC = utext_previous32From(uta, 2);
353 bool flagB = (previousC != uString[1]);
354 utext_close(uta);
355 bool flag = (flagA || flagB);
356 napi_value result = nullptr;
357 napi_get_boolean(env, flag, &result);
358 return result;
359 }
360
testUtext_getNativeIndex(napi_env env,napi_callback_info)361 static napi_value testUtext_getNativeIndex(napi_env env, napi_callback_info)
362 {
363 UChar uString[] = {0x41, 0x42, 0x43, 0};
364 UErrorCode status = U_ZERO_ERROR;
365 const int32_t compare = 1;
366 UText *uta = utext_openUChars(NULL, uString, -1, &status);
367 bool flagA = U_FAILURE(status);
368 UChar32 previousC = utext_previous32From(uta, 2);
369 int64_t getNativeIndexI = utext_getNativeIndex(uta);
370 bool flagB = (getNativeIndexI != compare);
371 utext_close(uta);
372 bool flag = (flagA || flagB);
373 napi_value result = nullptr;
374 napi_get_boolean(env, flag, &result);
375 return result;
376 }
377
testUtext_setNativeIndex_moveIndex32(napi_env env,napi_callback_info)378 static napi_value testUtext_setNativeIndex_moveIndex32(napi_env env, napi_callback_info)
379 {
380 UChar uString[] = {0x41, 0x42, 0x43, 0};
381 UErrorCode status = U_ZERO_ERROR;
382 const int32_t compare = 1;
383 UText *uta = utext_openUChars(NULL, uString, -1, &status);
384 bool flagA = U_FAILURE(status);
385 utext_setNativeIndex(uta, 0);
386 UBool moveIndexB = utext_moveIndex32(uta, 1);
387 int64_t getNativeIndexI = utext_getNativeIndex(uta);
388 bool flagB = (moveIndexB != true || getNativeIndexI != compare);
389 utext_close(uta);
390 bool flag = (flagA || flagB);
391 napi_value result = nullptr;
392 napi_get_boolean(env, flag, &result);
393 return result;
394 }
395
testUtext_getPreviousNativeIndex(napi_env env,napi_callback_info)396 static napi_value testUtext_getPreviousNativeIndex(napi_env env, napi_callback_info)
397 {
398 UChar uString[] = {0x41, 0x42, 0x43, 0};
399 const int32_t compareZero = 0;
400 UErrorCode status = U_ZERO_ERROR;
401 UText *uta = utext_openUChars(NULL, uString, -1, &status);
402 bool flagA = U_FAILURE(status);
403 UBool moveIndexB = utext_moveIndex32(uta, 1);
404 int64_t getPreviousNativeIndexI = utext_getPreviousNativeIndex(uta);
405 bool flagB = (getPreviousNativeIndexI != compareZero);
406 utext_close(uta);
407 bool flag = (flagA || flagB);
408 napi_value result = nullptr;
409 napi_get_boolean(env, flag, &result);
410 return result;
411 }
412
testUtext_extract(napi_env env,napi_callback_info)413 static napi_value testUtext_extract(napi_env env, napi_callback_info)
414 {
415 UChar uString[] = {0x41, 0x42, 0x43, 0};
416 UErrorCode status = U_ZERO_ERROR;
417 UText *uta;
418 UChar groupBuf[20];
419 uta = utext_openUChars(NULL, uString, -1, &status);
420 bool flagA = U_FAILURE(status);
421 utext_extract(uta, 0 /*start index */, 0 + 1 /*limit index*/, groupBuf, sizeof(groupBuf), &status);
422 UBool moveIndexB = utext_moveIndex32(uta, 1);
423 int64_t getPreviousNativeIndexI = utext_getPreviousNativeIndex(uta);
424 bool flagB = U_FAILURE(status);
425 utext_close(uta);
426 bool flag = (flagA || flagB);
427 napi_value result = nullptr;
428 napi_get_boolean(env, flag, &result);
429 return result;
430 }
431
testU_strlen(napi_env env,napi_callback_info)432 static napi_value testU_strlen(napi_env env, napi_callback_info)
433 {
434 UChar uString[] = {0x41, 0x42, 0x43, 0};
435 const int32_t stringLen = 3;
436 int32_t len = u_strlen(uString);
437 bool flag = (len != stringLen);
438 napi_value result = nullptr;
439 napi_get_boolean(env, flag, &result);
440 return result;
441 }
442
testU_countChar32(napi_env env,napi_callback_info)443 static napi_value testU_countChar32(napi_env env, napi_callback_info)
444 {
445 UChar uString[] = {0x41, 0x42, 0x43, 0};
446 const int32_t stringLen = 3;
447 int32_t len = u_countChar32(uString, -1);
448 bool flag = (len != stringLen);
449 napi_value result = nullptr;
450 napi_get_boolean(env, flag, &result);
451 return result;
452 }
453
testU_strHasMoreChar32Than(napi_env env,napi_callback_info)454 static napi_value testU_strHasMoreChar32Than(napi_env env, napi_callback_info)
455 {
456 UChar uString[] = {0x41, 0x42, 0x43, 0};
457 UBool ThanB = u_strHasMoreChar32Than(uString, -1, 1);
458 bool flag = (ThanB != true);
459 napi_value result = nullptr;
460 napi_get_boolean(env, flag, &result);
461 return result;
462 }
463
testU_strcat(napi_env env,napi_callback_info)464 static napi_value testU_strcat(napi_env env, napi_callback_info)
465 {
466 UChar uStringOne[] = {0x41, 0x42, 0x43, 0, 0, 0, 0};
467 UChar uStringTwo[] = {0x41, 0x42, 0};
468 const int32_t stringLen = 5;
469 u_strcat(uStringOne, uStringTwo);
470 int32_t len = u_strlen(uStringOne);
471 bool flag = (len != stringLen);
472 napi_value result = nullptr;
473 napi_get_boolean(env, flag, &result);
474 return result;
475 }
476
testU_strncat(napi_env env,napi_callback_info)477 static napi_value testU_strncat(napi_env env, napi_callback_info)
478 {
479 UChar uStringOne[] = {0x41, 0x42, 0x43, 0, 0, 0, 0};
480 UChar uStringTwo[] = {0x41, 0x42, 0};
481 const int32_t catLen = 2;
482 const int32_t stringLen = 5;
483 u_strncat(uStringOne, uStringTwo, catLen);
484 int32_t len = u_strlen(uStringOne);
485 bool flag = (len != stringLen);
486 napi_value result = nullptr;
487 napi_get_boolean(env, flag, &result);
488 return result;
489 }
490
testU_strstr(napi_env env,napi_callback_info)491 static napi_value testU_strstr(napi_env env, napi_callback_info)
492 {
493 UChar uStringOne[] = {0x41, 0x42, 0x43, 0};
494 UChar uStringTwo[] = {0x44, 0x44, 0};
495 UChar *resultA = u_strstr(uStringOne, uStringTwo);
496 bool flag = (resultA != NULL);
497 napi_value result = nullptr;
498 napi_get_boolean(env, flag, &result);
499 return result;
500 }
501
testU_strFindFirst(napi_env env,napi_callback_info)502 static napi_value testU_strFindFirst(napi_env env, napi_callback_info)
503 {
504 UChar uStringOne[] = {0x41, 0x42, 0x43, 0};
505 UChar uStringTwo[] = {0x44, 0x44, 0};
506 UChar *resultA = u_strFindFirst(uStringOne, -1, uStringTwo, 2);
507 bool flag = (resultA != NULL);
508 napi_value result = nullptr;
509 napi_get_boolean(env, flag, &result);
510 return result;
511 }
512
testU_strchr(napi_env env,napi_callback_info)513 static napi_value testU_strchr(napi_env env, napi_callback_info)
514 {
515 UChar uStringOne[] = {0x41, 0x42, 0x43, 0};
516 UChar uStringTwo = 0x44;
517 UChar *resultA = u_strchr(uStringOne, uStringTwo);
518 bool flag = (resultA != NULL);
519 napi_value result = nullptr;
520 napi_get_boolean(env, flag, &result);
521 return result;
522 }
523
testU_strchr32(napi_env env,napi_callback_info)524 static napi_value testU_strchr32(napi_env env, napi_callback_info)
525 {
526 UChar uStringOne[] = {0x41, 0x42, 0x43, 0};
527 UChar uStringTwo = 0x44;
528 UChar *resultA = u_strchr32(uStringOne, uStringTwo);
529 bool flag = (resultA != NULL);
530 napi_value result = nullptr;
531 napi_get_boolean(env, flag, &result);
532 return result;
533 }
534
testU_strrstr(napi_env env,napi_callback_info)535 static napi_value testU_strrstr(napi_env env, napi_callback_info)
536 {
537 UChar uStringOne[] = {0x41, 0x42, 0x43, 0};
538 UChar uStringTwo[] = {0x44, 0x44, 0};
539 UChar *resultA = u_strrstr(uStringOne, uStringTwo);
540 bool flag = (resultA != NULL);
541 napi_value result = nullptr;
542 napi_get_boolean(env, flag, &result);
543 return result;
544 }
545
testU_strFindLast(napi_env env,napi_callback_info)546 static napi_value testU_strFindLast(napi_env env, napi_callback_info)
547 {
548 UChar uStringOne[] = {0x41, 0x42, 0x43, 0};
549 UChar uStringTwo[] = {0x44, 0x44, 0};
550 UChar *resultA = u_strFindLast(uStringOne, -1, uStringTwo, 2);
551 bool flag = (resultA != NULL);
552 napi_value result = nullptr;
553 napi_get_boolean(env, flag, &result);
554 return result;
555 }
556
testU_strrchr(napi_env env,napi_callback_info)557 static napi_value testU_strrchr(napi_env env, napi_callback_info)
558 {
559 UChar uStringOne[] = {0x41, 0x42, 0x43, 0};
560 UChar test = 0x44;
561 UChar *resultA = u_strrchr(uStringOne, test);
562 bool flag = false;
563 if (resultA == NULL) {
564 flag = true;
565 }
566 napi_value result = nullptr;
567 napi_get_boolean(env, flag, &result);
568 return result;
569 }
570
testU_strrchr32(napi_env env,napi_callback_info)571 static napi_value testU_strrchr32(napi_env env, napi_callback_info)
572 {
573 UChar uStringOne[] = {0x41, 0x42, 0x43, 0};
574 UChar32 test = 0x44;
575 UChar *resultA = u_strrchr32(uStringOne, test);
576 bool flag = false;
577 if (resultA == NULL) {
578 flag = true;
579 }
580 napi_value result = nullptr;
581 napi_get_boolean(env, flag, &result);
582 return result;
583 }
584
testU_strpbrk(napi_env env,napi_callback_info)585 static napi_value testU_strpbrk(napi_env env, napi_callback_info)
586 {
587 UChar uStringOne[] = {0x41, 0x42, 0x43, 0};
588 UChar test[] = {0x44, 0};
589 UChar *resultA = u_strpbrk(uStringOne, test);
590 bool flag = false;
591 if (resultA == NULL) {
592 flag = true;
593 }
594 napi_value result = nullptr;
595 napi_get_boolean(env, flag, &result);
596 return result;
597 }
598
testU_strcspn(napi_env env,napi_callback_info)599 static napi_value testU_strcspn(napi_env env, napi_callback_info)
600 {
601 UChar uStringOne[] = {0x41, 0x42, 0x43, 0};
602 UChar test[] = {0x44, 0};
603 const int32_t stringLen = 3;
604 int32_t resultA = u_strcspn(uStringOne, test);
605 bool flag = false;
606 if (resultA == stringLen) {
607 flag = true;
608 }
609 napi_value result = nullptr;
610 napi_get_boolean(env, flag, &result);
611 return result;
612 }
613
testU_strspn(napi_env env,napi_callback_info)614 static napi_value testU_strspn(napi_env env, napi_callback_info)
615 {
616 UChar uStringOne[] = {0x41, 0x42, 0x43, 0};
617 UChar test[] = {0x44, 0};
618 const int32_t stringLen = 0;
619 int32_t resultA = u_strspn(uStringOne, test);
620 bool flag = false;
621 if (resultA == stringLen) {
622 flag = true;
623 }
624 napi_value result = nullptr;
625 napi_get_boolean(env, flag, &result);
626 return result;
627 }
628
testU_strtok_r(napi_env env,napi_callback_info)629 static napi_value testU_strtok_r(napi_env env, napi_callback_info)
630 {
631 UChar uStringOne[] = {0x41, 0x42, 0x43, 0};
632 UChar del[] = {0x42, 0};
633 UChar *state;
634 const UChar compare = 0x43;
635 UChar *resultA = u_strtok_r(uStringOne, del, &state);
636 resultA = u_strtok_r(NULL, del, &state);
637 bool flag = false;
638 if (*resultA == compare) {
639 flag = true;
640 }
641 napi_value result = nullptr;
642 napi_get_boolean(env, flag, &result);
643 return result;
644 }
645
testU_strcmp(napi_env env,napi_callback_info)646 static napi_value testU_strcmp(napi_env env, napi_callback_info)
647 {
648 UChar uStringOne[] = {0x41, 0x42, 0x43, 0};
649 UChar uStringTwo[] = {0x41, 0x42, 0x43, 0};
650 const int32_t stringLen = 0;
651 int32_t test = u_strcmp(uStringOne, uStringTwo);
652 bool flag = false;
653 if (test == stringLen) {
654 flag = true;
655 }
656 napi_value result = nullptr;
657 napi_get_boolean(env, flag, &result);
658 return result;
659 }
660
testU_strcmpCodePointOrder(napi_env env,napi_callback_info)661 static napi_value testU_strcmpCodePointOrder(napi_env env, napi_callback_info)
662 {
663 UChar uStringOne[] = {0x41, 0x42, 0x43, 0};
664 UChar uStringTwo[] = {0x41, 0x42, 0x43, 0};
665 const int32_t stringLen = 0;
666 int32_t test = u_strcmpCodePointOrder(uStringOne, uStringTwo);
667 bool flag = false;
668 if (test == stringLen) {
669 flag = true;
670 }
671 napi_value result = nullptr;
672 napi_get_boolean(env, flag, &result);
673 return result;
674 }
675
testU_strCompare(napi_env env,napi_callback_info)676 static napi_value testU_strCompare(napi_env env, napi_callback_info)
677 {
678 UChar uStringOne[] = {0x41, 0x42, 0x43, 0};
679 UChar uStringTwo[] = {0x41, 0x42, 0x43, 0};
680 const int32_t stringLen = 0;
681 int32_t test = u_strCompare(uStringOne, 2, uStringTwo, 2, false);
682 bool flag = false;
683 if (test == stringLen) {
684 flag = true;
685 }
686 napi_value result = nullptr;
687 napi_get_boolean(env, flag, &result);
688 return result;
689 }
690
testU_strCaseCompare(napi_env env,napi_callback_info)691 static napi_value testU_strCaseCompare(napi_env env, napi_callback_info)
692 {
693 UChar uStringOne[] = {0x41, 0x42, 0x43, 0};
694 UChar uStringTwo[] = {0x41, 0x42, 0x43, 0};
695 UErrorCode status = U_ZERO_ERROR;
696 const int32_t stringLen = 0;
697 int32_t test = u_strCaseCompare(uStringOne, 2, uStringTwo, 2, U_FOLD_CASE_DEFAULT, &status);
698 bool flag = false;
699 if (test == stringLen) {
700 flag = true;
701 }
702 napi_value result = nullptr;
703 napi_get_boolean(env, flag, &result);
704 return result;
705 }
706
testU_strncmp(napi_env env,napi_callback_info)707 static napi_value testU_strncmp(napi_env env, napi_callback_info)
708 {
709 UChar uStringOne[] = {0x41, 0x42, 0x43, 0};
710 UChar uStringTwo[] = {0x41, 0x42, 0x43, 0};
711 const int32_t stringLen = 0;
712 int32_t test = u_strncmp(uStringOne, uStringTwo, 2);
713 bool flag = false;
714 if (test == stringLen) {
715 flag = true;
716 }
717 napi_value result = nullptr;
718 napi_get_boolean(env, flag, &result);
719 return result;
720 }
721
testU_strncmpCodePointOrder(napi_env env,napi_callback_info)722 static napi_value testU_strncmpCodePointOrder(napi_env env, napi_callback_info)
723 {
724 UChar uStringOne[] = {0x41, 0x42, 0x43, 0};
725 UChar uStringTwo[] = {0x41, 0x42, 0x43, 0};
726 const int32_t stringLen = 0;
727 int32_t test = u_strncmpCodePointOrder(uStringOne, uStringTwo, 2);
728 bool flag = false;
729 if (test == stringLen) {
730 flag = true;
731 }
732 napi_value result = nullptr;
733 napi_get_boolean(env, flag, &result);
734 return result;
735 }
736
testU_strcasecmp(napi_env env,napi_callback_info)737 static napi_value testU_strcasecmp(napi_env env, napi_callback_info)
738 {
739 UChar uStringOne[] = {0x41, 0x42, 0x43, 0};
740 UChar uStringTwo[] = {0x41, 0x42, 0x43, 0};
741 const int32_t stringLen = 0;
742 int32_t test = u_strcasecmp(uStringOne, uStringTwo, U_FOLD_CASE_DEFAULT);
743 bool flag = false;
744 if (test == stringLen) {
745 flag = true;
746 }
747 napi_value result = nullptr;
748 napi_get_boolean(env, flag, &result);
749 return result;
750 }
751
testU_strncasecmp(napi_env env,napi_callback_info)752 static napi_value testU_strncasecmp(napi_env env, napi_callback_info)
753 {
754 UChar uStringOne[] = {0x41, 0x42, 0x43, 0};
755 UChar uStringTwo[] = {0x41, 0x42, 0x43, 0};
756 const int32_t stringLen = 0;
757 int32_t test = u_strncasecmp(uStringOne, uStringTwo, 2, U_FOLD_CASE_DEFAULT);
758 bool flag = false;
759 if (test == stringLen) {
760 flag = true;
761 }
762 napi_value result = nullptr;
763 napi_get_boolean(env, flag, &result);
764 return result;
765 }
766
testU_memcasecmp(napi_env env,napi_callback_info)767 static napi_value testU_memcasecmp(napi_env env, napi_callback_info)
768 {
769 UChar uStringOne[] = {0x41, 0x42, 0x43, 0};
770 UChar uStringTwo[] = {0x41, 0x42, 0x43, 0};
771 const int32_t stringLen = 0;
772 int32_t test = u_memcasecmp(uStringOne, uStringTwo, 2, U_FOLD_CASE_DEFAULT);
773 bool flag = false;
774 if (test == stringLen) {
775 flag = true;
776 }
777 napi_value result = nullptr;
778 napi_get_boolean(env, flag, &result);
779 return result;
780 }
781
testU_strcpy(napi_env env,napi_callback_info)782 static napi_value testU_strcpy(napi_env env, napi_callback_info)
783 {
784 UChar uStringOne[] = {0x41, 0x42, 0x43, 0};
785 UChar uStringTwo[] = {0x41, 0x42, 0};
786 const int32_t stringLen = 2;
787 u_strcpy(uStringOne, uStringTwo);
788 bool flag = false;
789 if (u_strlen(uStringOne) == stringLen) {
790 flag = true;
791 }
792 napi_value result = nullptr;
793 napi_get_boolean(env, flag, &result);
794 return result;
795 }
796
testU_strncpy(napi_env env,napi_callback_info)797 static napi_value testU_strncpy(napi_env env, napi_callback_info)
798 {
799 UChar uStringOne[] = {0x41, 0x42, 0x43, 0};
800 UChar uStringTwo[] = {0x41, 0x42, 0};
801 const int32_t stringLen = 2;
802 const int32_t compareLen = 3;
803 u_strncpy(uStringOne, uStringTwo, stringLen);
804 bool flag = false;
805 if (u_strlen(uStringOne) == compareLen) {
806 flag = true;
807 }
808 napi_value result = nullptr;
809 napi_get_boolean(env, flag, &result);
810 return result;
811 }
812
testU_memcpy(napi_env env,napi_callback_info)813 static napi_value testU_memcpy(napi_env env, napi_callback_info)
814 {
815 UChar uStringOne[] = {0x41, 0x42, 0x43, 0};
816 UChar uStringTwo[] = {0x41, 0x42, 0};
817 const int32_t stringLen = 2;
818 const int32_t compareLen = 3;
819 u_memcpy(uStringOne, uStringTwo, stringLen);
820 bool flag = false;
821 if (u_strlen(uStringOne) == compareLen) {
822 flag = true;
823 }
824 napi_value result = nullptr;
825 napi_get_boolean(env, flag, &result);
826 return result;
827 }
828
testU_memmove(napi_env env,napi_callback_info)829 static napi_value testU_memmove(napi_env env, napi_callback_info)
830 {
831 UChar uStringOne[] = {0x41, 0x42, 0x43, 0};
832 UChar uStringTwo[] = {0x41, 0x42, 0};
833 const int32_t stringLen = 2;
834 const int32_t compareLen = 3;
835 u_memmove(uStringOne, uStringTwo, stringLen);
836 bool flag = false;
837 if (u_strlen(uStringOne) == compareLen) {
838 flag = true;
839 }
840 napi_value result = nullptr;
841 napi_get_boolean(env, flag, &result);
842 return result;
843 }
844
testU_memset(napi_env env,napi_callback_info)845 static napi_value testU_memset(napi_env env, napi_callback_info)
846 {
847 UChar uStringOne[] = {0x41, 0x42, 0x43, 0};
848 UChar testChar = 0x41;
849 const int32_t stringLen = 2;
850 u_memset(uStringOne, testChar, stringLen);
851 bool flag = false;
852 if (uStringOne[0] == testChar) {
853 flag = true;
854 }
855 napi_value result = nullptr;
856 napi_get_boolean(env, flag, &result);
857 return result;
858 }
859
testU_memcmp(napi_env env,napi_callback_info)860 static napi_value testU_memcmp(napi_env env, napi_callback_info)
861 {
862 UChar uStringOne[] = {0x41, 0x42, 0x43, 0};
863 UChar uStringTwo[] = {0x41, 0x42, 0x43, 0};
864 const int32_t stringLen = 0;
865 int32_t test = u_memcmp(uStringOne, uStringTwo, 2);
866 bool flag = false;
867 if (test == stringLen) {
868 flag = true;
869 }
870 napi_value result = nullptr;
871 napi_get_boolean(env, flag, &result);
872 return result;
873 }
874
testU_memcmpCodePointOrder(napi_env env,napi_callback_info)875 static napi_value testU_memcmpCodePointOrder(napi_env env, napi_callback_info)
876 {
877 UChar uStringOne[] = {0x41, 0x42, 0x43, 0};
878 UChar uStringTwo[] = {0x41, 0x42, 0x43, 0};
879 const int32_t stringLen = 0;
880 int32_t test = u_memcmpCodePointOrder(uStringOne, uStringTwo, 2);
881 bool flag = false;
882 if (test == stringLen) {
883 flag = true;
884 }
885 napi_value result = nullptr;
886 napi_get_boolean(env, flag, &result);
887 return result;
888 }
889
testU_memchr(napi_env env,napi_callback_info)890 static napi_value testU_memchr(napi_env env, napi_callback_info)
891 {
892 UChar uStringOne[] = {0x41, 0x42, 0x43, 0};
893 UChar testChar = 0x44;
894 UChar *resultA = u_memchr(uStringOne, testChar, 3);
895 bool flag = false;
896 if (resultA == NULL) {
897 flag = true;
898 }
899 napi_value result = nullptr;
900 napi_get_boolean(env, flag, &result);
901 return result;
902 }
903
testU_memchr32(napi_env env,napi_callback_info)904 static napi_value testU_memchr32(napi_env env, napi_callback_info)
905 {
906 UChar uStringOne[] = {0x41, 0x42, 0x43, 0};
907 UChar32 testChar = 0x44;
908 UChar *resultA = u_memchr32(uStringOne, testChar, 3);
909 bool flag = false;
910 if (resultA == NULL) {
911 flag = true;
912 }
913 napi_value result = nullptr;
914 napi_get_boolean(env, flag, &result);
915 return result;
916 }
917
testU_memrchr(napi_env env,napi_callback_info)918 static napi_value testU_memrchr(napi_env env, napi_callback_info)
919 {
920 UChar uStringOne[] = {0x41, 0x42, 0x43, 0};
921 UChar testChar = 0x44;
922 UChar *resultA = u_memrchr(uStringOne, testChar, 3);
923 bool flag = false;
924 if (resultA == NULL) {
925 flag = true;
926 }
927 napi_value result = nullptr;
928 napi_get_boolean(env, flag, &result);
929 return result;
930 }
931
testU_memrchr32(napi_env env,napi_callback_info)932 static napi_value testU_memrchr32(napi_env env, napi_callback_info)
933 {
934 UChar uStringOne[] = {0x41, 0x42, 0x43, 0};
935 UChar32 testChar = 0x44;
936 UChar *resultA = u_memrchr32(uStringOne, testChar, 3);
937 bool flag = false;
938 if (resultA == NULL) {
939 flag = true;
940 }
941 napi_value result = nullptr;
942 napi_get_boolean(env, flag, &result);
943 return result;
944 }
945
testU_strToUpper(napi_env env,napi_callback_info)946 static napi_value testU_strToUpper(napi_env env, napi_callback_info)
947 {
948 UChar uStringOne[] = {0x41, 0x42, 0x43, 0};
949 UChar uStringTwo[] = {0x61, 0x42, 0x43, 0};
950 const char *local = "en";
951 const int32_t uStringSize = 3;
952 UErrorCode status = U_ZERO_ERROR;
953 u_strToUpper(uStringOne, uStringSize, uStringTwo, uStringSize, local, &status);
954 bool flag = U_FAILURE(status);
955 napi_value result = nullptr;
956 napi_get_boolean(env, flag, &result);
957 return result;
958 }
959
testU_strToLower(napi_env env,napi_callback_info)960 static napi_value testU_strToLower(napi_env env, napi_callback_info)
961 {
962 UChar uStringOne[] = {0x41, 0x42, 0x43, 0};
963 UChar uStringTwo[] = {0x41, 0x42, 0x43, 0};
964 const char *local = "en";
965 const int32_t uStringSize = 3;
966 UErrorCode status = U_ZERO_ERROR;
967 u_strToLower(uStringOne, uStringSize, uStringTwo, uStringSize, local, &status);
968 bool flag = U_FAILURE(status);
969 napi_value result = nullptr;
970 napi_get_boolean(env, flag, &result);
971 return result;
972 }
973
testU_strToTitle(napi_env env,napi_callback_info)974 static napi_value testU_strToTitle(napi_env env, napi_callback_info)
975 {
976 UChar uStringOne[] = {0x41, 0x42, 0x43, 0};
977 UChar uStringTwo[] = {0x41, 0x42, 0x43, 0};
978 const char *local = "en";
979 const int32_t uStringSize = 3;
980 UErrorCode status = U_ZERO_ERROR;
981 u_strToTitle(uStringOne, uStringSize, uStringTwo, uStringSize, NULL, local, &status);
982 bool flag = U_FAILURE(status);
983 napi_value result = nullptr;
984 napi_get_boolean(env, flag, &result);
985 return result;
986 }
987
testU_strFoldCase(napi_env env,napi_callback_info)988 static napi_value testU_strFoldCase(napi_env env, napi_callback_info)
989 {
990 UChar uStringOne[] = {0x41, 0x42, 0x43, 0};
991 UChar uStringTwo[] = {0x61, 0x42, 0x43, 0};
992 const char *local = "en";
993 const int32_t uStringSize = 3;
994 UErrorCode status = U_ZERO_ERROR;
995 u_strFoldCase(uStringOne, uStringSize, uStringTwo, uStringSize, U_FOLD_CASE_DEFAULT, &status);
996 bool flag = U_FAILURE(status);
997 napi_value result = nullptr;
998 napi_get_boolean(env, flag, &result);
999 return result;
1000 }
1001
testU_strToUTF8(napi_env env,napi_callback_info)1002 static napi_value testU_strToUTF8(napi_env env, napi_callback_info)
1003 {
1004 char dst[] = {0x41, 0x42, 0x43, 0};
1005 UChar uStringTwo[] = {0x61, 0};
1006 UErrorCode status = U_ZERO_ERROR;
1007 int32_t dstLength;
1008 const int32_t dstSize = 3;
1009 const int32_t uStringTwoSize = 1;
1010 u_strToUTF8(dst, dstSize, &dstLength, uStringTwo, uStringTwoSize, &status);
1011 bool flag = U_FAILURE(status);
1012 napi_value result = nullptr;
1013 napi_get_boolean(env, flag, &result);
1014 return result;
1015 }
1016
testU_strFromUTF8(napi_env env,napi_callback_info)1017 static napi_value testU_strFromUTF8(napi_env env, napi_callback_info)
1018 {
1019 char dst[] = {0x41, 0};
1020 UChar uStringTwo[] = {0x61, 0x41, 0};
1021 UErrorCode status = U_ZERO_ERROR;
1022 int32_t dstLength;
1023 const int32_t dstSize = 2;
1024 const int32_t uStringTwoSize = 1;
1025 u_strFromUTF8(uStringTwo, dstSize, &dstLength, dst, uStringTwoSize, &status);
1026 bool flag = U_FAILURE(status);
1027 napi_value result = nullptr;
1028 napi_get_boolean(env, flag, &result);
1029 return result;
1030 }
1031
testU_strToUTF8WithSub(napi_env env,napi_callback_info)1032 static napi_value testU_strToUTF8WithSub(napi_env env, napi_callback_info)
1033 {
1034 char dst[] = {0x41, 0x42, 0x43, 0};
1035 UChar uStringTwo[] = {0x61, 0};
1036 UChar subChar = 0x40;
1037 UErrorCode status = U_ZERO_ERROR;
1038 int32_t dstLength;
1039 int32_t subCount;
1040 const int32_t dstSize = 3;
1041 const int32_t uStringTwoSize = 1;
1042 u_strToUTF8WithSub(dst, dstSize, &dstLength, uStringTwo, uStringTwoSize, subChar, &subCount, &status);
1043 bool flag = U_FAILURE(status);
1044 napi_value result = nullptr;
1045 napi_get_boolean(env, flag, &result);
1046 return result;
1047 }
1048
testU_strFromUTF8WithSub(napi_env env,napi_callback_info)1049 static napi_value testU_strFromUTF8WithSub(napi_env env, napi_callback_info)
1050 {
1051 char dst[] = {0x41, 0};
1052 UChar uStringTwo[] = {0x61, 0x41, 0};
1053 UChar subChar = 0x40;
1054 UErrorCode status = U_ZERO_ERROR;
1055 int32_t dstLength;
1056 int32_t subCount;
1057 const int32_t dstSize = 2;
1058 const int32_t uStringTwoSize = 1;
1059 u_strFromUTF8WithSub(uStringTwo, dstSize, &dstLength, dst, uStringTwoSize, subChar, &subCount, &status);
1060 bool flag = U_FAILURE(status);
1061 napi_value result = nullptr;
1062 napi_get_boolean(env, flag, &result);
1063 return result;
1064 }
1065
testU_strFromUTF8Lenient(napi_env env,napi_callback_info)1066 static napi_value testU_strFromUTF8Lenient(napi_env env, napi_callback_info)
1067 {
1068 char dst[] = {0x41, 0};
1069 UChar uStringTwo[] = {0x61, 0x41, 0};
1070 UErrorCode status = U_ZERO_ERROR;
1071 int32_t dstLength;
1072 const int32_t dstSize = 2;
1073 const int32_t uStringTwoSize = 1;
1074 u_strFromUTF8Lenient(uStringTwo, dstSize, &dstLength, dst, uStringTwoSize, &status);
1075 bool flag = U_FAILURE(status);
1076 napi_value result = nullptr;
1077 napi_get_boolean(env, flag, &result);
1078 return result;
1079 }
1080
testU_strToUTF32(napi_env env,napi_callback_info)1081 static napi_value testU_strToUTF32(napi_env env, napi_callback_info)
1082 {
1083 UChar32 dst[] = {0x61, 0x41, 0};
1084 UChar uStringTwo[] = {0x61, 0};
1085 UErrorCode status = U_ZERO_ERROR;
1086 int32_t dstLength;
1087 const int32_t dstSize = 2;
1088 const int32_t uStringTwoSize = 1;
1089 u_strToUTF32(dst, dstSize, &dstLength, uStringTwo, uStringTwoSize, &status);
1090 bool flag = U_FAILURE(status);
1091 napi_value result = nullptr;
1092 napi_get_boolean(env, flag, &result);
1093 return result;
1094 }
1095
testU_strFromUTF32(napi_env env,napi_callback_info)1096 static napi_value testU_strFromUTF32(napi_env env, napi_callback_info)
1097 {
1098 UChar dst[] = {0x61, 0x41, 0};
1099 UChar32 uStringTwo[] = {0x61, 0};
1100 UErrorCode status = U_ZERO_ERROR;
1101 int32_t dstLength;
1102 const int32_t dstSize = 2;
1103 const int32_t uStringTwoSize = 1;
1104 u_strFromUTF32(dst, dstSize, &dstLength, uStringTwo, uStringTwoSize, &status);
1105 bool flag = U_FAILURE(status);
1106 napi_value result = nullptr;
1107 napi_get_boolean(env, flag, &result);
1108 return result;
1109 }
1110
testU_strToUTF32WithSub(napi_env env,napi_callback_info)1111 static napi_value testU_strToUTF32WithSub(napi_env env, napi_callback_info)
1112 {
1113 UChar32 dst[] = {0x61, 0x41, 0};
1114 UChar uStringTwo[] = {0x61, 0};
1115 UErrorCode status = U_ZERO_ERROR;
1116 int32_t dstLength;
1117 UChar subChar = 0x40;
1118 int32_t subCount;
1119 const int32_t dstSize = 2;
1120 const int32_t uStringTwoSize = 1;
1121 u_strToUTF32WithSub(dst, dstSize, &dstLength, uStringTwo, uStringTwoSize, subChar, &subCount, &status);
1122 bool flag = U_FAILURE(status);
1123 napi_value result = nullptr;
1124 napi_get_boolean(env, flag, &result);
1125 return result;
1126 }
1127
testU_strFromUTF32WithSub(napi_env env,napi_callback_info)1128 static napi_value testU_strFromUTF32WithSub(napi_env env, napi_callback_info)
1129 {
1130 UChar dst[] = {0x61, 0x41, 0};
1131 UChar32 uStringTwo[] = {0x61, 0};
1132 UErrorCode status = U_ZERO_ERROR;
1133 int32_t dstLength;
1134 UChar subChar = 0x40;
1135 int32_t subCount;
1136 const int32_t dstSize = 2;
1137 const int32_t uStringTwoSize = 1;
1138 u_strFromUTF32WithSub(dst, dstSize, &dstLength, uStringTwo, uStringTwoSize, subChar, &subCount, &status);
1139 bool flag = U_FAILURE(status);
1140 napi_value result = nullptr;
1141 napi_get_boolean(env, flag, &result);
1142 return result;
1143 }
1144
testU_errorName(napi_env env,napi_callback_info)1145 static napi_value testU_errorName(napi_env env, napi_callback_info)
1146 {
1147 const char *resultA = u_errorName(U_ZERO_ERROR);
1148 bool flag = false;
1149 if (resultA != nullptr) {
1150 flag = true;
1151 }
1152 napi_value result = nullptr;
1153 napi_get_boolean(env, flag, &result);
1154 return result;
1155 }
1156
1157 EXTERN_C_START
Init(napi_env env,napi_value exports)1158 static napi_value Init(napi_env env, napi_value exports)
1159 {
1160 napi_property_descriptor desc[] = {
1161 {"testuidna_openUTS46", nullptr, TestUidna_openUTS46, nullptr, nullptr,
1162 nullptr, napi_default, nullptr},
1163 {"testuidna_close", nullptr, testUidna_close, nullptr, nullptr,
1164 nullptr, napi_default, nullptr},
1165 {"testuidna_labelToASCII", nullptr, testUidna_labelToASCII, nullptr, nullptr,
1166 nullptr, napi_default, nullptr},
1167 {"testuidna_labelToUnicode", nullptr, testUidna_labelToUnicode, nullptr, nullptr,
1168 nullptr, napi_default, nullptr},
1169 {"testuidna_nameToASCII", nullptr, testUidna_nameToASCII, nullptr, nullptr,
1170 nullptr, napi_default, nullptr},
1171 {"testuidna_nameToUnicode", nullptr, testUidna_nameToUnicode, nullptr, nullptr,
1172 nullptr, napi_default, nullptr},
1173 {"testuidna_labelToASCLL_UTF8", nullptr, testUidna_labelToASCLL_UTF8, nullptr,
1174 nullptr, nullptr, napi_default, nullptr},
1175 {"testuidna_labelToUnicodeUTF8", nullptr, testUidna_labelToUnicodeUTF8, nullptr,
1176 nullptr, nullptr, napi_default, nullptr},
1177 {"testuidna_nameToASCII_UTF8", nullptr, testUidna_nameToASCII_UTF8, nullptr,
1178 nullptr, nullptr, napi_default, nullptr},
1179 {"testuidna_nameToUnicodeUTF8", nullptr, testUidna_nameToUnicodeUTF8, nullptr,
1180 nullptr, nullptr, napi_default, nullptr},
1181 {"testutext_openUTF8", nullptr, testUtext_openUTF8, nullptr,
1182 nullptr, nullptr, napi_default, nullptr},
1183 {"testutext_openUTF8_close", nullptr, testUtext_openUTF8_close, nullptr,
1184 nullptr, nullptr, napi_default, nullptr},
1185 {"testutext_clone", nullptr, testUtext_clone, nullptr,
1186 nullptr, nullptr, napi_default, nullptr},
1187 {"testutext_equals", nullptr, testUtext_equals, nullptr,
1188 nullptr, nullptr, napi_default, nullptr},
1189 {"testutext_nativeLength", nullptr, testUtext_nativeLength, nullptr,
1190 nullptr, nullptr, napi_default, nullptr},
1191 {"testutext_char32At", nullptr, testUtext_char32At, nullptr,
1192 nullptr, nullptr, napi_default, nullptr},
1193 {"testutext_current32", nullptr, testUtext_current32, nullptr,
1194 nullptr, nullptr, napi_default, nullptr},
1195 {"testutext_next32", nullptr, testUtext_next32, nullptr,
1196 nullptr, nullptr, napi_default, nullptr},
1197 {"testutext_previous32", nullptr, testUtext_previous32, nullptr,
1198 nullptr, nullptr, napi_default, nullptr},
1199 {"testutext_next32From", nullptr, testUtext_next32From, nullptr,
1200 nullptr, nullptr, napi_default, nullptr},
1201 {"testutext_previous32From", nullptr, testUtext_previous32From, nullptr,
1202 nullptr, nullptr, napi_default, nullptr},
1203 {"testutext_getNativeIndex", nullptr, testUtext_getNativeIndex, nullptr,
1204 nullptr, nullptr, napi_default, nullptr},
1205 {"testutext_setNativeIndex_moveIndex32", nullptr, testUtext_setNativeIndex_moveIndex32, nullptr,
1206 nullptr, nullptr, napi_default, nullptr},
1207 {"testutext_getPreviousNativeIndex", nullptr, testUtext_getPreviousNativeIndex, nullptr,
1208 nullptr, nullptr, napi_default, nullptr},
1209 {"testutext_extract", nullptr, testUtext_extract, nullptr,
1210 nullptr, nullptr, napi_default, nullptr},
1211 {"testu_strlen", nullptr, testU_strlen, nullptr,
1212 nullptr, nullptr, napi_default, nullptr},
1213 {"testu_countChar32", nullptr, testU_countChar32, nullptr,
1214 nullptr, nullptr, napi_default, nullptr},
1215 {"testu_strHasMoreChar32Than", nullptr, testU_strHasMoreChar32Than, nullptr,
1216 nullptr, nullptr, napi_default, nullptr},
1217 {"testu_strcat", nullptr, testU_strcat, nullptr,
1218 nullptr, nullptr, napi_default, nullptr},
1219 {"testu_strncat", nullptr, testU_strncat, nullptr,
1220 nullptr, nullptr, napi_default, nullptr},
1221 {"testu_strstr", nullptr, testU_strstr, nullptr,
1222 nullptr, nullptr, napi_default, nullptr},
1223 {"testu_strFindFirst", nullptr, testU_strFindFirst, nullptr,
1224 nullptr, nullptr, napi_default, nullptr},
1225 {"testu_strchr", nullptr, testU_strchr, nullptr,
1226 nullptr, nullptr, napi_default, nullptr},
1227 {"testu_strchr32", nullptr, testU_strchr32, nullptr,
1228 nullptr, nullptr, napi_default, nullptr},
1229 {"testu_strrstr", nullptr, testU_strrstr, nullptr,
1230 nullptr, nullptr, napi_default, nullptr},
1231 {"testu_strFindLast", nullptr, testU_strFindLast, nullptr,
1232 nullptr, nullptr, napi_default, nullptr},
1233 {"testu_strrchr", nullptr, testU_strrchr, nullptr,
1234 nullptr, nullptr, napi_default, nullptr},
1235 {"testu_strrchr32", nullptr, testU_strrchr32, nullptr,
1236 nullptr, nullptr, napi_default, nullptr},
1237 {"testu_strpbrk", nullptr, testU_strpbrk, nullptr,
1238 nullptr, nullptr, napi_default, nullptr},
1239 {"testu_strcspn", nullptr, testU_strcspn, nullptr,
1240 nullptr, nullptr, napi_default, nullptr},
1241 {"testu_strspn", nullptr, testU_strspn, nullptr,
1242 nullptr, nullptr, napi_default, nullptr},
1243 {"testu_strtok_r", nullptr, testU_strtok_r, nullptr,
1244 nullptr, nullptr, napi_default, nullptr},
1245 {"testu_strcmp", nullptr, testU_strcmp, nullptr,
1246 nullptr, nullptr, napi_default, nullptr},
1247 {"testu_strcmpCodePointOrder", nullptr, testU_strcmpCodePointOrder, nullptr,
1248 nullptr, nullptr, napi_default, nullptr},
1249 {"testu_strCompare", nullptr, testU_strCompare, nullptr,
1250 nullptr, nullptr, napi_default, nullptr},
1251 {"testu_strCaseCompare", nullptr, testU_strCaseCompare, nullptr,
1252 nullptr, nullptr, napi_default, nullptr},
1253 {"testu_strncmp", nullptr, testU_strncmp, nullptr,
1254 nullptr, nullptr, napi_default, nullptr},
1255 {"testu_strncmpCodePointOrder", nullptr, testU_strncmpCodePointOrder, nullptr,
1256 nullptr, nullptr, napi_default, nullptr},
1257 {"testu_strcasecmp", nullptr, testU_strcasecmp, nullptr,
1258 nullptr, nullptr, napi_default, nullptr},
1259 {"testu_strncasecmp", nullptr, testU_strncasecmp, nullptr,
1260 nullptr, nullptr, napi_default, nullptr},
1261 {"testu_memcasecmp", nullptr, testU_memcasecmp, nullptr,
1262 nullptr, nullptr, napi_default, nullptr},
1263 {"testu_strcpy", nullptr, testU_strcpy, nullptr,
1264 nullptr, nullptr, napi_default, nullptr},
1265 {"testu_strncpy", nullptr, testU_strncpy, nullptr,
1266 nullptr, nullptr, napi_default, nullptr},
1267 {"testu_memcpy", nullptr, testU_memcpy, nullptr,
1268 nullptr, nullptr, napi_default, nullptr},
1269 {"testu_memmove", nullptr, testU_memmove, nullptr,
1270 nullptr, nullptr, napi_default, nullptr},
1271 {"testu_memset", nullptr, testU_memset, nullptr,
1272 nullptr, nullptr, napi_default, nullptr},
1273 {"testu_memcmp", nullptr, testU_memcmp, nullptr,
1274 nullptr, nullptr, napi_default, nullptr},
1275 {"testu_memcmpCodePointOrder", nullptr, testU_memcmpCodePointOrder, nullptr,
1276 nullptr, nullptr, napi_default, nullptr},
1277 {"testu_memchr", nullptr, testU_memchr, nullptr,
1278 nullptr, nullptr, napi_default, nullptr},
1279 {"testu_memchr32", nullptr, testU_memchr32, nullptr,
1280 nullptr, nullptr, napi_default, nullptr},
1281 {"testu_memrchr", nullptr, testU_memrchr, nullptr,
1282 nullptr, nullptr, napi_default, nullptr},
1283 {"testu_memrchr32", nullptr, testU_memrchr32, nullptr,
1284 nullptr, nullptr, napi_default, nullptr},
1285 {"testu_strToUpper", nullptr, testU_strToUpper, nullptr,
1286 nullptr, nullptr, napi_default, nullptr},
1287 {"testu_strToLower", nullptr, testU_strToLower, nullptr,
1288 nullptr, nullptr, napi_default, nullptr},
1289 {"testu_strToTitle", nullptr, testU_strToTitle, nullptr,
1290 nullptr, nullptr, napi_default, nullptr},
1291 {"testu_strFoldCase", nullptr, testU_strFoldCase, nullptr,
1292 nullptr, nullptr, napi_default, nullptr},
1293 {"testu_strToUTF8", nullptr, testU_strToUTF8, nullptr,
1294 nullptr, nullptr, napi_default, nullptr},
1295 {"testu_strFromUTF8", nullptr, testU_strFromUTF8, nullptr,
1296 nullptr, nullptr, napi_default, nullptr},
1297 {"testu_strToUTF8WithSub", nullptr, testU_strToUTF8WithSub, nullptr,
1298 nullptr, nullptr, napi_default, nullptr},
1299 {"testu_strFromUTF8WithSub", nullptr, testU_strFromUTF8WithSub, nullptr,
1300 nullptr, nullptr, napi_default, nullptr},
1301 {"testu_strFromUTF8Lenient", nullptr, testU_strFromUTF8Lenient, nullptr,
1302 nullptr, nullptr, napi_default, nullptr},
1303 {"testu_strToUTF32", nullptr, testU_strToUTF32, nullptr,
1304 nullptr, nullptr, napi_default, nullptr},
1305 {"testu_strFromUTF32", nullptr, testU_strFromUTF32, nullptr,
1306 nullptr, nullptr, napi_default, nullptr},
1307 {"testu_strToUTF32WithSub", nullptr, testU_strToUTF32WithSub, nullptr,
1308 nullptr, nullptr, napi_default, nullptr},
1309 {"testu_strFromUTF32WithSub", nullptr, testU_strFromUTF32WithSub, nullptr,
1310 nullptr, nullptr, napi_default, nullptr},
1311 {"testu_errorName", nullptr, testU_errorName, nullptr,
1312 nullptr, nullptr, napi_default, nullptr},
1313 };
1314 napi_define_properties(env, exports, sizeof(desc) / sizeof(desc[0]), desc);
1315 return exports;
1316 }
1317 EXTERN_C_END
1318
1319 static napi_module demoModule = {
1320 .nm_version = 1,
1321 .nm_flags = 0,
1322 .nm_filename = nullptr,
1323 .nm_register_func = Init,
1324 .nm_modname = "entry",
1325 .nm_priv = ((void *)0),
1326 .reserved = {0},
1327 };
1328
RegisterEntryModule(void)1329 extern "C" __attribute__((constructor)) void RegisterEntryModule(void)
1330 {
1331 napi_module_register(&demoModule);
1332 }
1333