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 : ldiv_0100 28 * @tc.desc : Divide two long integers, return the quotient and remainder 29 * @tc.level : Level 0 30 */ 31void ldiv_0100(void) 32{ 33 ldiv_t ret; 34 ret = ldiv(TEST_LDIV_P_SEVENT, TEST_LDIV_P_FOUR); 35 EXPECT_EQ("ldiv_0100", ret.quot, 1); 36 EXPECT_EQ("ldiv_0100", ret.rem, TEST_LDIV_P_THREE); 37 38 ret = ldiv(TEST_LDIV_P_SEVENT, TEST_LDIV_N_FOUR); 39 EXPECT_EQ("ldiv_0100", ret.quot, -1); 40 EXPECT_EQ("ldiv_0100", ret.rem, TEST_LDIV_P_THREE); 41 42 ret = ldiv(TEST_LDIV_N_SEVENT, TEST_LDIV_P_FOUR); 43 EXPECT_EQ("ldiv_0100", ret.quot, -1); 44 EXPECT_EQ("ldiv_0100", ret.rem, TEST_LDIV_N_THREE); 45 46 ret = ldiv(TEST_LDIV_N_SEVENT, TEST_LDIV_N_FOUR); 47 EXPECT_EQ("ldiv_0100", ret.quot, 1); 48 EXPECT_EQ("ldiv_0100", ret.rem, TEST_LDIV_N_THREE); 49} 50 51int main(void) 52{ 53 ldiv_0100(); 54 return t_status; 55}