• 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 <wchar.h>
17 #include <stdio.h>
18 #include <string.h>
19 #include "test.h"
20 
21 /**
22  * @tc.name      : wcscasecmp_0100
23  * @tc.desc      : Test wcscasecmp compare case-ignoring wide strings
24  * @tc.level     : Level 0
25  */
wcscasecmp_0100(void)26 void wcscasecmp_0100(void)
27 {
28     int result = wcscasecmp(L"hello", L"HELLO");
29     if (result != 0) {
30         t_error("%s wcscasecmp get result is %d are not 0\n", __func__, result);
31     }
32 }
33 
34 /**
35  * @tc.name      : wcscasecmp_0200
36  * @tc.desc      : Test the result of calling wcscasecmp with uppercase letters, plus numbers, and lowercase letters
37  *                 and small numbers
38  * @tc.level     : Level 1
39  */
wcscasecmp_0200(void)40 void wcscasecmp_0200(void)
41 {
42     int result = wcscasecmp(L"hello1", L"HELLO2");
43     if (result >= 0) {
44         t_error("%s wcscasecmp get result is %d are more then 0\n", __func__, result);
45     }
46 }
47 
48 /**
49  * @tc.name      : wcscasecmp_0300
50  * @tc.desc      : Test the result of calling wcscasecmp with uppercase letters plus small numbers and lowercase
51  *                 letters and large numbers
52  * @tc.level     : Level 1
53  */
wcscasecmp_0300(void)54 void wcscasecmp_0300(void)
55 {
56     int result = wcscasecmp(L"hello2", L"HELLO1");
57     if (result <= 0) {
58         t_error("%s wcscasecmp get result is %d are less then 0\n", __func__, result);
59     }
60 }
61 
62 /**
63  * @tc.name      : wcscasecmp_0400
64  * @tc.desc      : Test the result of calling wcscasecmp for shorter uppercase wide strings versus longer lowercase
65  *                 wide strings
66  * @tc.level     : Level 1
67  */
wcscasecmp_0400(void)68 void wcscasecmp_0400(void)
69 {
70     int result = wcscasecmp(L"hello", L"HELL");
71     if (result <= 0) {
72         t_error("%s wcscasecmp get result is %d are less then 0\n", __func__, result);
73     }
74 }
75 
76 /**
77  * @tc.name      : wcscasecmp_0500
78  * @tc.desc      : Test the result of calling wcscasecmp on a shorter lowercase wide string versus a longer uppercase
79  *                 wide string
80  * @tc.level     : Level 1
81  */
wcscasecmp_0500(void)82 void wcscasecmp_0500(void)
83 {
84     int result = wcscasecmp(L"hell", L"HELLO");
85     if (result >= 0) {
86         t_error("%s wcscasecmp get result is %d are more then 0\n", __func__, result);
87     }
88 }
89 
main(int argc,char * argv[])90 int main(int argc, char *argv[])
91 {
92     wcscasecmp_0100();
93     wcscasecmp_0200();
94     wcscasecmp_0300();
95     wcscasecmp_0400();
96     wcscasecmp_0500();
97     return t_status;
98 }