1 /*
2 * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
3 * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without modification,
6 * are permitted provided that the following conditions are met:
7 *
8 * 1. Redistributions of source code must retain the above copyright notice, this list of
9 * conditions and the following disclaimer.
10 *
11 * 2. Redistributions in binary form must reproduce the above copyright notice, this list
12 * of conditions and the following disclaimer in the documentation and/or other materials
13 * provided with the distribution.
14 *
15 * 3. Neither the name of the copyright holder nor the names of its contributors may be used
16 * to endorse or promote products derived from this software without specific prior written
17 * permission.
18 *
19 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
21 * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
23 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
24 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
25 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
26 * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
27 * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
28 * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
29 * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30 */
31
32 #include <ctype.h>
33 #include "ohos_types.h"
34 #include "posix_test.h"
35 #include "los_config.h"
36 #include "kernel_test.h"
37 #include "log.h"
38
39
40 /* *
41 * @tc.desc : register a test suite, this suite is used to test basic flow and interface dependency
42 * @param : subsystem name is utils
43 * @param : module name is utilsFile
44 * @param : test suit name is CmsisTaskFuncTestSuite
45 */
46 LITE_TEST_SUIT(Posix, Posixtimer, PosixCTypeIslowerTest);
47
48 /* *
49 * @tc.setup : setup for all testcases
50 * @return : setup result, TRUE is success, FALSE is fail
51 */
PosixCTypeIslowerTestSetUp(void)52 static BOOL PosixCTypeIslowerTestSetUp(void)
53 {
54 return TRUE;
55 }
56
57 /* *
58 * @tc.teardown : teardown for all testcases
59 * @return : teardown result, TRUE is success, FALSE is fail
60 */
PosixCTypeIslowerTestTearDown(void)61 static BOOL PosixCTypeIslowerTestTearDown(void)
62 {
63 LOG("+-------------------------------------------+\n");
64 return TRUE;
65 }
66
67 /* *
68 * @tc.number : TEST_CTYPE_ISLOWER_001
69 * @tc.name : Checks whether a parameter is a lowercase letter
70 * @tc.desc : [C- SOFTWARE -0200]
71 */
72 LITE_TEST_CASE(PosixCTypeIslowerTest, testCTypeIslower001, Function | MediumTest | Level1)
73 {
74 int a = 'a';
75 int ret = islower(a);
76 if (ret != 0) {
77 LOG("[DEMO] posix ctype test case 1:islower(%c) ok.\n", a);
78 } else {
79 LOG("[DEMO] posix ctype test case 1:islower(%c) fail.\n", a);
80 }
81 ICUNIT_ASSERT_EQUAL(ret, 1, ret);
82 return 0;
83 }
84
85 /* *
86 * @tc.number : TEST_CTYPE_ISLOWER_002
87 * @tc.name : Checks whether a parameter is a lowercase letter
88 * @tc.desc : [C- SOFTWARE -0200]
89 */
90 LITE_TEST_CASE(PosixCTypeIslowerTest, testCTypeIslower002, Function | MediumTest | Level1)
91 {
92 int a = 'z';
93 int ret = islower(a);
94 if (ret != 0) {
95 LOG("[DEMO] posix ctype test case 2:islower(%c) ok.\n", a);
96 } else {
97 LOG("[DEMO] posix ctype test case 2:islower(%c) fail.\n", a);
98 }
99 ICUNIT_ASSERT_EQUAL(ret, 1, ret);
100 return 0;
101 }
102
103 /* *
104 * @tc.number : TEST_CTYPE_ISLOWER_003
105 * @tc.name : Checks whether a parameter is a lowercase letter
106 * @tc.desc : [C- SOFTWARE -0200]
107 */
108 LITE_TEST_CASE(PosixCTypeIslowerTest, testCTypeIslower003, Function | MediumTest | Level1)
109 {
110 int a = 'f';
111 int ret = islower(a);
112 if (ret != 0) {
113 LOG("[DEMO] posix ctype test case 3:islower(%c) ok.\n", a);
114 } else {
115 LOG("[DEMO] posix ctype test case 3:islower(%c) fail.\n", a);
116 }
117 ICUNIT_ASSERT_EQUAL(ret, 1, ret);
118 return 0;
119 }
120
121 /* *
122 * @tc.number : TEST_CTYPE_ISLOWER_004
123 * @tc.name : Checks whether a parameter is a lowercase letter
124 * @tc.desc : [C- SOFTWARE -0200]
125 */
126 LITE_TEST_CASE(PosixCTypeIslowerTest, testCTypeIslower004, Function | MediumTest | Level1)
127 {
128 int a = 'a' - 1;
129 int ret = islower(a);
130 if (ret == 0) {
131 LOG("[DEMO] posix ctype test case 4(except):islower(%c) ok.\n", a);
132 } else {
133 LOG("[DEMO] posix ctype test case 4(except):islower(%c) fail.\n", a);
134 }
135 ICUNIT_ASSERT_EQUAL(ret, 0, ret);
136 return 0;
137 }
138
139 /* *
140 * @tc.number : TEST_CTYPE_ISLOWER_005
141 * @tc.name : Checks whether a parameter is a lowercase letter
142 * @tc.desc : [C- SOFTWARE -0200]
143 */
144 LITE_TEST_CASE(PosixCTypeIslowerTest, testCTypeIslower005, Function | MediumTest | Level1)
145 {
146 int a = 'z' + 1;
147 int ret = islower(a);
148 if (ret == 0) {
149 LOG("[DEMO] posix ctype test case 5(except):islower(%c) ok.\n", a);
150 } else {
151 LOG("[DEMO] posix ctype test case 5(except):islower(%c) fail.\n", a);
152 }
153 ICUNIT_ASSERT_EQUAL(ret, 0, ret);
154 return 0;
155 }
156
157 /* *
158 * @tc.number : TEST_CTYPE_ISLOWER_006
159 * @tc.name : Checks whether a parameter is a lowercase letter
160 * @tc.desc : [C- SOFTWARE -0200]
161 */
162 LITE_TEST_CASE(PosixCTypeIslowerTest, testCTypeIslower006, Function | MediumTest | Level1)
163 {
164 int a = 'A';
165 int ret = islower(a);
166 if (ret == 0) {
167 LOG("[DEMO] posix ctype test case 6(except):islower(%c) ok.\n", a);
168 } else {
169 LOG("[DEMO] posix ctype test case 6(except):islower(%c) fail.\n", a);
170 }
171 ICUNIT_ASSERT_EQUAL(ret, 0, ret);
172 return 0;
173 }
174
PosixIslowerFuncTest()175 void PosixIslowerFuncTest()
176 {
177 LOG("begin PosixIslowerFuncTest....");
178 RUN_ONE_TESTCASE(testCTypeIslower001);
179 RUN_ONE_TESTCASE(testCTypeIslower002);
180 RUN_ONE_TESTCASE(testCTypeIslower003);
181 RUN_ONE_TESTCASE(testCTypeIslower004);
182 RUN_ONE_TESTCASE(testCTypeIslower005);
183 RUN_ONE_TESTCASE(testCTypeIslower006);
184
185 return;
186 }