diff mbox series

Fix tests for std::clamp

Message ID 20170921100609.GA8419@redhat.com
State New
Headers show
Series Fix tests for std::clamp | expand

Commit Message

Jonathan Wakely Sept. 21, 2017, 10:06 a.m. UTC
The tests using std::greater need to reverse the order of the 'hi' and
'lo' arguments, so that the precondition !comp(hi, lo) is met.

	* testsuite/25_algorithms/clamp/1.cc: Fix order of arguments and
	expected results when using predicate defining reverse order.
	* testsuite/25_algorithms/clamp/constexpr.cc: Likewise.

Tested x86_64-linux with -D_GLIBCXX_ASSERTIONS.

Committing to trunk and gcc-7-branch.
commit f1dabaea28903e55dee8ee52c45edbde766b3bb4
Author: Jonathan Wakely <jwakely@redhat.com>
Date:   Thu Sep 21 10:51:45 2017 +0100

    Fix tests for std::clamp
    
            * testsuite/25_algorithms/clamp/1.cc: Fix order of arguments and
            expected results when using predicate defining reverse order.
            * testsuite/25_algorithms/clamp/constexpr.cc: Likewise.
diff mbox series

Patch

diff --git a/libstdc++-v3/testsuite/25_algorithms/clamp/1.cc b/libstdc++-v3/testsuite/25_algorithms/clamp/1.cc
index 991b10d1fe3..655c241e9a2 100644
--- a/libstdc++-v3/testsuite/25_algorithms/clamp/1.cc
+++ b/libstdc++-v3/testsuite/25_algorithms/clamp/1.cc
@@ -30,12 +30,12 @@  void test01()
   VERIFY( y == 3 );
   VERIFY( z == 4 );
 
-  const int xc = std::clamp(1, 2, 4, std::greater<int>());
-  const int yc = std::clamp(3, 2, 4, std::greater<int>());
-  const int zc = std::clamp(5, 2, 4, std::greater<int>());
-  VERIFY( xc == 4 );
-  VERIFY( yc == 2 );
-  VERIFY( zc == 2 );
+  const int xc = std::clamp(1, 4, 2, std::greater<int>());
+  const int yc = std::clamp(3, 4, 2, std::greater<int>());
+  const int zc = std::clamp(5, 4, 2, std::greater<int>());
+  VERIFY( xc == 2 );
+  VERIFY( yc == 3 );
+  VERIFY( zc == 4 );
 }
 
 int
diff --git a/libstdc++-v3/testsuite/25_algorithms/clamp/constexpr.cc b/libstdc++-v3/testsuite/25_algorithms/clamp/constexpr.cc
index 0864b8e1d30..606748ec689 100644
--- a/libstdc++-v3/testsuite/25_algorithms/clamp/constexpr.cc
+++ b/libstdc++-v3/testsuite/25_algorithms/clamp/constexpr.cc
@@ -27,5 +27,5 @@ 
 # error "Feature-test macro for clamp has wrong value"
 #endif
 
-static_assert(std::clamp(2, 0, 1) == 1, "");
-static_assert(std::clamp(2, 0, 1, std::greater<int>()) == 0, "");
+static_assert(std::clamp(2, 0, 1) == 1);
+static_assert(std::clamp(2, 1, 0, std::greater<int>()) == 1);