Skip to content

Commit 19a8895

Browse files
Add constexpr boilerplate to tests
1 parent b386880 commit 19a8895

File tree

71 files changed

+837
-168
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

71 files changed

+837
-168
lines changed

libcxx/test/std/containers/associative/multimap/empty.pass.cpp

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,15 +10,16 @@
1010

1111
// class multimap
1212

13-
// bool empty() const;
13+
// bool empty() const; // constexpr since C++26
1414

1515
#include <map>
1616
#include <cassert>
1717

1818
#include "test_macros.h"
1919
#include "min_allocator.h"
2020

21-
int main(int, char**) {
21+
TEST_CONSTEXPR_CXX26
22+
bool test() {
2223
{
2324
typedef std::multimap<int, double> M;
2425
M m;
@@ -40,5 +41,13 @@ int main(int, char**) {
4041
}
4142
#endif
4243

44+
return true;
45+
}
46+
int main(int, char**) {
47+
assert(test());
48+
49+
#if TEST_STD_VER >= 26
50+
static_assert(test());
51+
#endif
4352
return 0;
4453
}

libcxx/test/std/containers/associative/multimap/get_allocator.pass.cpp

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010

1111
// class multimap
1212

13-
// allocator_type get_allocator() const
13+
// allocator_type get_allocator() const // constexpr since C++26
1414

1515
#include <map>
1616
#include <cassert>
@@ -19,7 +19,8 @@
1919
#include "test_allocator.h"
2020
#include "test_macros.h"
2121

22-
int main(int, char**) {
22+
TEST_CONSTEXPR_CXX26
23+
bool test() {
2324
typedef std::pair<const int, std::string> ValueType;
2425
{
2526
std::allocator<ValueType> alloc;
@@ -32,5 +33,13 @@ int main(int, char**) {
3233
assert(m.get_allocator() == alloc);
3334
}
3435

36+
return true;
37+
}
38+
int main(int, char**) {
39+
assert(test());
40+
41+
#if TEST_STD_VER >= 26
42+
static_assert(test());
43+
#endif
3544
return 0;
3645
}

libcxx/test/std/containers/associative/multimap/incomplete_type.pass.cpp

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,11 +26,21 @@ struct A {
2626

2727
inline bool operator==(A const& L, A const& R) { return &L == &R; }
2828
inline bool operator<(A const& L, A const& R) { return L.data < R.data; }
29-
int main(int, char**) {
29+
30+
TEST_CONSTEXPR_CXX26
31+
bool test() {
3032
A a;
3133

3234
// Make sure that the allocator isn't rebound to and incomplete type
3335
std::multimap<int, int, std::less<int>, complete_type_allocator<std::pair<const int, int> > > m;
3436

37+
return true;
38+
}
39+
int main(int, char**) {
40+
assert(test());
41+
42+
#if TEST_STD_VER >= 26
43+
static_assert(test());
44+
#endif
3545
return 0;
3646
}

libcxx/test/std/containers/associative/multimap/iterator.pass.cpp

Lines changed: 24 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -10,20 +10,22 @@
1010

1111
// class multimap
1212

13-
// iterator begin();
14-
// const_iterator begin() const;
15-
// iterator end();
16-
// const_iterator end() const;
13+
// iterator begin(); // constexpr since C++26
14+
// const_iterator begin() const; // constexpr since C++26
15+
// iterator end(); // constexpr since C++26
16+
// const_iterator end() const; // constexpr since C++26
17+
1718
//
18-
// reverse_iterator rbegin();
19-
// const_reverse_iterator rbegin() const;
20-
// reverse_iterator rend();
21-
// const_reverse_iterator rend() const;
19+
// reverse_iterator rbegin(); // constexpr since C++26
20+
// const_reverse_iterator rbegin() const; // constexpr since C++26
21+
// reverse_iterator rend(); // constexpr since C++26
22+
// const_reverse_iterator rend() const; // constexpr since C++26
23+
2224
//
23-
// const_iterator cbegin() const;
24-
// const_iterator cend() const;
25-
// const_reverse_iterator crbegin() const;
26-
// const_reverse_iterator crend() const;
25+
// const_iterator cbegin() const; // constexpr since C++26
26+
// const_iterator cend() const; // constexpr since C++26
27+
// const_reverse_iterator crbegin() const; // constexpr since C++26
28+
// const_reverse_iterator crend() const; // constexpr since C++26
2729

2830
#include <map>
2931
#include <cassert>
@@ -32,7 +34,8 @@
3234
#include "test_macros.h"
3335
#include "min_allocator.h"
3436

35-
int main(int, char**) {
37+
TEST_CONSTEXPR_CXX26
38+
bool test() {
3639
{
3740
typedef std::pair<const int, double> V;
3841
V ar[] = {V(1, 1), V(1, 1.5), V(1, 2), V(2, 1), V(2, 1.5), V(2, 2), V(3, 1), V(3, 1.5),
@@ -165,5 +168,13 @@ int main(int, char**) {
165168
}
166169
#endif
167170

171+
return true;
172+
}
173+
int main(int, char**) {
174+
assert(test());
175+
176+
#if TEST_STD_VER >= 26
177+
static_assert(test());
178+
#endif
168179
return 0;
169180
}

libcxx/test/std/containers/associative/multimap/max_size.pass.cpp

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010

1111
// class multimap
1212

13-
// size_type max_size() const;
13+
// size_type max_size() const; // constexpr since C++26
1414

1515
#include <cassert>
1616
#include <limits>
@@ -20,7 +20,8 @@
2020
#include "test_allocator.h"
2121
#include "test_macros.h"
2222

23-
int main(int, char**) {
23+
TEST_CONSTEXPR_CXX26
24+
bool test() {
2425
typedef std::pair<const int, int> KV;
2526
{
2627
typedef limited_allocator<KV, 10> A;
@@ -45,5 +46,13 @@ int main(int, char**) {
4546
assert(c.max_size() <= alloc_max_size(c.get_allocator()));
4647
}
4748

49+
return true;
50+
}
51+
int main(int, char**) {
52+
assert(test());
53+
54+
#if TEST_STD_VER >= 26
55+
static_assert(test());
56+
#endif
4857
return 0;
4958
}

libcxx/test/std/containers/associative/multimap/multimap.cons/alloc.pass.cpp

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010

1111
// class multimap
1212

13-
// explicit multimap(const allocator_type& a);
13+
// explicit multimap(const allocator_type& a); // constexpr since C++26
1414

1515
#include <map>
1616
#include <cassert>
@@ -19,7 +19,8 @@
1919
#include "test_allocator.h"
2020
#include "min_allocator.h"
2121

22-
int main(int, char**) {
22+
TEST_CONSTEXPR_CXX26
23+
bool test() {
2324
{
2425
typedef std::less<int> C;
2526
typedef test_allocator<std::pair<const int, double> > A;
@@ -47,5 +48,14 @@ int main(int, char**) {
4748
}
4849
#endif
4950

51+
return true;
52+
}
53+
54+
int main(int, char**) {
55+
assert(test());
56+
57+
#if TEST_STD_VER >= 26
58+
static_assert(test());
59+
#endif
5060
return 0;
5161
}

libcxx/test/std/containers/associative/multimap/multimap.cons/assign_initializer_list.pass.cpp

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,15 +12,16 @@
1212

1313
// class multimap
1414

15-
// multimap& operator=(initializer_list<value_type> il);
15+
// multimap& operator=(initializer_list<value_type> il); // constexpr since C++26
1616

1717
#include <map>
1818
#include <cassert>
1919

2020
#include "test_macros.h"
2121
#include "min_allocator.h"
2222

23-
int main(int, char**) {
23+
TEST_CONSTEXPR_CXX26
24+
bool test() {
2425
{
2526
typedef std::multimap<int, double> C;
2627
typedef C::value_type V;
@@ -58,5 +59,13 @@ int main(int, char**) {
5859
assert(*++i == V(3, 2));
5960
}
6061

62+
return true;
63+
}
64+
int main(int, char**) {
65+
assert(test());
66+
67+
#if TEST_STD_VER >= 26
68+
static_assert(test());
69+
#endif
6170
return 0;
6271
}

libcxx/test/std/containers/associative/multimap/multimap.cons/compare.pass.cpp

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010

1111
// class multimap
1212

13-
// explicit multimap(const key_compare& comp);
13+
// explicit multimap(const key_compare& comp); // constexpr since C++26
1414

1515
#include <map>
1616
#include <cassert>
@@ -19,7 +19,8 @@
1919
#include "../../../test_compare.h"
2020
#include "min_allocator.h"
2121

22-
int main(int, char**) {
22+
TEST_CONSTEXPR_CXX26
23+
bool test() {
2324
{
2425
typedef test_less<int> C;
2526
const std::multimap<int, double, C> m(C(3));
@@ -37,5 +38,13 @@ int main(int, char**) {
3738
}
3839
#endif
3940

41+
return true;
42+
}
43+
int main(int, char**) {
44+
assert(test());
45+
46+
#if TEST_STD_VER >= 26
47+
static_assert(test());
48+
#endif
4049
return 0;
4150
}

libcxx/test/std/containers/associative/multimap/multimap.cons/compare_alloc.pass.cpp

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010

1111
// class multimap
1212

13-
// multimap(const key_compare& comp, const allocator_type& a);
13+
// multimap(const key_compare& comp, const allocator_type& a); // constexpr since C++26
1414

1515
#include <map>
1616
#include <cassert>
@@ -20,7 +20,8 @@
2020
#include "test_allocator.h"
2121
#include "min_allocator.h"
2222

23-
int main(int, char**) {
23+
TEST_CONSTEXPR_CXX26
24+
bool test() {
2425
{
2526
typedef test_less<int> C;
2627
typedef test_allocator<std::pair<const int, double> > A;
@@ -51,5 +52,13 @@ int main(int, char**) {
5152
}
5253
#endif
5354

55+
return true;
56+
}
57+
int main(int, char**) {
58+
assert(test());
59+
60+
#if TEST_STD_VER >= 26
61+
static_assert(test());
62+
#endif
5463
return 0;
5564
}

libcxx/test/std/containers/associative/multimap/multimap.cons/copy.pass.cpp

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010

1111
// class multimap
1212

13-
// multimap(const multimap& m);
13+
// multimap(const multimap& m); // constexpr since C++26
1414

1515
#include <map>
1616
#include <cassert>
@@ -83,7 +83,8 @@ void test_alloc() {
8383
}
8484
}
8585

86-
void test() {
86+
TEST_CONSTEXPR_CXX26
87+
bool test() {
8788
test_alloc<std::allocator>();
8889
test_alloc<min_allocator>(); // Make sure that fancy pointers work
8990

@@ -132,10 +133,14 @@ void test() {
132133
assert(orig.size() == 3);
133134
assert(orig.get_allocator() == other_allocator<V>(10));
134135
}
136+
return true;
135137
}
136138

137139
int main(int, char**) {
138-
test();
140+
assert(test());
141+
#if TEST_STD_VER >= 26
142+
static_assert(test());
143+
#endif
139144

140145
return 0;
141146
}

0 commit comments

Comments
 (0)