-
Notifications
You must be signed in to change notification settings - Fork 15.2k
[libcxx] adds tests for complex<float> and complex<long double>
#122809
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
cjdb
wants to merge
1
commit into
llvm:main
Choose a base branch
from
cjdb:complex-tests
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This increases test coverage for `std::complex`, and improves verifying improvements to `complex` to non-double types.
Member
|
@llvm/pr-subscribers-libcxx Author: Christopher Di Bella (cjdb) ChangesThis increases test coverage for Patch is 133.42 KiB, truncated to 20.00 KiB below, full version: https://github.com/llvm/llvm-project/pull/122809.diff 28 Files Affected:
diff --git a/libcxx/test/std/numerics/complex.number/cases.h b/libcxx/test/std/numerics/complex.number/cases.h
index b360e1423ff576..69059bdebdcfed 100644
--- a/libcxx/test/std/numerics/complex.number/cases.h
+++ b/libcxx/test/std/numerics/complex.number/cases.h
@@ -15,181 +15,182 @@
#include <cassert>
#include <complex>
+#include <limits>
#include <type_traits>
#include "test_macros.h"
-TEST_CONSTEXPR_CXX20 const std::complex<double> testcases[] =
-{
- std::complex<double>( 1.e-6, 1.e-6),
- std::complex<double>(-1.e-6, 1.e-6),
- std::complex<double>(-1.e-6, -1.e-6),
- std::complex<double>( 1.e-6, -1.e-6),
+template <class T>
+TEST_CONSTEXPR_CXX20 const std::complex<T> testcases[] = {
+ std::complex<T>(+1.e-6, +1.e-6),
+ std::complex<T>(-1.e-6, +1.e-6),
+ std::complex<T>(-1.e-6, -1.e-6),
+ std::complex<T>(+1.e-6, -1.e-6),
- std::complex<double>( 1.e+6, 1.e-6),
- std::complex<double>(-1.e+6, 1.e-6),
- std::complex<double>(-1.e+6, -1.e-6),
- std::complex<double>( 1.e+6, -1.e-6),
+ std::complex<T>(+1.e+6, +1.e-6),
+ std::complex<T>(-1.e+6, +1.e-6),
+ std::complex<T>(-1.e+6, -1.e-6),
+ std::complex<T>(+1.e+6, -1.e-6),
- std::complex<double>( 1.e-6, 1.e+6),
- std::complex<double>(-1.e-6, 1.e+6),
- std::complex<double>(-1.e-6, -1.e+6),
- std::complex<double>( 1.e-6, -1.e+6),
+ std::complex<T>(+1.e-6, +1.e+6),
+ std::complex<T>(-1.e-6, +1.e+6),
+ std::complex<T>(-1.e-6, -1.e+6),
+ std::complex<T>(+1.e-6, -1.e+6),
- std::complex<double>( 1.e+6, 1.e+6),
- std::complex<double>(-1.e+6, 1.e+6),
- std::complex<double>(-1.e+6, -1.e+6),
- std::complex<double>( 1.e+6, -1.e+6),
+ std::complex<T>(+1.e+6, +1.e+6),
+ std::complex<T>(-1.e+6, +1.e+6),
+ std::complex<T>(-1.e+6, -1.e+6),
+ std::complex<T>(+1.e+6, -1.e+6),
- std::complex<double>(-0, -1.e-6),
- std::complex<double>(-0, 1.e-6),
- std::complex<double>(-0, 1.e+6),
- std::complex<double>(-0, -1.e+6),
- std::complex<double>( 0, -1.e-6),
- std::complex<double>( 0, 1.e-6),
- std::complex<double>( 0, 1.e+6),
- std::complex<double>( 0, -1.e+6),
+ std::complex<T>(-0.0, -1.e-6),
+ std::complex<T>(-0.0, +1.e-6),
+ std::complex<T>(-0.0, +1.e+6),
+ std::complex<T>(-0.0, -1.e+6),
+ std::complex<T>(+0.0, -1.e-6),
+ std::complex<T>(+0.0, +1.e-6),
+ std::complex<T>(+0.0, +1.e+6),
+ std::complex<T>(+0.0, -1.e+6),
- std::complex<double>(-1.e-6, -0),
- std::complex<double>( 1.e-6, -0),
- std::complex<double>( 1.e+6, -0),
- std::complex<double>(-1.e+6, -0),
- std::complex<double>(-1.e-6, 0),
- std::complex<double>( 1.e-6, 0),
- std::complex<double>( 1.e+6, 0),
- std::complex<double>(-1.e+6, 0),
+ std::complex<T>(-1.e-6, -0.0),
+ std::complex<T>(+1.e-6, -0.0),
+ std::complex<T>(+1.e+6, -0.0),
+ std::complex<T>(-1.e+6, -0.0),
+ std::complex<T>(-1.e-6, +0.0),
+ std::complex<T>(+1.e-6, +0.0),
+ std::complex<T>(+1.e+6, +0.0),
+ std::complex<T>(-1.e+6, +0.0),
- std::complex<double>(std::numeric_limits<double>::quiet_NaN(), std::numeric_limits<double>::quiet_NaN()),
- std::complex<double>(-std::numeric_limits<double>::infinity(), std::numeric_limits<double>::quiet_NaN()),
- std::complex<double>(-2, std::numeric_limits<double>::quiet_NaN()),
- std::complex<double>(-1, std::numeric_limits<double>::quiet_NaN()),
- std::complex<double>(-0.5, std::numeric_limits<double>::quiet_NaN()),
- std::complex<double>(-0., std::numeric_limits<double>::quiet_NaN()),
- std::complex<double>(+0., std::numeric_limits<double>::quiet_NaN()),
- std::complex<double>(0.5, std::numeric_limits<double>::quiet_NaN()),
- std::complex<double>(1, std::numeric_limits<double>::quiet_NaN()),
- std::complex<double>(2, std::numeric_limits<double>::quiet_NaN()),
- std::complex<double>(std::numeric_limits<double>::infinity(), std::numeric_limits<double>::quiet_NaN()),
+ std::complex<T>(std::numeric_limits<T>::quiet_NaN(), std::numeric_limits<T>::quiet_NaN()),
+ std::complex<T>(-std::numeric_limits<T>::infinity(), std::numeric_limits<T>::quiet_NaN()),
+ std::complex<T>(-2, std::numeric_limits<T>::quiet_NaN()),
+ std::complex<T>(-1, std::numeric_limits<T>::quiet_NaN()),
+ std::complex<T>(-0.5, std::numeric_limits<T>::quiet_NaN()),
+ std::complex<T>(-0., std::numeric_limits<T>::quiet_NaN()),
+ std::complex<T>(+0., std::numeric_limits<T>::quiet_NaN()),
+ std::complex<T>(0.5, std::numeric_limits<T>::quiet_NaN()),
+ std::complex<T>(1, std::numeric_limits<T>::quiet_NaN()),
+ std::complex<T>(2, std::numeric_limits<T>::quiet_NaN()),
+ std::complex<T>(std::numeric_limits<T>::infinity(), std::numeric_limits<T>::quiet_NaN()),
- std::complex<double>(std::numeric_limits<double>::quiet_NaN(), -std::numeric_limits<double>::infinity()),
- std::complex<double>(-std::numeric_limits<double>::infinity(), -std::numeric_limits<double>::infinity()),
- std::complex<double>(-2, -std::numeric_limits<double>::infinity()),
- std::complex<double>(-1, -std::numeric_limits<double>::infinity()),
- std::complex<double>(-0.5, -std::numeric_limits<double>::infinity()),
- std::complex<double>(-0., -std::numeric_limits<double>::infinity()),
- std::complex<double>(+0., -std::numeric_limits<double>::infinity()),
- std::complex<double>(0.5, -std::numeric_limits<double>::infinity()),
- std::complex<double>(1, -std::numeric_limits<double>::infinity()),
- std::complex<double>(2, -std::numeric_limits<double>::infinity()),
- std::complex<double>(std::numeric_limits<double>::infinity(), -std::numeric_limits<double>::infinity()),
+ std::complex<T>(std::numeric_limits<T>::quiet_NaN(), -std::numeric_limits<T>::infinity()),
+ std::complex<T>(-std::numeric_limits<T>::infinity(), -std::numeric_limits<T>::infinity()),
+ std::complex<T>(-2, -std::numeric_limits<T>::infinity()),
+ std::complex<T>(-1, -std::numeric_limits<T>::infinity()),
+ std::complex<T>(-0.5, -std::numeric_limits<T>::infinity()),
+ std::complex<T>(-0., -std::numeric_limits<T>::infinity()),
+ std::complex<T>(+0., -std::numeric_limits<T>::infinity()),
+ std::complex<T>(0.5, -std::numeric_limits<T>::infinity()),
+ std::complex<T>(1, -std::numeric_limits<T>::infinity()),
+ std::complex<T>(2, -std::numeric_limits<T>::infinity()),
+ std::complex<T>(std::numeric_limits<T>::infinity(), -std::numeric_limits<T>::infinity()),
- std::complex<double>(std::numeric_limits<double>::quiet_NaN(), -2),
- std::complex<double>(-std::numeric_limits<double>::infinity(), -2),
- std::complex<double>(-2, -2),
- std::complex<double>(-1, -2),
- std::complex<double>(-0.5, -2),
- std::complex<double>(-0., -2),
- std::complex<double>(+0., -2),
- std::complex<double>(0.5, -2),
- std::complex<double>(1, -2),
- std::complex<double>(2, -2),
- std::complex<double>(std::numeric_limits<double>::infinity(), -2),
+ std::complex<T>(std::numeric_limits<T>::quiet_NaN(), -2),
+ std::complex<T>(-std::numeric_limits<T>::infinity(), -2),
+ std::complex<T>(-2, -2),
+ std::complex<T>(-1, -2),
+ std::complex<T>(-0.5, -2),
+ std::complex<T>(-0., -2),
+ std::complex<T>(+0., -2),
+ std::complex<T>(0.5, -2),
+ std::complex<T>(1, -2),
+ std::complex<T>(2, -2),
+ std::complex<T>(std::numeric_limits<T>::infinity(), -2),
- std::complex<double>(std::numeric_limits<double>::quiet_NaN(), -1),
- std::complex<double>(-std::numeric_limits<double>::infinity(), -1),
- std::complex<double>(-2, -1),
- std::complex<double>(-1, -1),
- std::complex<double>(-0.5, -1),
- std::complex<double>(-0., -1),
- std::complex<double>(+0., -1),
- std::complex<double>(0.5, -1),
- std::complex<double>(1, -1),
- std::complex<double>(2, -1),
- std::complex<double>(std::numeric_limits<double>::infinity(), -1),
+ std::complex<T>(std::numeric_limits<T>::quiet_NaN(), -1),
+ std::complex<T>(-std::numeric_limits<T>::infinity(), -1),
+ std::complex<T>(-2, -1),
+ std::complex<T>(-1, -1),
+ std::complex<T>(-0.5, -1),
+ std::complex<T>(-0., -1),
+ std::complex<T>(+0., -1),
+ std::complex<T>(0.5, -1),
+ std::complex<T>(1, -1),
+ std::complex<T>(2, -1),
+ std::complex<T>(std::numeric_limits<T>::infinity(), -1),
- std::complex<double>(std::numeric_limits<double>::quiet_NaN(), -0.5),
- std::complex<double>(-std::numeric_limits<double>::infinity(), -0.5),
- std::complex<double>(-2, -0.5),
- std::complex<double>(-1, -0.5),
- std::complex<double>(-0.5, -0.5),
- std::complex<double>(-0., -0.5),
- std::complex<double>(+0., -0.5),
- std::complex<double>(0.5, -0.5),
- std::complex<double>(1, -0.5),
- std::complex<double>(2, -0.5),
- std::complex<double>(std::numeric_limits<double>::infinity(), -0.5),
+ std::complex<T>(std::numeric_limits<T>::quiet_NaN(), -0.5),
+ std::complex<T>(-std::numeric_limits<T>::infinity(), -0.5),
+ std::complex<T>(-2, -0.5),
+ std::complex<T>(-1, -0.5),
+ std::complex<T>(-0.5, -0.5),
+ std::complex<T>(-0., -0.5),
+ std::complex<T>(+0., -0.5),
+ std::complex<T>(0.5, -0.5),
+ std::complex<T>(1, -0.5),
+ std::complex<T>(2, -0.5),
+ std::complex<T>(std::numeric_limits<T>::infinity(), -0.5),
- std::complex<double>(std::numeric_limits<double>::quiet_NaN(), -0.),
- std::complex<double>(-std::numeric_limits<double>::infinity(), -0.),
- std::complex<double>(-2, -0.),
- std::complex<double>(-1, -0.),
- std::complex<double>(-0.5, -0.),
- std::complex<double>(-0., -0.),
- std::complex<double>(+0., -0.),
- std::complex<double>(0.5, -0.),
- std::complex<double>(1, -0.),
- std::complex<double>(2, -0.),
- std::complex<double>(std::numeric_limits<double>::infinity(), -0.),
+ std::complex<T>(std::numeric_limits<T>::quiet_NaN(), -0.),
+ std::complex<T>(-std::numeric_limits<T>::infinity(), -0.),
+ std::complex<T>(-2, -0.),
+ std::complex<T>(-1, -0.),
+ std::complex<T>(-0.5, -0.),
+ std::complex<T>(-0., -0.),
+ std::complex<T>(+0., -0.),
+ std::complex<T>(0.5, -0.),
+ std::complex<T>(1, -0.),
+ std::complex<T>(2, -0.),
+ std::complex<T>(std::numeric_limits<T>::infinity(), -0.),
- std::complex<double>(std::numeric_limits<double>::quiet_NaN(), +0.),
- std::complex<double>(-std::numeric_limits<double>::infinity(), +0.),
- std::complex<double>(-2, +0.),
- std::complex<double>(-1, +0.),
- std::complex<double>(-0.5, +0.),
- std::complex<double>(-0., +0.),
- std::complex<double>(+0., +0.),
- std::complex<double>(0.5, +0.),
- std::complex<double>(1, +0.),
- std::complex<double>(2, +0.),
- std::complex<double>(std::numeric_limits<double>::infinity(), +0.),
+ std::complex<T>(std::numeric_limits<T>::quiet_NaN(), +0.),
+ std::complex<T>(-std::numeric_limits<T>::infinity(), +0.),
+ std::complex<T>(-2, +0.),
+ std::complex<T>(-1, +0.),
+ std::complex<T>(-0.5, +0.),
+ std::complex<T>(-0., +0.),
+ std::complex<T>(+0., +0.),
+ std::complex<T>(0.5, +0.),
+ std::complex<T>(1, +0.),
+ std::complex<T>(2, +0.),
+ std::complex<T>(std::numeric_limits<T>::infinity(), +0.),
- std::complex<double>(std::numeric_limits<double>::quiet_NaN(), 0.5),
- std::complex<double>(-std::numeric_limits<double>::infinity(), 0.5),
- std::complex<double>(-2, 0.5),
- std::complex<double>(-1, 0.5),
- std::complex<double>(-0.5, 0.5),
- std::complex<double>(-0., 0.5),
- std::complex<double>(+0., 0.5),
- std::complex<double>(0.5, 0.5),
- std::complex<double>(1, 0.5),
- std::complex<double>(2, 0.5),
- std::complex<double>(std::numeric_limits<double>::infinity(), 0.5),
+ std::complex<T>(std::numeric_limits<T>::quiet_NaN(), 0.5),
+ std::complex<T>(-std::numeric_limits<T>::infinity(), 0.5),
+ std::complex<T>(-2, 0.5),
+ std::complex<T>(-1, 0.5),
+ std::complex<T>(-0.5, 0.5),
+ std::complex<T>(-0., 0.5),
+ std::complex<T>(+0., 0.5),
+ std::complex<T>(0.5, 0.5),
+ std::complex<T>(1, 0.5),
+ std::complex<T>(2, 0.5),
+ std::complex<T>(std::numeric_limits<T>::infinity(), 0.5),
- std::complex<double>(std::numeric_limits<double>::quiet_NaN(), 1),
- std::complex<double>(-std::numeric_limits<double>::infinity(), 1),
- std::complex<double>(-2, 1),
- std::complex<double>(-1, 1),
- std::complex<double>(-0.5, 1),
- std::complex<double>(-0., 1),
- std::complex<double>(+0., 1),
- std::complex<double>(0.5, 1),
- std::complex<double>(1, 1),
- std::complex<double>(2, 1),
- std::complex<double>(std::numeric_limits<double>::infinity(), 1),
+ std::complex<T>(std::numeric_limits<T>::quiet_NaN(), 1),
+ std::complex<T>(-std::numeric_limits<T>::infinity(), 1),
+ std::complex<T>(-2, 1),
+ std::complex<T>(-1, 1),
+ std::complex<T>(-0.5, 1),
+ std::complex<T>(-0., 1),
+ std::complex<T>(+0., 1),
+ std::complex<T>(0.5, 1),
+ std::complex<T>(1, 1),
+ std::complex<T>(2, 1),
+ std::complex<T>(std::numeric_limits<T>::infinity(), 1),
- std::complex<double>(std::numeric_limits<double>::quiet_NaN(), 2),
- std::complex<double>(-std::numeric_limits<double>::infinity(), 2),
- std::complex<double>(-2, 2),
- std::complex<double>(-1, 2),
- std::complex<double>(-0.5, 2),
- std::complex<double>(-0., 2),
- std::complex<double>(+0., 2),
- std::complex<double>(0.5, 2),
- std::complex<double>(1, 2),
- std::complex<double>(2, 2),
- std::complex<double>(std::numeric_limits<double>::infinity(), 2),
+ std::complex<T>(std::numeric_limits<T>::quiet_NaN(), 2),
+ std::complex<T>(-std::numeric_limits<T>::infinity(), 2),
+ std::complex<T>(-2, 2),
+ std::complex<T>(-1, 2),
+ std::complex<T>(-0.5, 2),
+ std::complex<T>(-0., 2),
+ std::complex<T>(+0., 2),
+ std::complex<T>(0.5, 2),
+ std::complex<T>(1, 2),
+ std::complex<T>(2, 2),
+ std::complex<T>(std::numeric_limits<T>::infinity(), 2),
- std::complex<double>(std::numeric_limits<double>::quiet_NaN(), std::numeric_limits<double>::infinity()),
- std::complex<double>(-std::numeric_limits<double>::infinity(), std::numeric_limits<double>::infinity()),
- std::complex<double>(-2, std::numeric_limits<double>::infinity()),
- std::complex<double>(-1, std::numeric_limits<double>::infinity()),
- std::complex<double>(-0.5, std::numeric_limits<double>::infinity()),
- std::complex<double>(-0., std::numeric_limits<double>::infinity()),
- std::complex<double>(+0., std::numeric_limits<double>::infinity()),
- std::complex<double>(0.5, std::numeric_limits<double>::infinity()),
- std::complex<double>(1, std::numeric_limits<double>::infinity()),
- std::complex<double>(2, std::numeric_limits<double>::infinity()),
- std::complex<double>(std::numeric_limits<double>::infinity(), std::numeric_limits<double>::infinity())
+ std::complex<T>(std::numeric_limits<T>::quiet_NaN(), std::numeric_limits<T>::infinity()),
+ std::complex<T>(-std::numeric_limits<T>::infinity(), std::numeric_limits<T>::infinity()),
+ std::complex<T>(-2, std::numeric_limits<T>::infinity()),
+ std::complex<T>(-1, std::numeric_limits<T>::infinity()),
+ std::complex<T>(-0.5, std::numeric_limits<T>::infinity()),
+ std::complex<T>(-0., std::numeric_limits<T>::infinity()),
+ std::complex<T>(+0., std::numeric_limits<T>::infinity()),
+ std::complex<T>(0.5, std::numeric_limits<T>::infinity()),
+ std::complex<T>(1, std::numeric_limits<T>::infinity()),
+ std::complex<T>(2, std::numeric_limits<T>::infinity()),
+ std::complex<T>(std::numeric_limits<T>::infinity(), std::numeric_limits<T>::infinity()),
};
enum {zero, non_zero, inf, NaN, non_zero_nan};
@@ -230,17 +231,15 @@ classify(const std::complex<T>& x)
return non_zero;
}
-inline
-int
-classify(double x)
-{
- if (x == 0)
- return zero;
- if (std::isinf(x))
- return inf;
- if (std::isnan(x))
- return NaN;
- return non_zero;
+template <class T>
+inline int classify(T x) {
+ if (x == 0)
+ return zero;
+ if (std::isinf(x))
+ return inf;
+ if (std::isnan(x))
+ return NaN;
+ return non_zero;
}
void is_about(float x, float y)
diff --git a/libcxx/test/std/numerics/complex.number/complex.ops/complex_divide_complex.pass.cpp b/libcxx/test/std/numerics/complex.number/complex.ops/complex_divide_complex.pass.cpp
index d12dfd994b0ae9..cd8c5389c6caa4 100644
--- a/libcxx/test/std/numerics/complex.number/complex.ops/complex_divide_complex.pass.cpp
+++ b/libcxx/test/std/numerics/complex.number/complex.ops/complex_divide_complex.pass.cpp
@@ -34,18 +34,18 @@ test()
return true;
}
-TEST_CONSTEXPR_CXX20
-bool
-test_edges()
-{
- const unsigned N = sizeof(testcases) / sizeof(testcases[0]);
+template <class T>
+TEST_CONSTEXPR_CXX20 bool test_edges() {
+ const unsigned N = sizeof(testcases<T>) / sizeof(testcases<T>[0]);
int classification[N];
for (unsigned i=0; i < N; ++i)
- classification[i] = classify(testcases[i]);
+ classification[i] = classify(testcases<T>[i]);
for (unsigned i = 0; i < N; ++i) {
+ auto const x = testcases<T>[i];
for (unsigned j = 0; j < N; ++j) {
- std::complex<double> r = testcases[i] / testcases[j];
+ auto const y = testcases<T>[j];
+ std::complex<T> r = x / y;
switch (classification[i]) {
case zero:
switch (classification[j]) {
@@ -153,13 +153,17 @@ int main(int, char**)
test<float>();
test<double>();
test<long double>();
- test_edges();
+ test_edges<float>();
+ test_edges<double>();
+ test_edges<long double>();
#if TEST_STD_VER > 17
static_assert(test<float>());
static_assert(test<double>());
static_assert(test<long double>());
- static_assert(test_edges());
+ static_assert(test_edges<float>());
+ static_assert(test_edges<double>());
+ static_assert(test_edges<long double>());
#endif
return 0;
diff --git a/libcxx/test/std/numerics/complex.number/complex.ops/complex_times_complex.pass.cpp b/libcxx/test/std/numerics/complex.number/complex.ops/complex_times_complex.pass.cpp
index 817d6cdf492d30..2f8af2c313e8eb 100644
--- a/libcxx/test/std/numerics/complex.number/complex.ops/complex_times_complex.pass.cpp
+++ b/libcxx/test/std/numerics/complex.number/complex.ops/complex_times_complex.pass.cpp
@@ -33,87 +33,80 @@ test()
// test edges
-TEST_CONSTEXPR_CXX20 bool test_edges()
-{
- const unsigned N = sizeof(testcases) / sizeof(testcases[0]);
- int classification[N];
- for (unsigned i=0; i < N; ++i)
- classification[i] = classify(testcases[i]);
+template <class T>
+TEST_CONSTEXPR_CXX20 bool test_edges() {
+ const unsigned N = sizeof(testcases<T>) / sizeof(testcases<T>[0]);
+ int classification[N];
+ for (unsigned i = 0; i < N; ++i)
+ classification[i] = classify(testcases<T>[i]);
- for (unsigned i = 0; i < N; ++i)
- {
- for (unsigned j = 0; j < N; ++j)
- {
- std::complex<double> r = testcases[i] * testcases[j];
- switch (classification[i])
- {
- case zero:
- switch (classification[j])
- {
- case zero:
- case non_zero:
- assert(classify(r) == zero);
- break;
- case inf:
- case NaN:
- case non_zero_nan:
- assert(classify(r) == NaN);
- break;
- }
- break;
- case non_zero:
- switch (classification[j])
- {
- case zero:
- assert(classify(r) == zero);
- break;
- case non_zero:
- assert(classify(r) == non_zero);
- break;
- case inf:
- assert(classify(r) == inf);
- break;
- case NaN:
- case non_zero_nan:
- assert(classify(r) == NaN);
- break;
- }
- break;
- case inf:
- switch (classification[j])
- {
- case zero:
- case NaN:
- assert(classify(r) == NaN);
- break;
- case non_zero:
- case inf:
- case non...
[truncated]
|
You can test this locally with the following command:git-clang-format --diff a8d2aeec8732c8d158f5b194a5191c0805bcd961 329ce37243c52547fb00243ac7bc59139d3f5125 --extensions h,cpp -- libcxx/test/std/numerics/complex.number/cases.h libcxx/test/std/numerics/complex.number/complex.ops/complex_divide_complex.pass.cpp libcxx/test/std/numerics/complex.number/complex.ops/complex_times_complex.pass.cpp libcxx/test/std/numerics/complex.number/complex.transcendentals/acos.pass.cpp libcxx/test/std/numerics/complex.number/complex.transcendentals/acosh.pass.cpp libcxx/test/std/numerics/complex.number/complex.transcendentals/asin.pass.cpp libcxx/test/std/numerics/complex.number/complex.transcendentals/asinh.pass.cpp libcxx/test/std/numerics/complex.number/complex.transcendentals/atan.pass.cpp libcxx/test/std/numerics/complex.number/complex.transcendentals/atanh.pass.cpp libcxx/test/std/numerics/complex.number/complex.transcendentals/cos.pass.cpp libcxx/test/std/numerics/complex.number/complex.transcendentals/cosh.pass.cpp libcxx/test/std/numerics/complex.number/complex.transcendentals/exp.pass.cpp libcxx/test/std/numerics/complex.number/complex.transcendentals/log.pass.cpp libcxx/test/std/numerics/complex.number/complex.transcendentals/log10.pass.cpp libcxx/test/std/numerics/complex.number/complex.transcendentals/pow_complex_complex.pass.cpp libcxx/test/std/numerics/complex.number/complex.transcendentals/pow_complex_scalar.pass.cpp libcxx/test/std/numerics/complex.number/complex.transcendentals/pow_scalar_complex.pass.cpp libcxx/test/std/numerics/complex.number/complex.transcendentals/sin.pass.cpp libcxx/test/std/numerics/complex.number/complex.transcendentals/sinh.pass.cpp libcxx/test/std/numerics/complex.number/complex.transcendentals/sqrt.pass.cpp libcxx/test/std/numerics/complex.number/complex.transcendentals/tan.pass.cpp libcxx/test/std/numerics/complex.number/complex.transcendentals/tanh.pass.cpp libcxx/test/std/numerics/complex.number/complex.value.ops/abs.pass.cpp libcxx/test/std/numerics/complex.number/complex.value.ops/arg.pass.cpp libcxx/test/std/numerics/complex.number/complex.value.ops/norm.pass.cpp libcxx/test/std/numerics/complex.number/complex.value.ops/polar.pass.cpp libcxx/test/std/numerics/complex.number/complex.value.ops/proj.pass.cppView the diff from clang-format here.diff --git a/libcxx/test/std/numerics/complex.number/complex.transcendentals/sqrt.pass.cpp b/libcxx/test/std/numerics/complex.number/complex.transcendentals/sqrt.pass.cpp
index 43813ba6fd..18344d4070 100644
--- a/libcxx/test/std/numerics/complex.number/complex.transcendentals/sqrt.pass.cpp
+++ b/libcxx/test/std/numerics/complex.number/complex.transcendentals/sqrt.pass.cpp
@@ -35,21 +35,19 @@ test()
test(std::complex<T>(64, 0), std::complex<T>(8, 0));
}
-template<class T>
-bool in_range(const T value, const T low, const T high) { return low < value && value < high; }
+template <class T>
+bool in_range(const T value, const T low, const T high) {
+ return low < value && value < high;
+}
// cosine calculations for std::arg terminate at different times based on the precision of T,
// and can produce a very small negative number instead of a very small positive one, so we
// should actually check that we're really close to zero instead of positive.
-bool approaching_zero(const float value) {
- return value == -0.0f || in_range(value, -4.38e-5f, 4.38e-5f);
-}
+bool approaching_zero(const float value) { return value == -0.0f || in_range(value, -4.38e-5f, 4.38e-5f); }
bool approaching_zero(double) { return false; }
-bool approaching_zero(const long double value) {
- return value == -0.0f || in_range(value, -3.0e-17L, 3.0e-17L);
-}
+bool approaching_zero(const long double value) { return value == -0.0f || in_range(value, -3.0e-17L, 3.0e-17L); }
template <class T>
void test_edges() {
|
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This increases test coverage for
std::complex, and improves verifying improvements tocomplexto non-double types.