[libcxx-commits] [libcxx] 11a1fc4 - [libc++][NFC] Refactor `std::array`'s `verify.cpp` tests (#173455)
via libcxx-commits
libcxx-commits at lists.llvm.org
Thu Dec 25 04:06:10 PST 2025
Author: Hristo Hristov
Date: 2025-12-25T14:06:05+02:00
New Revision: 11a1fc412b37b8907064db447bebf5f0d42ff6a4
URL: https://github.com/llvm/llvm-project/commit/11a1fc412b37b8907064db447bebf5f0d42ff6a4
DIFF: https://github.com/llvm/llvm-project/commit/11a1fc412b37b8907064db447bebf5f0d42ff6a4.diff
LOG: [libc++][NFC] Refactor `std::array`'s `verify.cpp` tests (#173455)
This came up in a review previously: replaces `main()` in some
`verify.cpp` tests.
Added:
Modified:
libcxx/test/std/containers/sequences/array/array.cons/deduct.verify.cpp
libcxx/test/std/containers/sequences/array/array.creation/to_array.verify.cpp
libcxx/test/std/containers/sequences/array/array.fill/fill.verify.cpp
libcxx/test/std/containers/sequences/array/array.swap/swap.verify.cpp
libcxx/test/std/containers/sequences/array/array.tuple/get.verify.cpp
libcxx/test/std/containers/sequences/array/compare.verify.cpp
Removed:
libcxx/test/std/containers/sequences/array/empty.verify.cpp
################################################################################
diff --git a/libcxx/test/std/containers/sequences/array/array.cons/deduct.verify.cpp b/libcxx/test/std/containers/sequences/array/array.cons/deduct.verify.cpp
index 92dac11501185..96bed04adfbea 100644
--- a/libcxx/test/std/containers/sequences/array/array.cons/deduct.verify.cpp
+++ b/libcxx/test/std/containers/sequences/array/array.cons/deduct.verify.cpp
@@ -6,8 +6,9 @@
//
//===----------------------------------------------------------------------===//
+// REQUIRES: std-at-least-c++17
+
// <array>
-// UNSUPPORTED: c++03, c++11, c++14
// template <class T, class... U>
// array(T, U...) -> array<T, 1 + sizeof...(U)>;
@@ -20,11 +21,9 @@
#include "test_macros.h"
-int main(int, char**) {
+void test() {
{
std::array arr{1, 2, 3L};
// expected-error-re at -1 {{no viable constructor or deduction guide for deduction of template arguments of '{{(std::)?}}array'}}
}
-
- return 0;
}
diff --git a/libcxx/test/std/containers/sequences/array/array.creation/to_array.verify.cpp b/libcxx/test/std/containers/sequences/array/array.creation/to_array.verify.cpp
index ee8d8e6cfb2e5..65315dc79d31f 100644
--- a/libcxx/test/std/containers/sequences/array/array.creation/to_array.verify.cpp
+++ b/libcxx/test/std/containers/sequences/array/array.creation/to_array.verify.cpp
@@ -6,8 +6,9 @@
//
//===----------------------------------------------------------------------===//
+// REQUIRES: std-at-least-c++20
+
// <array>
-// UNSUPPORTED: c++03, c++11, c++14, c++17
#include <array>
@@ -16,7 +17,7 @@
// expected-warning at array:* 0-1 {{suggest braces around initialization of subobject}}
-int main(int, char**) {
+void test() {
{
char source[3][6] = {"hi", "world"};
// expected-error at array:* {{to_array does not accept multidimensional arrays}}
@@ -38,6 +39,4 @@ int main(int, char**) {
// expected-error-re at array:* 0-1{{{{(call to implicitly-deleted copy constructor of 'MoveOnly')|(call to deleted constructor of 'MoveOnly')}}}}
(void)std::to_array(std::move(cmo)); // expected-note {{requested here}}
}
-
- return 0;
}
diff --git a/libcxx/test/std/containers/sequences/array/array.fill/fill.verify.cpp b/libcxx/test/std/containers/sequences/array/array.fill/fill.verify.cpp
index 199081677c1a7..99dd4fa36d89a 100644
--- a/libcxx/test/std/containers/sequences/array/array.fill/fill.verify.cpp
+++ b/libcxx/test/std/containers/sequences/array/array.fill/fill.verify.cpp
@@ -13,7 +13,7 @@
#include <array>
#include <cassert>
-int main(int, char**) {
+void test() {
{
typedef double T;
typedef std::array<const T, 0> C;
@@ -21,6 +21,4 @@ int main(int, char**) {
// expected-error-re@*:* {{static assertion failed{{.*}}cannot fill zero-sized array of type 'const T'}}
c.fill(5.5); // expected-note {{requested here}}
}
-
- return 0;
}
diff --git a/libcxx/test/std/containers/sequences/array/array.swap/swap.verify.cpp b/libcxx/test/std/containers/sequences/array/array.swap/swap.verify.cpp
index 337815c6a73f2..2a898d23493ef 100644
--- a/libcxx/test/std/containers/sequences/array/array.swap/swap.verify.cpp
+++ b/libcxx/test/std/containers/sequences/array/array.swap/swap.verify.cpp
@@ -13,15 +13,11 @@
#include <array>
#include <cassert>
-int main(int, char**) {
- {
- typedef double T;
- typedef std::array<const T, 0> C;
- C c = {};
- C c2 = {};
- // expected-error-re@*:* {{static assertion failed{{.*}}cannot swap zero-sized array of type 'const T'}}
- c.swap(c2); // expected-note {{requested here}}
- }
-
- return 0;
+void test() {
+ typedef double T;
+ typedef std::array<const T, 0> C;
+ C c = {};
+ C c2 = {};
+ // expected-error-re@*:* {{static assertion failed{{.*}}cannot swap zero-sized array of type 'const T'}}
+ c.swap(c2); // expected-note {{requested here}}
}
diff --git a/libcxx/test/std/containers/sequences/array/array.tuple/get.verify.cpp b/libcxx/test/std/containers/sequences/array/array.tuple/get.verify.cpp
index 02368314f17a8..78054e8a12b68 100644
--- a/libcxx/test/std/containers/sequences/array/array.tuple/get.verify.cpp
+++ b/libcxx/test/std/containers/sequences/array/array.tuple/get.verify.cpp
@@ -16,7 +16,7 @@
#include <array>
#include <cassert>
-void f() {
+void test() {
typedef double T;
typedef std::array<T, 3> C;
C c = {1, 2, 3.5};
diff --git a/libcxx/test/std/containers/sequences/array/compare.verify.cpp b/libcxx/test/std/containers/sequences/array/compare.verify.cpp
index 4b001601a4fe2..c49f83e2e1f2c 100644
--- a/libcxx/test/std/containers/sequences/array/compare.verify.cpp
+++ b/libcxx/test/std/containers/sequences/array/compare.verify.cpp
@@ -28,7 +28,7 @@
template <int>
struct NoCompare {};
-int main(int, char**) {
+void test() {
{
typedef NoCompare<0> T;
typedef std::array<T, 3> C;
@@ -53,6 +53,4 @@ int main(int, char**) {
TEST_IGNORE_NODISCARD(c1 == c1);
TEST_IGNORE_NODISCARD(c1 < c1);
}
-
- return 0;
}
diff --git a/libcxx/test/std/containers/sequences/array/empty.verify.cpp b/libcxx/test/std/containers/sequences/array/empty.verify.cpp
deleted file mode 100644
index 2fc821e08a106..0000000000000
--- a/libcxx/test/std/containers/sequences/array/empty.verify.cpp
+++ /dev/null
@@ -1,24 +0,0 @@
-//===----------------------------------------------------------------------===//
-//
-// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
-// See https://llvm.org/LICENSE.txt for license information.
-// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
-//
-//===----------------------------------------------------------------------===//
-
-// <array>
-
-// class array
-
-// bool empty() const noexcept;
-
-// UNSUPPORTED: c++03, c++11, c++14, c++17
-
-#include <array>
-
-void f() {
- std::array<int, 1> c;
- c.empty(); // expected-warning {{ignoring return value of function declared with 'nodiscard' attribute}}
- std::array<int, 0> c0;
- c0.empty(); // expected-warning {{ignoring return value of function declared with 'nodiscard' attribute}}
-}
More information about the libcxx-commits
mailing list