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 "functionalext.h"
17
18 typedef void (*TEST_FUN)();
19
20 /**
21 * @tc.name : printf_0100
22 * @tc.desc : Verify the output data in the specified format (the format character is d)
23 * @tc.level : Level 0
24 */
printf_0100(void)25 void printf_0100(void)
26 {
27 int num = 6;
28 int result = printf("%d\n", num);
29 EXPECT_TRUE("printf_0100", result > 0);
30 }
31
32 /**
33 * @tc.name : printf_0200
34 * @tc.desc : Verify the output data in the specified format (the format character is o)
35 * @tc.level : Level 0
36 */
printf_0200(void)37 void printf_0200(void)
38 {
39 int num = 6;
40 int result = printf("%o\n", num);
41 EXPECT_TRUE("printf_0200", result > 0);
42 }
43
44 /**
45 * @tc.name : printf_0300
46 * @tc.desc : Verify the output data in the specified format (the format character is x,X)
47 * @tc.level : Level 0
48 */
printf_0300(void)49 void printf_0300(void)
50 {
51 int num = 6;
52 int result = printf("%x\n", num);
53 EXPECT_TRUE("printf_0300", result > 0);
54
55 result = printf("%X\n", num);
56 EXPECT_TRUE("printf_0300", result > 0);
57 }
58
59 /**
60 * @tc.name : printf_0400
61 * @tc.desc : Verify the output data in the specified format (the format character is u)
62 * @tc.level : Level 0
63 */
printf_0400(void)64 void printf_0400(void)
65 {
66 int num = 6;
67 int result = printf("%u\n", num);
68 EXPECT_TRUE("printf_0400", result > 0);
69 }
70
71 /**
72 * @tc.name : printf_0500
73 * @tc.desc : Verify the output data in the specified format (the format character is f)
74 * @tc.level : Level 0
75 */
printf_0500(void)76 void printf_0500(void)
77 {
78 int num = 6;
79 int result = printf("%f\n", num);
80 EXPECT_TRUE("printf_0500", result > 0);
81 }
82
83 /**
84 * @tc.name : printf_0600
85 * @tc.desc : Verify the output data in the specified format (the format character is e,E)
86 * @tc.level : Level 0
87 */
printf_0600(void)88 void printf_0600(void)
89 {
90 int num = 6;
91 int result = printf("%e\n", num);
92 EXPECT_TRUE("printf_0600", result > 0);
93
94 result = printf("%E\n", num);
95 EXPECT_TRUE("printf_0600", result > 0);
96 }
97
98 /**
99 * @tc.name : printf_0700
100 * @tc.desc : Verify the output data in the specified format (the format character is g,G)
101 * @tc.level : Level 0
102 */
printf_0700(void)103 void printf_0700(void)
104 {
105 int num = 6;
106 int result = printf("%g\n", num);
107 EXPECT_TRUE("printf_0700", result > 0);
108
109 result = printf("%G\n", num);
110 EXPECT_TRUE("printf_0700", result > 0);
111 }
112
113 /**
114 * @tc.name : printf_0800
115 * @tc.desc : Verify the output data in the specified format (the format character is c)
116 * @tc.level : Level 0
117 */
printf_0800(void)118 void printf_0800(void)
119 {
120 char ch = 'a';
121 int result = printf("%c\n", ch);
122 EXPECT_TRUE("printf_0800", result > 0);
123 }
124
125 /**
126 * @tc.name : printf_0900
127 * @tc.desc : Verify the output data in the specified format (the format character is s)
128 * @tc.level : Level 0
129 */
printf_0900(void)130 void printf_0900(void)
131 {
132 char num[] = "test";
133 int result = printf("%s\n", num);
134 EXPECT_TRUE("printf_0900", result > 0);
135 }
136
main(int argc,char * argv[])137 int main(int argc, char *argv[])
138 {
139 printf_0100();
140 printf_0200();
141 printf_0300();
142 printf_0400();
143 printf_0500();
144 printf_0600();
145 printf_0700();
146 printf_0800();
147 printf_0900();
148
149 return t_status;
150 }