1 // Copyright (C) 2020-2023 Free Software Foundation, Inc.
3 // This file is part of the GNU ISO C++ Library. This library is free
4 // software; you can redistribute it and/or modify it under the
5 // terms of the GNU General Public License as published by the
6 // Free Software Foundation; either version 3, or (at your option)
9 // This library is distributed in the hope that it will be useful,
10 // but WITHOUT ANY WARRANTY; without even the implied warranty of
11 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 // GNU General Public License for more details.
14 // You should have received a copy of the GNU General Public License along
15 // with this library; see the file COPYING3. If not see
16 // <http://www.gnu.org/licenses/>.
18 // { dg-do compile { target c++14 } }
20 #include <experimental/numeric>
27 static_assert( std::experimental::gcd(-120, 10U) == 10,
28 "mixed signed/unsigned" );
29 static_assert( std::experimental::gcd(120U, -10) == 10,
30 "mixed signed/unsigned" );
32 static_assert( std::experimental::lcm(-42, 21U) == 42U );
38 static_assert( std::experimental::gcd(INT_MIN
, 0LL) == 1LL+INT_MAX
,
39 "|INT_MIN| should not be undefined as long as it fits in the result" );
40 static_assert( std::experimental::gcd(0LL, INT_MIN
) == 1LL+INT_MAX
,
41 "|INT_MIN| should not be undefined" );
42 static_assert( std::experimental::gcd(INT_MIN
, 0LL + INT_MIN
) == 1LL + INT_MAX
,
43 "|INT_MIN| should not be undefined" );
44 static_assert( std::experimental::gcd(INT_MIN
, 1LL + INT_MAX
) == 1LL + INT_MAX
,
45 "|INT_MIN| should not be undefined" );
46 static_assert( std::experimental::gcd(SHRT_MIN
, 1U + SHRT_MAX
) == 1U + SHRT_MAX
,
47 "|SHRT_MIN| should not be undefined" );