From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by sourceware.org (Postfix) with ESMTP id 95111385AC34 for ; Tue, 5 Oct 2021 14:57:59 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 95111385AC34 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-554-36VBC7CQOnaOZzFtwBXh_Q-1; Tue, 05 Oct 2021 10:57:57 -0400 X-MC-Unique: 36VBC7CQOnaOZzFtwBXh_Q-1 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 21106100C665; Tue, 5 Oct 2021 14:57:57 +0000 (UTC) Received: from localhost (unknown [10.33.37.40]) by smtp.corp.redhat.com (Postfix) with ESMTP id B0FDC60936; Tue, 5 Oct 2021 14:57:56 +0000 (UTC) Date: Tue, 5 Oct 2021 15:57:55 +0100 From: Jonathan Wakely To: libstdc++@gcc.gnu.org, gcc-patches@gcc.gnu.org Subject: [committed] libstdc++: Add test for std::cmp_greater Message-ID: MIME-Version: 1.0 X-Clacks-Overhead: GNU Terry Pratchett X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: multipart/mixed; boundary="gLPDj247qGWJPnug" Content-Disposition: inline X-Spam-Status: No, score=-13.8 required=5.0 tests=BAYES_00, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H2, SPF_HELO_NONE, SPF_NONE, TXREP autolearn=ham autolearn_force=no version=3.4.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on server2.sourceware.org X-BeenThere: libstdc++@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Libstdc++ mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 05 Oct 2021 14:58:09 -0000 --gLPDj247qGWJPnug Content-Type: text/plain; charset=us-ascii Content-Disposition: inline This was omitted from the commit that added these comparisons. libstdc++-v3/ChangeLog: * testsuite/20_util/integer_comparisons/greater.cc: New test. Tested powerpc64le-linux. Committed to trunk. --gLPDj247qGWJPnug Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename="patch.txt" commit 824e0855732c601e0866d0e8a9264a85f758213e Author: Jonathan Wakely Date: Tue Oct 5 10:38:03 2021 libstdc++: Add test for std::cmp_greater This was omitted from the commit that added these comparisons. libstdc++-v3/ChangeLog: * testsuite/20_util/integer_comparisons/greater.cc: New test. diff --git a/libstdc++-v3/testsuite/20_util/integer_comparisons/greater.cc b/libstdc++-v3/testsuite/20_util/integer_comparisons/greater.cc new file mode 100644 index 00000000000..e564d8d03f2 --- /dev/null +++ b/libstdc++-v3/testsuite/20_util/integer_comparisons/greater.cc @@ -0,0 +1,61 @@ +// { dg-options "-std=gnu++20" } +// { dg-do run { target c++20 } } + +#include +#include +#include + +void +test01() +{ + unsigned int u = std::numeric_limits::max(); + int s = -1; + VERIFY( !std::cmp_greater(s, u) ); + VERIFY( std::cmp_greater(u, s) ); + u = (unsigned) std::numeric_limits::max() + 1U; + VERIFY( !std::cmp_greater(s, u) ); + VERIFY( std::cmp_greater(u, s) ); +} + +constexpr bool +test02() +{ + unsigned int u = std::numeric_limits::max(); + int s = -1; + if (std::cmp_greater(s, u)) + throw 1; + if (!std::cmp_greater(u, s)) + throw 2; + return true; +} + +void +test03() +{ + short ss = -1; + int s = -1; + VERIFY( !std::cmp_greater(s, ss) ); + VERIFY( !std::cmp_greater(ss, s) ); + + unsigned int u = (unsigned int) -1; + VERIFY( !std::cmp_greater(s, u) ); + VERIFY( std::cmp_greater(u, s) ); + VERIFY( !std::cmp_greater(ss, u) ); + VERIFY( std::cmp_greater(u, ss) ); + + unsigned long long ul = (unsigned long long) -1; + VERIFY( !std::cmp_greater(s, ul) ); + VERIFY( std::cmp_greater(ul, s) ); + VERIFY( !std::cmp_greater(ss, ul) ); + VERIFY( std::cmp_greater(ul, ss) ); + VERIFY( !std::cmp_greater(u, ul) ); + VERIFY( std::cmp_greater(ul, u) ); +} + +int +main() +{ + test01(); + static_assert( test02() ); + test03(); +} --gLPDj247qGWJPnug--