[libcxx-commits] [libcxx] a1f75bf - [libc++] [test] Simplify arithmetic in list.special/swap.pass.cpp. NFCI.
Arthur O'Dwyer via libcxx-commits
libcxx-commits at lists.llvm.org
Fri May 7 07:05:26 PDT 2021
Author: Arthur O'Dwyer
Date: 2021-05-07T10:03:52-04:00
New Revision: a1f75bf091a20132dc44828a2a9a68d559f922f3
URL: https://github.com/llvm/llvm-project/commit/a1f75bf091a20132dc44828a2a9a68d559f922f3
DIFF: https://github.com/llvm/llvm-project/commit/a1f75bf091a20132dc44828a2a9a68d559f922f3.diff
LOG: [libc++] [test] Simplify arithmetic in list.special/swap.pass.cpp. NFCI.
Part of https://reviews.llvm.org/D102003
Added:
Modified:
libcxx/test/std/containers/sequences/list/list.special/swap.pass.cpp
Removed:
################################################################################
diff --git a/libcxx/test/std/containers/sequences/list/list.special/swap.pass.cpp b/libcxx/test/std/containers/sequences/list/list.special/swap.pass.cpp
index bb1efdcbc834..da9bf3ba3884 100644
--- a/libcxx/test/std/containers/sequences/list/list.special/swap.pass.cpp
+++ b/libcxx/test/std/containers/sequences/list/list.special/swap.pass.cpp
@@ -22,41 +22,37 @@ int main(int, char**)
{
int a1[] = {1, 3, 7, 9, 10};
int a2[] = {0, 2, 4, 5, 6, 8, 11};
- std::list<int> c1(a1, a1 + sizeof(a1)/sizeof(a1[0]));
- std::list<int> c2(a2, a2 + sizeof(a2)/sizeof(a2[0]));
+ std::list<int> c1(a1, a1 + 5);
+ std::list<int> c2(a2, a2 + 7);
std::list<int>::iterator it1 = c1.begin();
std::list<int>::const_iterator it2 = c2.begin();
swap(c1, c2);
- assert(c1 == std::list<int>(a2, a2+sizeof(a2)/sizeof(a2[0])));
- assert(c2 == std::list<int>(a1, a1+sizeof(a1)/sizeof(a1[0])));
+ assert(c1 == std::list<int>(a2, a2 + 7));
+ assert(c2 == std::list<int>(a1, a1 + 5));
assert(it1 == c2.begin()); // Iterators remain valid
assert(it2 == c1.begin()); // Iterators remain valid
}
{
- int a1[] = {1, 3, 7, 9, 10};
int a2[] = {0, 2, 4, 5, 6, 8, 11};
- std::list<int> c1(a1, a1);
- std::list<int> c2(a2, a2+sizeof(a2)/sizeof(a2[0]));
+ std::list<int> c1;
+ std::list<int> c2(a2, a2 + 7);
swap(c1, c2);
- assert(c1 == std::list<int>(a2, a2+sizeof(a2)/sizeof(a2[0])));
+ assert(c1 == std::list<int>(a2, a2 + 7));
assert(c2.empty());
assert(distance(c2.begin(), c2.end()) == 0);
}
{
int a1[] = {1, 3, 7, 9, 10};
- int a2[] = {0, 2, 4, 5, 6, 8, 11};
- std::list<int> c1(a1, a1+sizeof(a1)/sizeof(a1[0]));
- std::list<int> c2(a2, a2);
+ std::list<int> c1(a1, a1 + 5);
+ std::list<int> c2;
swap(c1, c2);
assert(c1.empty());
assert(distance(c1.begin(), c1.end()) == 0);
- assert(c2 == std::list<int>(a1, a1+sizeof(a1)/sizeof(a1[0])));
+ assert(c2 == std::list<int>(a1, a1 + 5));
}
{
- int a1[] = {1, 3, 7, 9, 10};
- int a2[] = {0, 2, 4, 5, 6, 8, 11};
- std::list<int> c1(a1, a1);
- std::list<int> c2(a2, a2);
+ std::list<int> c1;
+ std::list<int> c2;
swap(c1, c2);
assert(c1.empty());
assert(distance(c1.begin(), c1.end()) == 0);
@@ -67,61 +63,57 @@ int main(int, char**)
int a1[] = {1, 3, 7, 9, 10};
int a2[] = {0, 2, 4, 5, 6, 8, 11};
typedef test_allocator<int> A;
- std::list<int, A> c1(a1, a1+sizeof(a1)/sizeof(a1[0]), A(1));
- std::list<int, A> c2(a2, a2+sizeof(a2)/sizeof(a2[0]), A(1));
+ std::list<int, A> c1(a1, a1 + 5, A(1));
+ std::list<int, A> c2(a2, a2 + 7, A(1));
swap(c1, c2);
- assert((c1 == std::list<int, A>(a2, a2+sizeof(a2)/sizeof(a2[0]))));
+ assert((c1 == std::list<int, A>(a2, a2 + 7)));
assert(c1.get_allocator() == A(1));
- assert((c2 == std::list<int, A>(a1, a1+sizeof(a1)/sizeof(a1[0]))));
+ assert((c2 == std::list<int, A>(a1, a1 + 5)));
assert(c2.get_allocator() == A(1));
}
{
int a1[] = {1, 3, 7, 9, 10};
int a2[] = {0, 2, 4, 5, 6, 8, 11};
typedef other_allocator<int> A;
- std::list<int, A> c1(a1, a1+sizeof(a1)/sizeof(a1[0]), A(1));
- std::list<int, A> c2(a2, a2+sizeof(a2)/sizeof(a2[0]), A(2));
+ std::list<int, A> c1(a1, a1 + 5, A(1));
+ std::list<int, A> c2(a2, a2 + 7, A(2));
swap(c1, c2);
- assert((c1 == std::list<int, A>(a2, a2+sizeof(a2)/sizeof(a2[0]))));
+ assert((c1 == std::list<int, A>(a2, a2 + 7)));
assert(c1.get_allocator() == A(2));
- assert((c2 == std::list<int, A>(a1, a1+sizeof(a1)/sizeof(a1[0]))));
+ assert((c2 == std::list<int, A>(a1, a1 + 5)));
assert(c2.get_allocator() == A(1));
}
#if TEST_STD_VER >= 11
{
int a1[] = {1, 3, 7, 9, 10};
int a2[] = {0, 2, 4, 5, 6, 8, 11};
- std::list<int, min_allocator<int>> c1(a1, a1+sizeof(a1)/sizeof(a1[0]));
- std::list<int, min_allocator<int>> c2(a2, a2+sizeof(a2)/sizeof(a2[0]));
+ std::list<int, min_allocator<int>> c1(a1, a1 + 5);
+ std::list<int, min_allocator<int>> c2(a2, a2 + 7);
swap(c1, c2);
- assert((c1 == std::list<int, min_allocator<int>>(a2, a2+sizeof(a2)/sizeof(a2[0]))));
- assert((c2 == std::list<int, min_allocator<int>>(a1, a1+sizeof(a1)/sizeof(a1[0]))));
+ assert((c1 == std::list<int, min_allocator<int>>(a2, a2 + 7)));
+ assert((c2 == std::list<int, min_allocator<int>>(a1, a1 + 5)));
}
{
- int a1[] = {1, 3, 7, 9, 10};
int a2[] = {0, 2, 4, 5, 6, 8, 11};
- std::list<int, min_allocator<int>> c1(a1, a1);
- std::list<int, min_allocator<int>> c2(a2, a2+sizeof(a2)/sizeof(a2[0]));
+ std::list<int, min_allocator<int>> c1;
+ std::list<int, min_allocator<int>> c2(a2, a2 + 7);
swap(c1, c2);
- assert((c1 == std::list<int, min_allocator<int>>(a2, a2+sizeof(a2)/sizeof(a2[0]))));
+ assert((c1 == std::list<int, min_allocator<int>>(a2, a2 + 7)));
assert(c2.empty());
assert(distance(c2.begin(), c2.end()) == 0);
}
{
int a1[] = {1, 3, 7, 9, 10};
- int a2[] = {0, 2, 4, 5, 6, 8, 11};
- std::list<int, min_allocator<int>> c1(a1, a1+sizeof(a1)/sizeof(a1[0]));
- std::list<int, min_allocator<int>> c2(a2, a2);
+ std::list<int, min_allocator<int>> c1(a1, a1 + 5);
+ std::list<int, min_allocator<int>> c2;
swap(c1, c2);
assert(c1.empty());
assert(distance(c1.begin(), c1.end()) == 0);
- assert((c2 == std::list<int, min_allocator<int>>(a1, a1+sizeof(a1)/sizeof(a1[0]))));
+ assert((c2 == std::list<int, min_allocator<int>>(a1, a1 + 5)));
}
{
- int a1[] = {1, 3, 7, 9, 10};
- int a2[] = {0, 2, 4, 5, 6, 8, 11};
- std::list<int, min_allocator<int>> c1(a1, a1);
- std::list<int, min_allocator<int>> c2(a2, a2);
+ std::list<int, min_allocator<int>> c1;
+ std::list<int, min_allocator<int>> c2;
swap(c1, c2);
assert(c1.empty());
assert(distance(c1.begin(), c1.end()) == 0);
@@ -132,15 +124,15 @@ int main(int, char**)
int a1[] = {1, 3, 7, 9, 10};
int a2[] = {0, 2, 4, 5, 6, 8, 11};
typedef min_allocator<int> A;
- std::list<int, A> c1(a1, a1+sizeof(a1)/sizeof(a1[0]), A());
- std::list<int, A> c2(a2, a2+sizeof(a2)/sizeof(a2[0]), A());
+ std::list<int, A> c1(a1, a1 + 5, A());
+ std::list<int, A> c2(a2, a2 + 7, A());
swap(c1, c2);
- assert((c1 == std::list<int, A>(a2, a2+sizeof(a2)/sizeof(a2[0]))));
+ assert((c1 == std::list<int, A>(a2, a2 + 7)));
assert(c1.get_allocator() == A());
- assert((c2 == std::list<int, A>(a1, a1+sizeof(a1)/sizeof(a1[0]))));
+ assert((c2 == std::list<int, A>(a1, a1 + 5)));
assert(c2.get_allocator() == A());
}
#endif
- return 0;
+ return 0;
}
More information about the libcxx-commits
mailing list