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 <float.h>
17#include <math.h>
18#include <stdint.h>
19#include "functionalext.h"
20
21/**
22 * @tc.name      : finitef_0100
23 * @tc.desc      : Validate that the input parameter is a finite value (parameter is 0.0).
24 * @tc.level     : Level 0
25 */
26void finitef_0100(void)
27{
28    int ret = finitef(0.0);
29    EXPECT_EQ("finitef_0100", ret, 1);
30}
31
32/**
33 * @tc.name      : finitef_0200
34 * @tc.desc      : Validate that the input parameter is a finite value (parameter is DBL_MIN/2).
35 * @tc.level     : Level 0
36 */
37void finitef_0200(void)
38{
39    int ret = finitef(DBL_MIN / 2);
40    EXPECT_EQ("finitef_0100", ret, 1);
41}
42
43/**
44 * @tc.name      : finitef_0300
45 * @tc.desc      : Verify that the input parameter is not a finite value (parameter is NAN).
46 * @tc.level     : Level 2
47 */
48void finitef_0300(void)
49{
50    int ret = finitef(NAN);
51    EXPECT_EQ("finitef_0100", ret, 0);
52}
53
54/**
55 * @tc.name      : finitef_0400
56 * @tc.desc      : Verify that the input parameter is not a finite value (parameter is INFINITY).
57 * @tc.level     : Level 2
58 */
59void finitef_0400(void)
60{
61    int ret = finitef(INFINITY);
62    EXPECT_EQ("finitef_0100", ret, 0);
63}
64
65/**
66 * @tc.name      : finitef_0500
67 * @tc.desc      : Verify that the input parameter is not a finite value (parameter is sqrt(-1.0)).
68 * @tc.level     : Level 2
69 */
70void finitef_0500(void)
71{
72    int ret = finitef(sqrt(-1.0));
73    EXPECT_EQ("finitef_0100", ret, 0);
74}
75
76/**
77 * @tc.name      : finitef_0600
78 * @tc.desc      : Verify that the input parameter is not a finite value (exp(800)).
79 * @tc.level     : Level 2
80 */
81void finitef_0600(void)
82{
83    int ret = finitef(exp(800));
84    EXPECT_EQ("finitef_0100", ret, 0);
85}
86
87int main(int argc, char *argv[])
88{
89    finitef_0100();
90    finitef_0200();
91    finitef_0300();
92    finitef_0400();
93    finitef_0500();
94    finitef_0600();
95    return t_status;
96}
97