Merge "Trivial tests for <inttypes.h>/<stdlib.h> *abs and *div functions." am: 60103831eb

am: 5398ead784

Change-Id: Ib91a5148aafe4a08a1e6f0462d2f02a1e107e6ce
This commit is contained in:
Elliott Hughes 2017-09-08 19:59:37 +00:00 committed by android-build-merger
commit c7ad49251e
2 changed files with 44 additions and 0 deletions

View file

@ -156,3 +156,32 @@ TEST(inttypes, wcstoumax_EINVAL) {
wcstoumax(L"123", NULL, 37);
ASSERT_EQ(EINVAL, errno);
}
TEST(inttypes, div) {
div_t r = div(-5, 3);
ASSERT_EQ(-1, r.quot);
ASSERT_EQ(-2, r.rem);
}
TEST(inttypes, ldiv) {
ldiv_t r = ldiv(-5, 3);
ASSERT_EQ(-1, r.quot);
ASSERT_EQ(-2, r.rem);
}
TEST(inttypes, lldiv) {
lldiv_t r = lldiv(-5, 3);
ASSERT_EQ(-1, r.quot);
ASSERT_EQ(-2, r.rem);
}
TEST(inttypes, imaxdiv) {
imaxdiv_t r = imaxdiv(-5, 3);
ASSERT_EQ(-1, r.quot);
ASSERT_EQ(-2, r.rem);
}
TEST(inttypes, imaxabs) {
ASSERT_EQ(INTMAX_MAX, imaxabs(-INTMAX_MAX));
ASSERT_EQ(INTMAX_MAX, imaxabs(INTMAX_MAX));
}

View file

@ -650,3 +650,18 @@ TEST(stdlib, strtoimax_smoke) {
TEST(stdlib, strtoumax_smoke) {
CheckStrToInt(strtoumax);
}
TEST(stdlib, abs) {
ASSERT_EQ(INT_MAX, abs(-INT_MAX));
ASSERT_EQ(INT_MAX, abs(INT_MAX));
}
TEST(stdlib, labs) {
ASSERT_EQ(LONG_MAX, labs(-LONG_MAX));
ASSERT_EQ(LONG_MAX, labs(LONG_MAX));
}
TEST(stdlib, llabs) {
ASSERT_EQ(LLONG_MAX, llabs(-LLONG_MAX));
ASSERT_EQ(LLONG_MAX, llabs(LLONG_MAX));
}