1 // Copyright 2016-2021 Francesco Biscani (bluescarni@gmail.com)
2 //
3 // This file is part of the mp++ library.
4 //
5 // This Source Code Form is subject to the terms of the Mozilla
6 // Public License v. 2.0. If a copy of the MPL was not distributed
7 // with this file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 
9 #include <type_traits>
10 
11 #include <mp++/complex128.hpp>
12 
13 #include "catch.hpp"
14 
15 // NOLINTNEXTLINE(google-build-using-namespace)
16 using namespace mppp;
17 
18 TEST_CASE("sqrt")
19 {
20     const complex128 cmp{"(2,1)"};
21 
22     complex128 c{3, 4};
23     REQUIRE(std::is_same<complex128 &, decltype(c.sqrt())>::value);
24     c.sqrt();
25     REQUIRE(abs(complex128{c.m_value - cmp.m_value}) < 1E-32);
26     REQUIRE(std::is_same<complex128, decltype(sqrt(complex128{3, 4}))>::value);
27     REQUIRE(abs(complex128{sqrt(complex128{3, 4}).m_value - cmp.m_value}) < 1E-32);
28 }
29