Skip to content

Commit 20245bb

Browse files
committed
[libc++][NFC] Format abs.pass.cpp test
I will modify the test in an upcoming PR. I'm formatting it now to avoid a bunch of whitespace changes in that PR.
1 parent 584cc37 commit 20245bb

File tree

1 file changed

+37
-43
lines changed

1 file changed

+37
-43
lines changed

libcxx/test/std/numerics/c.math/abs.pass.cpp

Lines changed: 37 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -14,65 +14,59 @@
1414

1515
#include "test_macros.h"
1616

17-
template<class T>
18-
struct correct_size_int
19-
{
20-
typedef typename std::conditional<sizeof(T) < sizeof(int), int, T>::type type;
17+
template <class T>
18+
struct correct_size_int {
19+
typedef typename std::conditional<sizeof(T) < sizeof(int), int, T>::type type;
2120
};
2221

2322
template <class Source, class Result>
24-
void test_abs()
25-
{
26-
Source neg_val = -5;
27-
Source pos_val = 5;
28-
Result res = 5;
23+
void test_abs() {
24+
Source neg_val = -5;
25+
Source pos_val = 5;
26+
Result res = 5;
2927

30-
ASSERT_SAME_TYPE(decltype(std::abs(neg_val)), Result);
28+
ASSERT_SAME_TYPE(decltype(std::abs(neg_val)), Result);
3129

32-
assert(std::abs(neg_val) == res);
33-
assert(std::abs(pos_val) == res);
30+
assert(std::abs(neg_val) == res);
31+
assert(std::abs(pos_val) == res);
3432
}
3533

36-
void test_big()
37-
{
38-
long long int big_value = std::numeric_limits<long long int>::max(); // a value too big for ints to store
39-
long long int negative_big_value = -big_value;
40-
assert(std::abs(negative_big_value) == big_value); // make sure it doesn't get casted to a smaller type
34+
void test_big() {
35+
long long int big_value = std::numeric_limits<long long int>::max(); // a value too big for ints to store
36+
long long int negative_big_value = -big_value;
37+
assert(std::abs(negative_big_value) == big_value); // make sure it doesn't get casted to a smaller type
4138
}
4239

4340
// The following is helpful to keep in mind:
4441
// 1byte == char <= short <= int <= long <= long long
4542

46-
int main(int, char**)
47-
{
48-
// On some systems char is unsigned.
49-
// If that is the case, we should just test signed char twice.
50-
typedef std::conditional<
51-
std::is_signed<char>::value, char, signed char
52-
>::type SignedChar;
43+
int main(int, char**) {
44+
// On some systems char is unsigned.
45+
// If that is the case, we should just test signed char twice.
46+
typedef std::conditional< std::is_signed<char>::value, char, signed char >::type SignedChar;
5347

54-
// All types less than or equal to and not greater than int are promoted to int.
55-
test_abs<short int, int>();
56-
test_abs<SignedChar, int>();
57-
test_abs<signed char, int>();
48+
// All types less than or equal to and not greater than int are promoted to int.
49+
test_abs<short int, int>();
50+
test_abs<SignedChar, int>();
51+
test_abs<signed char, int>();
5852

59-
// These three calls have specific overloads:
60-
test_abs<int, int>();
61-
test_abs<long int, long int>();
62-
test_abs<long long int, long long int>();
53+
// These three calls have specific overloads:
54+
test_abs<int, int>();
55+
test_abs<long int, long int>();
56+
test_abs<long long int, long long int>();
6357

64-
// Here there is no guarantee that int is larger than int8_t so we
65-
// use a helper type trait to conditional test against int.
66-
test_abs<std::int8_t, correct_size_int<std::int8_t>::type>();
67-
test_abs<std::int16_t, correct_size_int<std::int16_t>::type>();
68-
test_abs<std::int32_t, correct_size_int<std::int32_t>::type>();
69-
test_abs<std::int64_t, correct_size_int<std::int64_t>::type>();
58+
// Here there is no guarantee that int is larger than int8_t so we
59+
// use a helper type trait to conditional test against int.
60+
test_abs<std::int8_t, correct_size_int<std::int8_t>::type>();
61+
test_abs<std::int16_t, correct_size_int<std::int16_t>::type>();
62+
test_abs<std::int32_t, correct_size_int<std::int32_t>::type>();
63+
test_abs<std::int64_t, correct_size_int<std::int64_t>::type>();
7064

71-
test_abs<long double, long double>();
72-
test_abs<double, double>();
73-
test_abs<float, float>();
65+
test_abs<long double, long double>();
66+
test_abs<double, double>();
67+
test_abs<float, float>();
7468

75-
test_big();
69+
test_big();
7670

77-
return 0;
71+
return 0;
7872
}

0 commit comments

Comments
 (0)