Skip to content

Commit bffdc24

Browse files
committed
[libc++] Minor cleanup in the test suite
1 parent 5a3077f commit bffdc24

File tree

3 files changed

+23
-26
lines changed

3 files changed

+23
-26
lines changed

libcxx/test/libcxx/containers/gnu_cxx/hash_map.pass.cpp

+1
Original file line numberDiff line numberDiff line change
@@ -35,4 +35,5 @@ void test_default_does_not_allocate() {
3535

3636
int main(int, char**) {
3737
test_default_does_not_allocate();
38+
return 0;
3839
}

libcxx/test/libcxx/containers/gnu_cxx/hash_set.pass.cpp

+1
Original file line numberDiff line numberDiff line change
@@ -35,4 +35,5 @@ void test_default_does_not_allocate() {
3535

3636
int main(int, char**) {
3737
test_default_does_not_allocate();
38+
return 0;
3839
}

libcxx/test/std/utilities/template.bitset/bitset.cons/string_ctor.pass.cpp

+21-26
Original file line numberDiff line numberDiff line change
@@ -9,24 +9,20 @@
99
// test bitset(string, pos, n, zero, one);
1010

1111
#include <bitset>
12-
#include <cassert>
1312
#include <algorithm> // for 'min' and 'max'
13+
#include <cassert>
1414
#include <stdexcept> // for 'invalid_argument'
15+
#include <string>
1516

1617
#include "test_macros.h"
1718

18-
#if defined(TEST_COMPILER_C1XX)
19-
#pragma warning(disable: 6294) // Ill-defined for-loop: initial condition does not satisfy test. Loop body not executed.
20-
#endif
21-
2219
template <std::size_t N>
23-
void test_string_ctor()
24-
{
20+
void test_string_ctor() {
2521
#ifndef TEST_HAS_NO_EXCEPTIONS
2622
{
2723
try {
28-
std::string str("xxx1010101010xxxx");
29-
std::bitset<N> v(str, str.size()+1, 10);
24+
std::string s("xxx1010101010xxxx");
25+
std::bitset<N> v(s, s.size()+1, 10);
3026
assert(false);
3127
}
3228
catch (std::out_of_range&)
@@ -35,8 +31,8 @@ void test_string_ctor()
3531
}
3632
{
3733
try {
38-
std::string str("xxx1010101010xxxx");
39-
std::bitset<N> v(str, 2, 10);
34+
std::string s("xxx1010101010xxxx");
35+
std::bitset<N> v(s, 2, 10);
4036
assert(false);
4137
}
4238
catch (std::invalid_argument&)
@@ -45,8 +41,8 @@ void test_string_ctor()
4541
}
4642
{
4743
try {
48-
std::string str("xxxbababababaxxxx");
49-
std::bitset<N> v(str, 2, 10, 'a', 'b');
44+
std::string s("xxxbababababaxxxx");
45+
std::bitset<N> v(s, 2, 10, 'a', 'b');
5046
assert(false);
5147
}
5248
catch (std::invalid_argument&)
@@ -55,21 +51,21 @@ void test_string_ctor()
5551
}
5652
#endif // TEST_HAS_NO_EXCEPTIONS
5753
{
58-
std::string str("xxx1010101010xxxx");
59-
std::bitset<N> v(str, 3, 10);
60-
std::size_t M = std::min<std::size_t>(N, 10);
54+
std::string s("xxx1010101010xxxx");
55+
std::bitset<N> v(s, 3, 10);
56+
std::size_t M = std::min<std::size_t>(v.size(), 10);
6157
for (std::size_t i = 0; i < M; ++i)
62-
assert(v[i] == (str[3 + M - 1 - i] == '1'));
63-
for (std::size_t i = 10; i < N; ++i)
58+
assert(v[i] == (s[3 + M - 1 - i] == '1'));
59+
for (std::size_t i = 10; i < v.size(); ++i)
6460
assert(v[i] == false);
6561
}
6662
{
67-
std::string str("xxxbababababaxxxx");
68-
std::bitset<N> v(str, 3, 10, 'a', 'b');
69-
std::size_t M = std::min<std::size_t>(N, 10);
63+
std::string s("xxxbababababaxxxx");
64+
std::bitset<N> v(s, 3, 10, 'a', 'b');
65+
std::size_t M = std::min<std::size_t>(v.size(), 10);
7066
for (std::size_t i = 0; i < M; ++i)
71-
assert(v[i] == (str[3 + M - 1 - i] == 'b'));
72-
for (std::size_t i = 10; i < N; ++i)
67+
assert(v[i] == (s[3 + M - 1 - i] == 'b'));
68+
for (std::size_t i = 10; i < v.size(); ++i)
7369
assert(v[i] == false);
7470
}
7571
}
@@ -86,8 +82,7 @@ void test_for_non_eager_instantiation() {
8682
static_assert(!std::is_constructible<std::bitset<3>, Nonsense*, size_t, Nonsense&, Nonsense&>::value, "");
8783
}
8884

89-
int main(int, char**)
90-
{
85+
int main(int, char**) {
9186
test_string_ctor<0>();
9287
test_string_ctor<1>();
9388
test_string_ctor<31>();
@@ -99,5 +94,5 @@ int main(int, char**)
9994
test_string_ctor<1000>();
10095
test_for_non_eager_instantiation();
10196

102-
return 0;
97+
return 0;
10398
}

0 commit comments

Comments
 (0)