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 <stdlib.h> 17570af302Sopenharmony_ci#include <ctype.h> 18570af302Sopenharmony_ci#include "functionalext.h" 19570af302Sopenharmony_ci 20570af302Sopenharmony_cilong long int result = 123456789012345; 21570af302Sopenharmony_ciint resultA = 123456; 22570af302Sopenharmony_ciint resultC = -123456; 23570af302Sopenharmony_ciint resultD = 1234567890; 24570af302Sopenharmony_ciint resultE = 1234; 25570af302Sopenharmony_ciint successfully = 0; 26570af302Sopenharmony_ciint resultG = 12; 27570af302Sopenharmony_ci 28570af302Sopenharmony_ci/** 29570af302Sopenharmony_ci * @tc.name : atoll_0100 30570af302Sopenharmony_ci * @tc.desc : Verify that the string can be converted to an integer (parameter is 123456789012345) 31570af302Sopenharmony_ci * @tc.level : Level 0 32570af302Sopenharmony_ci */ 33570af302Sopenharmony_civoid atoll_0100(void) 34570af302Sopenharmony_ci{ 35570af302Sopenharmony_ci long long int num; 36570af302Sopenharmony_ci char str[] = "123456789012345"; 37570af302Sopenharmony_ci num = atoll(str); 38570af302Sopenharmony_ci EXPECT_EQ("atoll_0100", num, result); 39570af302Sopenharmony_ci} 40570af302Sopenharmony_ci 41570af302Sopenharmony_ci/** 42570af302Sopenharmony_ci * @tc.name : atoll_0200 43570af302Sopenharmony_ci * @tc.desc : Verify that the string can be converted to an integer (parameter is 000123456) 44570af302Sopenharmony_ci * @tc.level : Level 0 45570af302Sopenharmony_ci */ 46570af302Sopenharmony_civoid atoll_0200(void) 47570af302Sopenharmony_ci{ 48570af302Sopenharmony_ci long long int num; 49570af302Sopenharmony_ci char str[] = "000123456"; 50570af302Sopenharmony_ci num = atoll(str); 51570af302Sopenharmony_ci EXPECT_EQ("atoll_0200", num, resultA); 52570af302Sopenharmony_ci} 53570af302Sopenharmony_ci 54570af302Sopenharmony_ci/** 55570af302Sopenharmony_ci * @tc.name : atoll_0300 56570af302Sopenharmony_ci * @tc.desc : Verify that the string can be converted to an integer (parameter is 123456) 57570af302Sopenharmony_ci * @tc.level : Level 1 58570af302Sopenharmony_ci */ 59570af302Sopenharmony_civoid atoll_0300(void) 60570af302Sopenharmony_ci{ 61570af302Sopenharmony_ci long long int num; 62570af302Sopenharmony_ci char str[] = " 123456"; 63570af302Sopenharmony_ci num = atoll(str); 64570af302Sopenharmony_ci EXPECT_EQ("atoll_0300", num, resultA); 65570af302Sopenharmony_ci} 66570af302Sopenharmony_ci 67570af302Sopenharmony_ci/** 68570af302Sopenharmony_ci * @tc.name : atoll_0400 69570af302Sopenharmony_ci * @tc.desc : Verify that the string can be converted to an integer (parameter is 123 456) 70570af302Sopenharmony_ci * @tc.level : Level 1 71570af302Sopenharmony_ci */ 72570af302Sopenharmony_civoid atoll_0400(void) 73570af302Sopenharmony_ci{ 74570af302Sopenharmony_ci long long int num; 75570af302Sopenharmony_ci char str[] = "123 456"; 76570af302Sopenharmony_ci num = atoll(str); 77570af302Sopenharmony_ci EXPECT_EQ("atoll_0400", num, 123); 78570af302Sopenharmony_ci} 79570af302Sopenharmony_ci 80570af302Sopenharmony_ci/** 81570af302Sopenharmony_ci * @tc.name : atoll_0500 82570af302Sopenharmony_ci * @tc.desc : Verify that the string can be converted to an integer (parameter is -123456) 83570af302Sopenharmony_ci * @tc.level : Level 1 84570af302Sopenharmony_ci */ 85570af302Sopenharmony_civoid atoll_0500(void) 86570af302Sopenharmony_ci{ 87570af302Sopenharmony_ci long long int num; 88570af302Sopenharmony_ci char str[] = "-123456"; 89570af302Sopenharmony_ci num = atoll(str); 90570af302Sopenharmony_ci EXPECT_EQ("atoll_0500", num, resultC); 91570af302Sopenharmony_ci} 92570af302Sopenharmony_ci 93570af302Sopenharmony_ci/** 94570af302Sopenharmony_ci * @tc.name : atoll_0600 95570af302Sopenharmony_ci * @tc.desc : Verify that the string can be converted to an integer (parameter is 1234567890-56) 96570af302Sopenharmony_ci * @tc.level : Level 1 97570af302Sopenharmony_ci */ 98570af302Sopenharmony_civoid atoll_0600(void) 99570af302Sopenharmony_ci{ 100570af302Sopenharmony_ci long long int num; 101570af302Sopenharmony_ci char str[] = "1234567890-56"; 102570af302Sopenharmony_ci num = atoll(str); 103570af302Sopenharmony_ci EXPECT_EQ("atoll_0600", num, resultD); 104570af302Sopenharmony_ci} 105570af302Sopenharmony_ci 106570af302Sopenharmony_ci/** 107570af302Sopenharmony_ci * @tc.name : atoll_0700 108570af302Sopenharmony_ci * @tc.desc : Verify that the string can be converted to an integer (parameter is +123456) 109570af302Sopenharmony_ci * @tc.level : Level 1 110570af302Sopenharmony_ci */ 111570af302Sopenharmony_civoid atoll_0700(void) 112570af302Sopenharmony_ci{ 113570af302Sopenharmony_ci long long int num; 114570af302Sopenharmony_ci char str[] = "+123456"; 115570af302Sopenharmony_ci num = atoll(str); 116570af302Sopenharmony_ci EXPECT_EQ("atoll_0700", num, resultA); 117570af302Sopenharmony_ci} 118570af302Sopenharmony_ci 119570af302Sopenharmony_ci/** 120570af302Sopenharmony_ci * @tc.name : atoll_0800 121570af302Sopenharmony_ci * @tc.desc : Verify that the string can be converted to an integer (parameter is 1234+56) 122570af302Sopenharmony_ci * @tc.level : Level 1 123570af302Sopenharmony_ci */ 124570af302Sopenharmony_civoid atoll_0800(void) 125570af302Sopenharmony_ci{ 126570af302Sopenharmony_ci long long int num; 127570af302Sopenharmony_ci char str[] = "1234+56"; 128570af302Sopenharmony_ci num = atoll(str); 129570af302Sopenharmony_ci EXPECT_EQ("atoll_0800", num, resultE); 130570af302Sopenharmony_ci} 131570af302Sopenharmony_ci 132570af302Sopenharmony_ci/** 133570af302Sopenharmony_ci * @tc.name : atoll_0900 134570af302Sopenharmony_ci * @tc.desc : Verify that cannot convert string to integer (parameter is a123456) 135570af302Sopenharmony_ci * @tc.level : Level 2 136570af302Sopenharmony_ci */ 137570af302Sopenharmony_civoid atoll_0900(void) 138570af302Sopenharmony_ci{ 139570af302Sopenharmony_ci long long int num; 140570af302Sopenharmony_ci char str[] = "a123456"; 141570af302Sopenharmony_ci num = atoll(str); 142570af302Sopenharmony_ci EXPECT_EQ("atoll_0900", num, successfully); 143570af302Sopenharmony_ci} 144570af302Sopenharmony_ci 145570af302Sopenharmony_ci/** 146570af302Sopenharmony_ci * @tc.name : atoll_1000 147570af302Sopenharmony_ci * @tc.desc : Verify that cannot convert string to integer (parameter is 12b3456789012345) 148570af302Sopenharmony_ci * @tc.level : Level 2 149570af302Sopenharmony_ci */ 150570af302Sopenharmony_civoid atoll_1000(void) 151570af302Sopenharmony_ci{ 152570af302Sopenharmony_ci long long int num; 153570af302Sopenharmony_ci char str[] = "12b3456789012345"; 154570af302Sopenharmony_ci num = atoll(str); 155570af302Sopenharmony_ci EXPECT_EQ("atoll_1000", num, resultG); 156570af302Sopenharmony_ci} 157570af302Sopenharmony_ci 158570af302Sopenharmony_ci/** 159570af302Sopenharmony_ci * @tc.name : atoll_1100 160570af302Sopenharmony_ci * @tc.desc : Verify that cannot convert string to integer (parameter is NULL) 161570af302Sopenharmony_ci * @tc.level : Level 2 162570af302Sopenharmony_ci */ 163570af302Sopenharmony_civoid atoll_1100(void) 164570af302Sopenharmony_ci{ 165570af302Sopenharmony_ci long long int num; 166570af302Sopenharmony_ci char str[] = "NULL"; 167570af302Sopenharmony_ci num = atoll(str); 168570af302Sopenharmony_ci EXPECT_EQ("atoll_1100", num, successfully); 169570af302Sopenharmony_ci} 170570af302Sopenharmony_ci 171570af302Sopenharmony_ci/** 172570af302Sopenharmony_ci * @tc.name : atoll_1200 173570af302Sopenharmony_ci * @tc.desc : Verify that cannot convert string to integer (parameter is “”) 174570af302Sopenharmony_ci * @tc.level : Level 2 175570af302Sopenharmony_ci */ 176570af302Sopenharmony_civoid atoll_1200(void) 177570af302Sopenharmony_ci{ 178570af302Sopenharmony_ci long long int num; 179570af302Sopenharmony_ci char str[] = ""; 180570af302Sopenharmony_ci num = atoll(str); 181570af302Sopenharmony_ci EXPECT_EQ("atoll_1200", num, successfully); 182570af302Sopenharmony_ci} 183570af302Sopenharmony_ci 184570af302Sopenharmony_ciint main(int argc, char *argv[]) 185570af302Sopenharmony_ci{ 186570af302Sopenharmony_ci atoll_0100(); 187570af302Sopenharmony_ci atoll_0200(); 188570af302Sopenharmony_ci atoll_0300(); 189570af302Sopenharmony_ci atoll_0400(); 190570af302Sopenharmony_ci atoll_0500(); 191570af302Sopenharmony_ci atoll_0600(); 192570af302Sopenharmony_ci atoll_0700(); 193570af302Sopenharmony_ci atoll_0800(); 194570af302Sopenharmony_ci atoll_0900(); 195570af302Sopenharmony_ci atoll_1000(); 196570af302Sopenharmony_ci atoll_1100(); 197570af302Sopenharmony_ci atoll_1200(); 198570af302Sopenharmony_ci 199570af302Sopenharmony_ci return t_status; 200570af302Sopenharmony_ci}