hypot_test.cc
Go to the documentation of this file.
1 #include "catch2/catch.hpp"
2 
3 #include <cmath>
4 #include <limits>
5 
6 #include "cetlib/hypot.h"
7 
8 using cet::hypot;
9 
10 TEST_CASE("Basic test")
11 {
12  CHECK(hypot(5, 12) == 13);
13  CHECK(hypot(.5, 1.2) == Approx(1.3).epsilon(0.0001));
14  CHECK(hypot(.05L, .12L) == Approx(.13L).epsilon(0.0001L));
15 }
16 
17 TEST_CASE("NaN test")
18 {
19  CHECK(std::isnan(hypot(std::numeric_limits<double>::quiet_NaN(), 1.2)));
20  CHECK(std::isnan(hypot(3.1415926, std::numeric_limits<double>::quiet_NaN())));
21 }
22 
23 TEST_CASE("Inf test")
24 {
25  CHECK(std::isinf(hypot(std::numeric_limits<double>::infinity(), 1.2)));
26  CHECK(std::isinf(hypot(3.1415926, std::numeric_limits<double>::infinity())));
27 
28  CHECK(std::isinf(hypot(-std::numeric_limits<double>::infinity(), 1.2)));
29  CHECK(std::isinf(hypot(3.1415926, -std::numeric_limits<double>::infinity())));
30 }
std::enable_if_t< std::is_arithmetic_v< T >, T > hypot(T x, T y)
Definition: hypot.h:60
TEST_CASE("Basic test")
Definition: hypot_test.cc:10