summaryrefslogtreecommitdiffstats
path: root/libcxx/test/numerics/c.math/cmath.pass.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'libcxx/test/numerics/c.math/cmath.pass.cpp')
-rw-r--r--libcxx/test/numerics/c.math/cmath.pass.cpp14
1 files changed, 14 insertions, 0 deletions
diff --git a/libcxx/test/numerics/c.math/cmath.pass.cpp b/libcxx/test/numerics/c.math/cmath.pass.cpp
index 10b0993ad2e..13d872cdcc7 100644
--- a/libcxx/test/numerics/c.math/cmath.pass.cpp
+++ b/libcxx/test/numerics/c.math/cmath.pass.cpp
@@ -15,6 +15,12 @@
#include "hexfloat.h"
+// convertible to int/float/double/etc
+template <class T, int N=0>
+struct Value {
+ operator T () { return T(N); }
+};
+
void test_abs()
{
static_assert((std::is_same<decltype(std::abs((float)0)), float>::value), "");
@@ -333,7 +339,14 @@ void test_pow()
static_assert((std::is_same<decltype(std::powf(0,0)), float>::value), "");
static_assert((std::is_same<decltype(std::powl(0,0)), long double>::value), "");
static_assert((std::is_same<decltype(std::pow((int)0, (int)0)), double>::value), "");
+ static_assert((std::is_same<decltype(std::pow(Value<int>(), (int)0)), double>::value), "");
+ static_assert((std::is_same<decltype(std::pow(Value<long double>(), (float)0)), long double>::value), "");
+ static_assert((std::is_same<decltype(std::pow((float) 0, Value<float>())), float>::value), "");
assert(std::pow(1,1) == 1);
+ assert(std::pow(Value<int,1>(), Value<float,1>()) == 1);
+ assert(std::pow(1.0f, Value<double,1>()) == 1);
+ assert(std::pow(1.0, Value<int,1>()) == 1);
+ assert(std::pow(Value<long double,1>(), 1LL) == 1);
}
void test_sin()
@@ -1279,6 +1292,7 @@ void test_trunc()
int main()
{
+ test_abs();
test_acos();
test_asin();
test_atan();
OpenPOWER on IntegriCloud