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, PosixCTypeToupperTest);
47
48 /* *
49 * @tc.setup : setup for all testcases
50 * @return : setup result, TRUE is success, FALSE is fail
51 */
PosixCTypeToupperTestSetUp(void)52 static BOOL PosixCTypeToupperTestSetUp(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 */
PosixCTypeToupperTestTearDown(void)61 static BOOL PosixCTypeToupperTestTearDown(void)
62 {
63 LOG("+-------------------------------------------+\n");
64 return TRUE;
65 }
66
67 /* *
68 * @tc.number : TEST_CTYPE_TOUPPER_001
69 * @tc.name : Converts a lowercase letter to uppercase equivalent
70 * @tc.desc : [C- SOFTWARE -0200]
71 */
72 LITE_TEST_CASE(PosixCTypeToupperTest, testCTypeToupper001, Function | MediumTest | Level1)
73 {
74 int a = 'a';
75 int ret = toupper(a);
76 if (ret == 'A') {
77 LOG("[DEMO] posix ctype test case 1:toupper(%c)==%c ok.\n", a, ret);
78 } else {
79 LOG("[DEMO] posix ctype test case 1:toupper(%c)!=%c fail.\n", a);
80 }
81 TEST_ASSERT_TRUE(ret == 'A');
82 return 0;
83 }
84
85 /* *
86 * @tc.number : TEST_CTYPE_TOUPPER_002
87 * @tc.name : Converts a lowercase letter to uppercase equivalent
88 * @tc.desc : [C- SOFTWARE -0200]
89 */
90 LITE_TEST_CASE(PosixCTypeToupperTest, testCTypeToupper002, Function | MediumTest | Level1)
91 {
92 int a = 'A';
93 int ret = toupper(a);
94 if (ret == 'A') {
95 LOG("[DEMO] posix ctype test case 2:toupper(%c)==%c ok.\n", a, ret);
96 } else {
97 LOG("[DEMO] posix ctype test case 2:toupper(%c)!=%c fail.\n", a);
98 }
99 TEST_ASSERT_TRUE(ret == 'A');
100 return 0;
101 }
102
103 /* *
104 * @tc.number : TEST_CTYPE_TOUPPER_003
105 * @tc.name : Converts a lowercase letter to uppercase equivalent
106 * @tc.desc : [C- SOFTWARE -0200]
107 */
108 LITE_TEST_CASE(PosixCTypeToupperTest, testCTypeToupper003, Function | MediumTest | Level1)
109 {
110 int a = 'z';
111 int ret = toupper(a);
112 if (ret == 'Z') {
113 LOG("[DEMO] posix ctype test case 3:toupper(%c)==%c ok.\n", a, ret);
114 } else {
115 LOG("[DEMO] posix ctype test case 3:toupper(%c)!=%c fail.\n", a);
116 }
117 TEST_ASSERT_TRUE(ret == 'Z');
118 return 0;
119 }
120
121 /* *
122 * @tc.number : TEST_CTYPE_TOUPPER_004
123 * @tc.name : Converts a lowercase letter to uppercase equivalent
124 * @tc.desc : [C- SOFTWARE -0200]
125 */
126 LITE_TEST_CASE(PosixCTypeToupperTest, testCTypeToupper004, Function | MediumTest | Level1)
127 {
128 int a = 'Z';
129 int ret = toupper(a);
130 if (ret == 'Z') {
131 LOG("[DEMO] posix ctype test case 4:toupper(%c)==%c ok.\n", a, ret);
132 } else {
133 LOG("[DEMO] posix ctype test case 4:toupper(%c)!=%c fail.\n", a);
134 }
135 TEST_ASSERT_TRUE(ret == 'Z');
136 return 0;
137 }
138
139 /* *
140 * @tc.number : TEST_CTYPE_TOUPPER_005
141 * @tc.name : Converts a lowercase letter to uppercase equivalent
142 * @tc.desc : [C- SOFTWARE -0200]
143 */
144 LITE_TEST_CASE(PosixCTypeToupperTest, testCTypeToupper005, Function | MediumTest | Level1)
145 {
146 int a = '1';
147 int ret = toupper(a);
148 if (ret == '1') {
149 LOG("[DEMO] posix ctype test case 5(except):toupper(%c)==%c ok.\n", a, ret);
150 } else {
151 LOG("[DEMO] posix ctype test case 5(except):toupper(%c)!=%c fail.\n", a);
152 }
153 TEST_ASSERT_TRUE(ret == '1');
154 return 0;
155 }
156
157 RUN_TEST_SUITE(PosixCTypeToupperTest);
158
PosixToupperFuncTest()159 void PosixToupperFuncTest()
160 {
161 LOG("begin PosixToupperFuncTest....");
162 RUN_ONE_TESTCASE(testCTypeToupper001);
163 RUN_ONE_TESTCASE(testCTypeToupper002);
164 RUN_ONE_TESTCASE(testCTypeToupper003);
165 RUN_ONE_TESTCASE(testCTypeToupper004);
166 RUN_ONE_TESTCASE(testCTypeToupper005);
167
168 return;
169 }