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 <math.h>
17 #include <stdlib.h>
18 #include "functionalext.h"
19
20 /**
21 * @tc.name : pow10_0100
22 * @tc.desc : Validate that the result is 1-1e+15 when the input parameter is 0-15.
23 * @tc.level : Level 0
24 */
pow10_0100(void)25 void pow10_0100(void)
26 {
27 double ret0 = pow10(0);
28 EXPECT_EQ("pow10_0100", ret0, 1.0);
29 double ret1 = pow10(1);
30 EXPECT_EQ("pow10_0100", ret1, 10.0);
31 double ret2 = pow10(2);
32 EXPECT_EQ("pow10_0100", ret2, 100.0);
33 double ret3 = pow10(3);
34 EXPECT_EQ("pow10_0100", ret3, 1e+03);
35 double ret4 = pow10(4);
36 EXPECT_EQ("pow10_0100", ret4, 1e+04);
37 double ret5 = pow10(5);
38 EXPECT_EQ("pow10_0100", ret5, 1e+05);
39 double ret6 = pow10(6);
40 EXPECT_EQ("pow10_0100", ret6, 1e+06);
41 double ret7 = pow10(7);
42 EXPECT_EQ("pow10_0100", ret7, 1e+07);
43 double ret8 = pow10(8);
44 EXPECT_EQ("pow10_0100", ret8, 1e+08);
45 double ret9 = pow10(9);
46 EXPECT_EQ("pow10_0100", ret9, 1e+09);
47 double ret10 = pow10(10);
48 EXPECT_EQ("pow10_0100", ret10, 1e+10);
49 double ret11 = pow10(11);
50 EXPECT_EQ("pow10_0100", ret11, 1e+11);
51 double ret12 = pow10(12);
52 EXPECT_EQ("pow10_0100", ret12, 1e+12);
53 double ret13 = pow10(13);
54 EXPECT_EQ("pow10_0100", ret13, 1e+13);
55 double ret14 = pow10(14);
56 EXPECT_EQ("pow10_0100", ret14, 1e+14);
57 double ret15 = pow10(15);
58 EXPECT_EQ("pow10_0100", ret15, 1e+15);
59 }
60
61 /**
62 * @tc.name : pow10_0200
63 * @tc.desc : Validate that the result is 1e+16 when the input parameter is 16.
64 * @tc.level : Level 0
65 */
pow10_0200(void)66 void pow10_0200(void)
67 {
68 double ret = pow10(16);
69 EXPECT_EQ("pow10_0200", ret, 1e+16);
70 }
71
72 /**
73 * @tc.name : pow10_0300
74 * @tc.desc : Validate that the result is 0.1 when the input parameter is -1.
75 * @tc.level : Level 0
76 */
pow10_0300(void)77 void pow10_0300(void)
78 {
79 double ret = pow10(-1);
80 EXPECT_EQ("pow10_0300", ret, 0.1);
81 }
82
83 /**
84 * @tc.name : pow10_0400
85 * @tc.desc : Validate that the result is 1e+100 when the input parameter is 100.
86 * @tc.level : Level 0
87 */
pow10_0400(void)88 void pow10_0400(void)
89 {
90 double ret = pow10(100);
91 EXPECT_EQ("pow10_0400", ret, 1e+100);
92 }
93
94 /**
95 * @tc.name : pow10_0500
96 * @tc.desc : Validate that the result is 1e-100 when the input parameter is -100.
97 * @tc.level : Level 0
98 */
pow10_0500(void)99 void pow10_0500(void)
100 {
101 double ret = pow10(-100);
102 EXPECT_EQ("pow10_0500", ret, 1e-100);
103 }
104
main(int argc,char * argv[])105 int main(int argc, char *argv[])
106 {
107 pow10_0100();
108 pow10_0200();
109 pow10_0300();
110 pow10_0400();
111 pow10_0500();
112 return t_status;
113 }