forked from OSchip/llvm-project
EricQWF's code coverage work showed that none of the libc++ tests were exercising some code in vector<bool>. Add more tests in an attempt to get better coverage
llvm-svn: 221644
This commit is contained in:
parent
7eb9091e42
commit
a773ab1d8d
|
@ -33,7 +33,7 @@ int main()
|
|||
assert(v[j] == 0);
|
||||
for (int k = 0; k < N; ++j, ++k)
|
||||
assert(v[j] == a[k]);
|
||||
for (; j < 105; ++j)
|
||||
for (; j < v.size(); ++j)
|
||||
assert(v[j] == 0);
|
||||
}
|
||||
{
|
||||
|
@ -52,6 +52,43 @@ int main()
|
|||
for (; j < 105; ++j)
|
||||
assert(v[j] == 0);
|
||||
}
|
||||
{
|
||||
std::vector<bool> v(100);
|
||||
while(v.size() < v.capacity()) v.push_back(false);
|
||||
size_t sz = v.size();
|
||||
bool a[] = {1, 0, 0, 1, 1};
|
||||
const unsigned N = sizeof(a)/sizeof(a[0]);
|
||||
std::vector<bool>::iterator i = v.insert(v.cbegin() + 10, forward_iterator<const bool*>(a),
|
||||
forward_iterator<const bool*>(a+N));
|
||||
assert(v.size() == sz + N);
|
||||
assert(i == v.begin() + 10);
|
||||
int j;
|
||||
for (j = 0; j < 10; ++j)
|
||||
assert(v[j] == 0);
|
||||
for (int k = 0; k < N; ++j, ++k)
|
||||
assert(v[j] == a[k]);
|
||||
for (; j < v.size(); ++j)
|
||||
assert(v[j] == 0);
|
||||
}
|
||||
{
|
||||
std::vector<bool> v(100);
|
||||
while(v.size() < v.capacity()) v.push_back(false);
|
||||
v.pop_back(); v.pop_back(); v.pop_back();
|
||||
size_t sz = v.size();
|
||||
bool a[] = {1, 0, 0, 1, 1};
|
||||
const unsigned N = sizeof(a)/sizeof(a[0]);
|
||||
std::vector<bool>::iterator i = v.insert(v.cbegin() + 10, forward_iterator<const bool*>(a),
|
||||
forward_iterator<const bool*>(a+N));
|
||||
assert(v.size() == sz + N);
|
||||
assert(i == v.begin() + 10);
|
||||
int j;
|
||||
for (j = 0; j < 10; ++j)
|
||||
assert(v[j] == 0);
|
||||
for (int k = 0; k < N; ++j, ++k)
|
||||
assert(v[j] == a[k]);
|
||||
for (; j < v.size(); ++j)
|
||||
assert(v[j] == 0);
|
||||
}
|
||||
#if __cplusplus >= 201103L
|
||||
{
|
||||
std::vector<bool, min_allocator<bool>> v(100);
|
||||
|
@ -66,7 +103,7 @@ int main()
|
|||
assert(v[j] == 0);
|
||||
for (int k = 0; k < N; ++j, ++k)
|
||||
assert(v[j] == a[k]);
|
||||
for (; j < 105; ++j)
|
||||
for (; j < v.size(); ++j)
|
||||
assert(v[j] == 0);
|
||||
}
|
||||
{
|
||||
|
@ -82,7 +119,7 @@ int main()
|
|||
assert(v[j] == 0);
|
||||
for (int k = 0; k < N; ++j, ++k)
|
||||
assert(v[j] == a[k]);
|
||||
for (; j < 105; ++j)
|
||||
for (; j < v.size(); ++j)
|
||||
assert(v[j] == 0);
|
||||
}
|
||||
#endif
|
||||
|
|
|
@ -29,7 +29,22 @@ int main()
|
|||
assert(v[j] == 0);
|
||||
for (; j < 15; ++j)
|
||||
assert(v[j] == 1);
|
||||
for (++j; j < 105; ++j)
|
||||
for (++j; j < v.size(); ++j)
|
||||
assert(v[j] == 0);
|
||||
}
|
||||
{
|
||||
std::vector<bool> v(100);
|
||||
while(v.size() < v.capacity()) v.push_back(false);
|
||||
size_t sz = v.size();
|
||||
std::vector<bool>::iterator i = v.insert(v.cbegin() + 10, 5, 1);
|
||||
assert(v.size() == sz + 5);
|
||||
assert(i == v.begin() + 10);
|
||||
int j;
|
||||
for (j = 0; j < 10; ++j)
|
||||
assert(v[j] == 0);
|
||||
for (; j < 15; ++j)
|
||||
assert(v[j] == 1);
|
||||
for (++j; j < v.size(); ++j)
|
||||
assert(v[j] == 0);
|
||||
}
|
||||
#if __cplusplus >= 201103L
|
||||
|
@ -43,7 +58,7 @@ int main()
|
|||
assert(v[j] == 0);
|
||||
for (; j < 15; ++j)
|
||||
assert(v[j] == 1);
|
||||
for (++j; j < 105; ++j)
|
||||
for (++j; j < v.size(); ++j)
|
||||
assert(v[j] == 0);
|
||||
}
|
||||
#endif
|
||||
|
|
|
@ -28,7 +28,21 @@ int main()
|
|||
for (j = 0; j < 10; ++j)
|
||||
assert(v[j] == 0);
|
||||
assert(v[j] == 1);
|
||||
for (++j; j < 101; ++j)
|
||||
for (++j; j < v.size(); ++j)
|
||||
assert(v[j] == 0);
|
||||
}
|
||||
{
|
||||
std::vector<bool> v(100);
|
||||
while(v.size() < v.capacity()) v.push_back(false);
|
||||
size_t sz = v.size();
|
||||
std::vector<bool>::iterator i = v.insert(v.cbegin() + 10, 1);
|
||||
assert(v.size() == sz + 1);
|
||||
assert(i == v.begin() + 10);
|
||||
int j;
|
||||
for (j = 0; j < 10; ++j)
|
||||
assert(v[j] == 0);
|
||||
assert(v[j] == 1);
|
||||
for (++j; j < v.size(); ++j)
|
||||
assert(v[j] == 0);
|
||||
}
|
||||
#if __cplusplus >= 201103L
|
||||
|
@ -41,7 +55,7 @@ int main()
|
|||
for (j = 0; j < 10; ++j)
|
||||
assert(v[j] == 0);
|
||||
assert(v[j] == 1);
|
||||
for (++j; j < 101; ++j)
|
||||
for (++j; j < v.size(); ++j)
|
||||
assert(v[j] == 0);
|
||||
}
|
||||
#endif
|
||||
|
|
|
@ -27,6 +27,10 @@ int main()
|
|||
v.resize(200);
|
||||
assert(v.size() == 200);
|
||||
assert(v.capacity() >= 200);
|
||||
v.reserve(400);
|
||||
v.resize(300); // check the case when resizing and we already have room
|
||||
assert(v.size() == 300);
|
||||
assert(v.capacity() >= 400);
|
||||
}
|
||||
#if __cplusplus >= 201103L
|
||||
{
|
||||
|
@ -37,6 +41,10 @@ int main()
|
|||
v.resize(200);
|
||||
assert(v.size() == 200);
|
||||
assert(v.capacity() >= 200);
|
||||
v.reserve(400);
|
||||
v.resize(300); // check the case when resizing and we already have room
|
||||
assert(v.size() == 300);
|
||||
assert(v.capacity() >= 400);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue