1570af302Sopenharmony_ci/* 2570af302Sopenharmony_ci * Copyright (c) 2022 Huawei Device Co., Ltd. 3570af302Sopenharmony_ci * Licensed under the Apache License, Version 2.0 (the "License"); 4570af302Sopenharmony_ci * you may not use this file except in compliance with the License. 5570af302Sopenharmony_ci * You may obtain a copy of the License at 6570af302Sopenharmony_ci * 7570af302Sopenharmony_ci * http://www.apache.org/licenses/LICENSE-2.0 8570af302Sopenharmony_ci * 9570af302Sopenharmony_ci * Unless required by applicable law or agreed to in writing, software 10570af302Sopenharmony_ci * distributed under the License is distributed on an "AS IS" BASIS, 11570af302Sopenharmony_ci * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12570af302Sopenharmony_ci * See the License for the specific language governing permissions and 13570af302Sopenharmony_ci * limitations under the License. 14570af302Sopenharmony_ci */ 15570af302Sopenharmony_ci 16570af302Sopenharmony_ci#include "functionalext.h" 17570af302Sopenharmony_ci 18570af302Sopenharmony_citypedef void (*TEST_FUN)(); 19570af302Sopenharmony_ci 20570af302Sopenharmony_ci/** 21570af302Sopenharmony_ci * @tc.name : printf_0100 22570af302Sopenharmony_ci * @tc.desc : Verify the output data in the specified format (the format character is d) 23570af302Sopenharmony_ci * @tc.level : Level 0 24570af302Sopenharmony_ci */ 25570af302Sopenharmony_civoid printf_0100(void) 26570af302Sopenharmony_ci{ 27570af302Sopenharmony_ci int num = 6; 28570af302Sopenharmony_ci int result = printf("%d\n", num); 29570af302Sopenharmony_ci EXPECT_TRUE("printf_0100", result > 0); 30570af302Sopenharmony_ci} 31570af302Sopenharmony_ci 32570af302Sopenharmony_ci/** 33570af302Sopenharmony_ci * @tc.name : printf_0200 34570af302Sopenharmony_ci * @tc.desc : Verify the output data in the specified format (the format character is o) 35570af302Sopenharmony_ci * @tc.level : Level 0 36570af302Sopenharmony_ci */ 37570af302Sopenharmony_civoid printf_0200(void) 38570af302Sopenharmony_ci{ 39570af302Sopenharmony_ci int num = 6; 40570af302Sopenharmony_ci int result = printf("%o\n", num); 41570af302Sopenharmony_ci EXPECT_TRUE("printf_0200", result > 0); 42570af302Sopenharmony_ci} 43570af302Sopenharmony_ci 44570af302Sopenharmony_ci/** 45570af302Sopenharmony_ci * @tc.name : printf_0300 46570af302Sopenharmony_ci * @tc.desc : Verify the output data in the specified format (the format character is x,X) 47570af302Sopenharmony_ci * @tc.level : Level 0 48570af302Sopenharmony_ci */ 49570af302Sopenharmony_civoid printf_0300(void) 50570af302Sopenharmony_ci{ 51570af302Sopenharmony_ci int num = 6; 52570af302Sopenharmony_ci int result = printf("%x\n", num); 53570af302Sopenharmony_ci EXPECT_TRUE("printf_0300", result > 0); 54570af302Sopenharmony_ci 55570af302Sopenharmony_ci result = printf("%X\n", num); 56570af302Sopenharmony_ci EXPECT_TRUE("printf_0300", result > 0); 57570af302Sopenharmony_ci} 58570af302Sopenharmony_ci 59570af302Sopenharmony_ci/** 60570af302Sopenharmony_ci * @tc.name : printf_0400 61570af302Sopenharmony_ci * @tc.desc : Verify the output data in the specified format (the format character is u) 62570af302Sopenharmony_ci * @tc.level : Level 0 63570af302Sopenharmony_ci */ 64570af302Sopenharmony_civoid printf_0400(void) 65570af302Sopenharmony_ci{ 66570af302Sopenharmony_ci int num = 6; 67570af302Sopenharmony_ci int result = printf("%u\n", num); 68570af302Sopenharmony_ci EXPECT_TRUE("printf_0400", result > 0); 69570af302Sopenharmony_ci} 70570af302Sopenharmony_ci 71570af302Sopenharmony_ci/** 72570af302Sopenharmony_ci * @tc.name : printf_0500 73570af302Sopenharmony_ci * @tc.desc : Verify the output data in the specified format (the format character is f) 74570af302Sopenharmony_ci * @tc.level : Level 0 75570af302Sopenharmony_ci */ 76570af302Sopenharmony_civoid printf_0500(void) 77570af302Sopenharmony_ci{ 78570af302Sopenharmony_ci int num = 6; 79570af302Sopenharmony_ci int result = printf("%f\n", num); 80570af302Sopenharmony_ci EXPECT_TRUE("printf_0500", result > 0); 81570af302Sopenharmony_ci} 82570af302Sopenharmony_ci 83570af302Sopenharmony_ci/** 84570af302Sopenharmony_ci * @tc.name : printf_0600 85570af302Sopenharmony_ci * @tc.desc : Verify the output data in the specified format (the format character is e,E) 86570af302Sopenharmony_ci * @tc.level : Level 0 87570af302Sopenharmony_ci */ 88570af302Sopenharmony_civoid printf_0600(void) 89570af302Sopenharmony_ci{ 90570af302Sopenharmony_ci int num = 6; 91570af302Sopenharmony_ci int result = printf("%e\n", num); 92570af302Sopenharmony_ci EXPECT_TRUE("printf_0600", result > 0); 93570af302Sopenharmony_ci 94570af302Sopenharmony_ci result = printf("%E\n", num); 95570af302Sopenharmony_ci EXPECT_TRUE("printf_0600", result > 0); 96570af302Sopenharmony_ci} 97570af302Sopenharmony_ci 98570af302Sopenharmony_ci/** 99570af302Sopenharmony_ci * @tc.name : printf_0700 100570af302Sopenharmony_ci * @tc.desc : Verify the output data in the specified format (the format character is g,G) 101570af302Sopenharmony_ci * @tc.level : Level 0 102570af302Sopenharmony_ci */ 103570af302Sopenharmony_civoid printf_0700(void) 104570af302Sopenharmony_ci{ 105570af302Sopenharmony_ci int num = 6; 106570af302Sopenharmony_ci int result = printf("%g\n", num); 107570af302Sopenharmony_ci EXPECT_TRUE("printf_0700", result > 0); 108570af302Sopenharmony_ci 109570af302Sopenharmony_ci result = printf("%G\n", num); 110570af302Sopenharmony_ci EXPECT_TRUE("printf_0700", result > 0); 111570af302Sopenharmony_ci} 112570af302Sopenharmony_ci 113570af302Sopenharmony_ci/** 114570af302Sopenharmony_ci * @tc.name : printf_0800 115570af302Sopenharmony_ci * @tc.desc : Verify the output data in the specified format (the format character is c) 116570af302Sopenharmony_ci * @tc.level : Level 0 117570af302Sopenharmony_ci */ 118570af302Sopenharmony_civoid printf_0800(void) 119570af302Sopenharmony_ci{ 120570af302Sopenharmony_ci char ch = 'a'; 121570af302Sopenharmony_ci int result = printf("%c\n", ch); 122570af302Sopenharmony_ci EXPECT_TRUE("printf_0800", result > 0); 123570af302Sopenharmony_ci} 124570af302Sopenharmony_ci 125570af302Sopenharmony_ci/** 126570af302Sopenharmony_ci * @tc.name : printf_0900 127570af302Sopenharmony_ci * @tc.desc : Verify the output data in the specified format (the format character is s) 128570af302Sopenharmony_ci * @tc.level : Level 0 129570af302Sopenharmony_ci */ 130570af302Sopenharmony_civoid printf_0900(void) 131570af302Sopenharmony_ci{ 132570af302Sopenharmony_ci char num[] = "test"; 133570af302Sopenharmony_ci int result = printf("%s\n", num); 134570af302Sopenharmony_ci EXPECT_TRUE("printf_0900", result > 0); 135570af302Sopenharmony_ci} 136570af302Sopenharmony_ci 137570af302Sopenharmony_ciint main(int argc, char *argv[]) 138570af302Sopenharmony_ci{ 139570af302Sopenharmony_ci printf_0100(); 140570af302Sopenharmony_ci printf_0200(); 141570af302Sopenharmony_ci printf_0300(); 142570af302Sopenharmony_ci printf_0400(); 143570af302Sopenharmony_ci printf_0500(); 144570af302Sopenharmony_ci printf_0600(); 145570af302Sopenharmony_ci printf_0700(); 146570af302Sopenharmony_ci printf_0800(); 147570af302Sopenharmony_ci printf_0900(); 148570af302Sopenharmony_ci 149570af302Sopenharmony_ci return t_status; 150570af302Sopenharmony_ci}