diff options
author | Elliott Hughes <enh@google.com> | 2017-09-07 16:42:13 -0700 |
---|---|---|
committer | Elliott Hughes <enh@google.com> | 2017-09-07 17:01:37 -0700 |
commit | 00d8a8b77922da018d71984ff90fd8877eaafd09 (patch) | |
tree | 08b369b64dbb5f879c13c9cb881cef9d3111ca28 /tests/stdlib_test.cpp | |
parent | 04503da174b5e51ba9035fb79521a6a2af17c111 (diff) |
Trivial tests for <inttypes.h>/<stdlib.h> *abs and *div functions.
Because I want something to copy & paste into the NDK support library test
that's slightly better than taking the address of the function...
Bug: https://github.com/android-ndk/ndk/issues/502
Test: ran tests
Change-Id: If43089d16691d6a4dcf5d972450b14ed85bbca81
Diffstat (limited to 'tests/stdlib_test.cpp')
-rw-r--r-- | tests/stdlib_test.cpp | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/tests/stdlib_test.cpp b/tests/stdlib_test.cpp index 7d2dc20ce..27495d88f 100644 --- a/tests/stdlib_test.cpp +++ b/tests/stdlib_test.cpp @@ -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)); +} |