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 "functionalext.h"
18
19 typedef void (*TEST_FUN)();
20 const int32_t COUNT_ZERO = 0;
21 const int32_t COUNT_ONE = 1;
22
23 /**
24 * @tc.name : __signbit_0100
25 * @tc.desc : When the float value is 0, test the return value of the function
26 * @tc.level : Level 0
27 */
__signbit_0100null28 void __signbit_0100()
29 {
30 double x = 0;
31 int result = __signbit(x);
32 EXPECT_EQ("_signbit_0100", result, COUNT_ZERO);
33 }
34
35 /**
36 * @tc.name : __signbit_0200
37 * @tc.desc : When the float value is 3.14, test the return value of the function
38 * @tc.level : Level 0
39 */
__signbit_0200null40 void __signbit_0200()
41 {
42 double x = 3.14;
43 int result = __signbit(x);
44 EXPECT_EQ("_signbit_0200", result, COUNT_ZERO);
45 }
46
47 /**
48 * @tc.name : __signbit_0300
49 * @tc.desc : When the float value is -3.14, test the return value of the function
50 * @tc.level : Level 0
51 */
__signbit_0300null52 void __signbit_0300()
53 {
54 double x = -3.14;
55 int result = __signbit(x);
56 EXPECT_EQ("_signbit_0300", result, COUNT_ONE);
57 }
58
59 TEST_FUN G_Fun_Array[] = {
60 __signbit_0100,
61 __signbit_0200,
62 __signbit_0300,
63 };
64
main(int argc, char *argv[])65 int main(int argc, char *argv[])
66 {
67 int num = sizeof(G_Fun_Array) / sizeof(TEST_FUN);
68 for (int pos = 0; pos < num; ++pos) {
69 G_Fun_Array[pos]();
70 }
71
72 return t_status;
73 }