• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2022 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 <stdio.h>
17 #include <locale.h>
18 #include <wchar.h>
19 #include "test.h"
20 
wcsxfrm_0100(void)21 void wcsxfrm_0100(void)
22 {
23     wchar_t *wc = L"ABCD";
24     wchar_t src[20];
25     size_t result = wcsxfrm(src, wc, 5);
26     if (result != wcslen(wc)) {
27         t_error("%s wcsxfrm get result is %d are not %d\n", __func__, result, wcslen(wc));
28     }
29     if (wcscmp(src, wc) != 0) {
30         t_error("%s wcsxfrm get is %ls are not %ls\n", __func__, src, wc);
31     }
32 }
33 
wcsxfrm_0200(void)34 void wcsxfrm_0200(void)
35 {
36     wchar_t *wc = L"\u00e5\ue011";
37     wchar_t src[20];
38     size_t result = wcsxfrm(src, wc, 1);
39     if (result != wcslen(wc)) {
40         t_error("%s wcsxfrm get result is %d are not %d\n", __func__, result, wcslen(wc));
41     }
42 }
43 
main(int argc,char * argv[])44 int main(int argc, char *argv[])
45 {
46     setlocale(LC_COLLATE, "en_US.utf8");
47     /**
48      * @tc.name      : wcsxfrm_0100
49      * @tc.desc      : Call wcsxfrm to copy wide strings
50      * @tc.level     : Level 0
51      */
52     wcsxfrm_0100();
53     /**
54      * @tc.name      : wcsxfrm_0200
55      * @tc.desc      : The incoming length is less than the wide string length
56      * @tc.level     : Level 0
57      */
58     wcsxfrm_0200();
59     return t_status;
60 }