Skip to content

Commit d3f7f5b

Browse files
committed
Add more comments on tests
1 parent 5f54df6 commit d3f7f5b

15 files changed

+45
-60
lines changed

libcxx/test/std/containers/sequences/vector.bool/append_range_exceptions.pass.cpp

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ int main(int, char**) {
2626
// Note: `test_append_range_exception_safety_throwing_copy` doesn't apply because copying booleans cannot throw.
2727
test_append_range_exception_safety_throwing_allocator<std::vector, bool>();
2828

29-
{
29+
{ // Attempt to append more elements to a non-empty vector<bool> than its maximum possible size
3030
std::vector<bool, limited_allocator<bool, 10> > v;
3131
v.resize(v.max_size() - 2, true);
3232
bool a[] = {false, true, false};
@@ -39,16 +39,14 @@ int main(int, char**) {
3939
assert(v[i] == true);
4040
}
4141
}
42-
{
43-
std::vector<bool, limited_allocator<bool, 10> > v(5, true);
44-
bool a[v.max_size()] = {}; // A large enough array to trigger a length_error when appended
42+
{ // Attempt to append more elements to an empty vector<bool> than its maximum possible size
43+
std::vector<bool, limited_allocator<bool, 10> > v;
44+
bool a[v.max_size() + 1] = {}; // A large enough array to trigger a length_error when appended
4545
try {
4646
v.append_range(a);
4747
assert(false);
4848
} catch (const std::length_error&) {
49-
assert(v.size() == 5);
50-
for (std::size_t i = 0; i != v.size(); ++i)
51-
assert(v[i] == true);
49+
assert(v.empty());
5250
}
5351
}
5452

libcxx/test/std/containers/sequences/vector.bool/emplace_back_exceptions.pass.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,8 @@
2424
int main(int, char**) {
2525
std::vector<bool, limited_allocator<bool, 10> > v;
2626
v.resize(v.max_size(), true);
27+
28+
// Attempt to append one more element to a vector<bool> that is already at its maximum possible size
2729
try {
2830
v.emplace_back(true);
2931
assert(false);

libcxx/test/std/containers/sequences/vector.bool/emplace_exceptions.pass.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
#include "test_allocator.h"
2222

2323
int main(int, char**) {
24-
{
24+
{ // Attempt to insert an element at the beginning of a vector<bool> that is already at its maximum possible size
2525
std::vector<bool, limited_allocator<bool, 10> > v;
2626
v.resize(v.max_size(), true);
2727
try {
@@ -33,7 +33,7 @@ int main(int, char**) {
3333
assert(v[i] == true);
3434
}
3535
}
36-
{
36+
{ // Attempt to insert an element at the end of a vector<bool> that is already at its maximum possible size
3737
std::vector<bool, limited_allocator<bool, 10> > v;
3838
v.resize(v.max_size(), true);
3939
try {
@@ -45,7 +45,7 @@ int main(int, char**) {
4545
assert(v[i] == true);
4646
}
4747
}
48-
{
48+
{ // Attempt to insert an element in the middle of a vector<bool> that is already at its maximum possible size
4949
std::vector<bool, limited_allocator<bool, 10> > v;
5050
v.resize(v.max_size(), true);
5151
try {

libcxx/test/std/containers/sequences/vector.bool/insert_exceptions.pass.cpp

Lines changed: 5 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
#include "test_macros.h"
2626

2727
int main(int, char**) {
28-
{
28+
{ // Attempt to insert an element at the beginning of a vector<bool> that is already at its maximum possible size
2929
std::vector<bool, limited_allocator<bool, 10> > v;
3030
v.resize(v.max_size(), true);
3131
try {
@@ -37,7 +37,7 @@ int main(int, char**) {
3737
assert(v[i] == true);
3838
}
3939
}
40-
{
40+
{ // Attempt to insert an element at the end of a vector<bool> that is already at its maximum possible size
4141
std::vector<bool, limited_allocator<bool, 10> > v;
4242
v.resize(v.max_size(), false);
4343
try {
@@ -49,7 +49,7 @@ int main(int, char**) {
4949
assert(v[i] == false);
5050
}
5151
}
52-
{
52+
{ // Attempt to insert an element in the middle of a vector<bool> that is already at its maximum possible size
5353
std::vector<bool, limited_allocator<bool, 10> > v;
5454
v.resize(v.max_size(), true);
5555
try {
@@ -61,19 +61,7 @@ int main(int, char**) {
6161
assert(v[i] == true);
6262
}
6363
}
64-
{
65-
std::vector<bool, limited_allocator<bool, 10> > v;
66-
v.resize(v.max_size(), true);
67-
try {
68-
v.insert(v.begin(), 1, false);
69-
assert(false);
70-
} catch (const std::length_error&) {
71-
assert(v.size() == v.max_size());
72-
for (std::size_t i = 0; i != v.size(); ++i)
73-
assert(v[i] == true);
74-
}
75-
}
76-
{
64+
{ // Attempt to insert an iterator range to a vector<bool> that would exceed its maximum possible size
7765
std::vector<bool, limited_allocator<bool, 10> > v;
7866
v.resize(v.max_size() - 2, true);
7967
bool a[] = {true, false, true};
@@ -87,7 +75,7 @@ int main(int, char**) {
8775
}
8876
}
8977
#if TEST_STD_VER >= 11
90-
{
78+
{ // Attempt to insert an initializer_list to a vector<bool> that would exceed its maximum possible size
9179
std::vector<bool, limited_allocator<bool, 10> > v;
9280
v.resize(v.max_size() - 2, true);
9381
try {

libcxx/test/std/containers/sequences/vector.bool/insert_range_exceptions.pass.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ int main(int, char**) {
2626
// Note: `test_insert_range_exception_safety_throwing_copy` doesn't apply because copying booleans cannot throw.
2727
test_insert_range_exception_safety_throwing_allocator<std::vector, bool>();
2828

29-
{
29+
{ // Attempt to insert a range at the end of a vector<bool> that would exceed its maximum possible size
3030
std::vector<bool, limited_allocator<bool, 10> > v;
3131
v.resize(v.max_size() - 2, true);
3232
bool a[] = {true, false, true};
@@ -39,7 +39,7 @@ int main(int, char**) {
3939
assert(v[i] == true);
4040
}
4141
}
42-
{
42+
{ // Attempt to insert a range at the beginning of a vector<bool> that would exceed its maximum possible size
4343
std::vector<bool, limited_allocator<bool, 10> > v;
4444
v.resize(v.max_size() - 2, false);
4545
bool a[] = {true, false, true};
@@ -52,7 +52,7 @@ int main(int, char**) {
5252
assert(v[i] == false);
5353
}
5454
}
55-
{
55+
{ // Attempt to insert a range in the middle of a vector<bool> that would exceed its maximum possible size
5656
std::vector<bool, limited_allocator<bool, 10> > v(5, true);
5757
bool a[v.max_size()] = {};
5858
try {

libcxx/test/std/containers/sequences/vector.bool/push_back_exceptions.pass.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
#include "test_allocator.h"
2121

2222
int main(int, char**) {
23+
// Attempt to push back an element into a vector<bool> that is already at its maximum possible size
2324
std::vector<bool, limited_allocator<bool, 10> > v;
2425
v.resize(v.max_size(), true);
2526
try {

libcxx/test/std/containers/sequences/vector.bool/reserve_exceptions.pass.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
#include "test_allocator.h"
2121

2222
int main(int, char**) {
23-
{
23+
{ // Attempt to reserve more space than the maximum possible size of a vector<bool>
2424
std::vector<bool, limited_allocator<bool, 10> > v;
2525
v.reserve(5);
2626
try {
@@ -35,7 +35,7 @@ int main(int, char**) {
3535
assert(v.capacity() >= 5);
3636
}
3737
}
38-
{
38+
{ // Attempt to reserve more space for a vector<bool> that is already at its maximum possible size
3939
std::vector<bool, limited_allocator<bool, 10> > v;
4040
v.resize(v.max_size(), true);
4141
try {
@@ -47,7 +47,7 @@ int main(int, char**) {
4747
assert(v[i] == true);
4848
}
4949
}
50-
{
50+
{ // Attempt to reserve 1 more space than the maximum possible size of a vector<bool>
5151
bool a[] = {true, false, true, false, true};
5252
std::vector<bool> v(std::begin(a), std::end(a));
5353
try {

libcxx/test/std/containers/sequences/vector.bool/resize_size_exceptions.pass.cpp

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
#include "test_allocator.h"
2222

2323
int main(int, char**) {
24-
{
24+
{ // Attempt to resize a non-empty vector<bool> to a size greater than its maximum possible size
2525
std::vector<bool, limited_allocator<bool, 10> > v(5, false);
2626
try {
2727
v.resize(v.max_size() + 1);
@@ -33,19 +33,16 @@ int main(int, char**) {
3333
assert(!v[i]);
3434
}
3535
}
36-
{
36+
{ // Attempt to resize an empty vector<bool> to a size greater than its maximum possible size
3737
std::vector<bool, limited_allocator<bool, 10> > v;
38-
v.resize(v.max_size() / 2);
3938
try {
4039
v.resize(v.max_size() + 1);
4140
assert(false);
4241
} catch (const std::length_error&) {
43-
assert(v.size() == v.max_size() / 2);
44-
for (std::size_t i = 0; i < v.size(); ++i)
45-
assert(v[i] == false);
42+
assert(v.empty());
4643
}
4744
}
48-
{
45+
{ // Attempt to resize a vector<bool> with standard allocator to a size greater than its maximum possible size
4946
bool a[] = {true, false, true, false, true};
5047
std::vector<bool> v(std::begin(a), std::end(a));
5148
try {

libcxx/test/std/containers/sequences/vector.bool/resize_size_value_exceptions.pass.cpp

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
#include "test_allocator.h"
2424

2525
int main(int, char**) {
26-
{
26+
{ // Attempt to resize a non-empty vector<bool> to a size greater than its maximum possible size
2727
std::vector<bool, limited_allocator<bool, 10> > v(5, false);
2828
try {
2929
v.resize(v.max_size() + 1, true);
@@ -35,19 +35,16 @@ int main(int, char**) {
3535
assert(!v[i]);
3636
}
3737
}
38-
{
38+
{ // Attempt to resize an empty vector<bool> to a size greater than its maximum possible size
3939
std::vector<bool, limited_allocator<bool, 10> > v;
40-
v.resize(v.max_size() / 2);
4140
try {
4241
v.resize(v.max_size() + 1, true);
4342
assert(false);
4443
} catch (const std::length_error&) {
45-
assert(v.size() == v.max_size() / 2);
46-
for (std::size_t i = 0; i < v.size(); ++i)
47-
assert(v[i] == false);
44+
assert(v.empty());
4845
}
4946
}
50-
{
47+
{ // Attempt to resize a vector<bool> with standard allocator to a size greater than its maximum possible size
5148
bool a[] = {true, false, true, false, true};
5249
std::vector<bool> v(std::begin(a), std::end(a));
5350
try {

libcxx/test/std/containers/sequences/vector/vector.modifiers/append_range_exceptions.pass.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ int main(int, char**) {
2525
test_append_range_exception_safety_throwing_copy<std::vector>();
2626
test_append_range_exception_safety_throwing_allocator<std::vector, int>();
2727

28+
// Attempt to append a range to a vector that would exceed its maximum possible size
2829
{
2930
std::vector<int, limited_allocator<int, 10> > v(8, 42);
3031
int a[] = {1, 2, 3};

0 commit comments

Comments
 (0)