• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 <inttypes.h>
17 #include "functionalext.h"
18 
19 /**
20  * @tc.name      : imaxdiv_0100
21  * @tc.desc      : Verify imaxdiv process success when param num is positive integer, param den is positive integer
22  * @tc.level     : Level 0
23  */
imaxdiv_0100(void)24 void imaxdiv_0100(void)
25 {
26     intmax_t num = 4;
27     intmax_t den = 3;
28     imaxdiv_t ret = imaxdiv(num, den);
29     EXPECT_EQ("imaxdiv_0100", ret.quot, 1);
30     EXPECT_EQ("imaxdiv_0100", ret.rem, 1);
31 }
32 
33 /**
34  * @tc.name      : imaxdiv_0200
35  * @tc.desc      : Verify imaxdiv process success when param num is positive integer, param den is negative integer
36  * @tc.level     : Level 0
37  */
imaxdiv_0200(void)38 void imaxdiv_0200(void)
39 {
40     intmax_t num = 4;
41     intmax_t den = -3;
42     imaxdiv_t ret = imaxdiv(num, den);
43     EXPECT_EQ("imaxdiv_0200", ret.quot, -1);
44     EXPECT_EQ("imaxdiv_0200", ret.rem, 1);
45 }
46 
47 /**
48  * @tc.name      : imaxdiv_0300
49  * @tc.desc      : Verify imaxdiv process success when param num is negative integer, param den is positive integer
50  * @tc.level     : Level 0
51  */
imaxdiv_0300(void)52 void imaxdiv_0300(void)
53 {
54     intmax_t num = -4;
55     intmax_t den = 3;
56     imaxdiv_t ret = imaxdiv(num, den);
57     EXPECT_EQ("imaxdiv_0300", ret.quot, -1);
58     EXPECT_EQ("imaxdiv_0300", ret.rem, -1);
59 }
60 
61 /**
62  * @tc.name      : imaxdiv_0400
63  * @tc.desc      : Verify imaxdiv process success when param num is negative integer, param den is negative integer
64  * @tc.level     : Level 0
65  */
imaxdiv_0400(void)66 void imaxdiv_0400(void)
67 {
68     intmax_t num = -4;
69     intmax_t den = -3;
70     imaxdiv_t ret = imaxdiv(num, den);
71     EXPECT_EQ("imaxdiv_0400", ret.quot, 1);
72     EXPECT_EQ("imaxdiv_0400", ret.rem, -1);
73 }
74 
main(int argc,char * argv[])75 int main(int argc, char *argv[])
76 {
77     imaxdiv_0100();
78     imaxdiv_0200();
79     imaxdiv_0300();
80     imaxdiv_0400();
81     return t_status;
82 }
83