• 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 <stdlib.h>
17 #include "functionalext.h"
18 
19 #define TEST_LDIV_P_SEVENT 7
20 #define TEST_LDIV_P_FOUR 4
21 #define TEST_LDIV_P_THREE 3
22 #define TEST_LDIV_N_SEVENT (-7)
23 #define TEST_LDIV_N_FOUR (-4)
24 #define TEST_LDIV_N_THREE (-3)
25 
26 /**
27  * @tc.name      : lldiv_0100
28  * @tc.desc      : Divide two long long integers, return the quotient and remainder
29  * @tc.level     : Level 0
30  */
lldiv_0100(void)31 void lldiv_0100(void)
32 {
33     lldiv_t ret = lldiv(TEST_LDIV_P_SEVENT, TEST_LDIV_P_FOUR);
34     EXPECT_EQ("lldiv_0100", ret.quot, 1);
35     EXPECT_EQ("lldiv_0100", ret.rem, TEST_LDIV_P_THREE);
36 
37     ret = lldiv(TEST_LDIV_P_SEVENT, TEST_LDIV_N_FOUR);
38     EXPECT_EQ("lldiv_0100", ret.quot, ERREXPECT);
39     EXPECT_EQ("lldiv_0100", ret.rem, TEST_LDIV_P_THREE);
40 
41     ret = lldiv(TEST_LDIV_N_SEVENT, TEST_LDIV_P_FOUR);
42     EXPECT_EQ("lldiv_0100", ret.quot, ERREXPECT);
43     EXPECT_EQ("lldiv_0100", ret.rem, TEST_LDIV_N_THREE);
44 
45     ret = lldiv(TEST_LDIV_N_SEVENT, TEST_LDIV_N_FOUR);
46     EXPECT_EQ("lldiv_0100", ret.quot, 1);
47     EXPECT_EQ("lldiv_0100", ret.rem, TEST_LDIV_N_THREE);
48 }
49 
main(void)50 int main(void)
51 {
52     lldiv_0100();
53     return t_status;
54 }
55