diff --git a/test/std/numerics/c.math/abs.pass.cpp b/test/std/numerics/c.math/abs.pass.cpp index 33e0c7d64..bdca9a616 100644 --- a/test/std/numerics/c.math/abs.pass.cpp +++ b/test/std/numerics/c.math/abs.pass.cpp @@ -16,7 +16,7 @@ template struct correct_size_int { - typedef typename std::conditional::type type; + typedef typename std::conditional::type type; }; template @@ -39,6 +39,9 @@ void test_big() assert(std::abs(negative_big_value) == big_value); // make sure it doesnt get casted to a smaller type } +// The following is helpful to keep in mind: +// 1byte == char <= short <= int <= long <= long long + int main(int, char**) { // On some systems char is unsigned. @@ -47,14 +50,18 @@ int main(int, char**) std::is_signed::value, char, signed char >::type SignedChar; - test_abs::type>(); - test_abs::type>(); - test_abs::type>(); + // All types less than or equal to and not greater than int are promoted to int. + test_abs(); + test_abs(); + test_abs(); - test_abs::type>(); - test_abs::type>(); - test_abs::type>(); + // These three calls have specific overloads: + test_abs(); + test_abs(); + test_abs(); + // Here there is no guarantee that int is larger than int8_t so we + // use a helper type trait to conditional test against int. test_abs::type>(); test_abs::type>(); test_abs::type>();