Skip to content

Commit ad6fce6

Browse files
committed
Merge #10844: Use range based for loop
d0413c6 Use range based for loop (René Nyffenegger) Pull request description: Instead of iterating over 0 .. 1 and then deciding on an actual desired value, use a range based for loop for the desired value. Tree-SHA512: 0a7a4a80516c9f16cf97fa7d257088b8386360e19b93c4deac3d745b6270ea452c513821686d7d14a159a235763e034f9b14eef222ca15f7eb71c37bd1c2c380
2 parents 99c7db8 + d0413c6 commit ad6fce6

File tree

1 file changed

+5
-18
lines changed

1 file changed

+5
-18
lines changed

src/test/dbwrapper_tests.cpp

Lines changed: 5 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,7 @@ BOOST_FIXTURE_TEST_SUITE(dbwrapper_tests, BasicTestingSetup)
2424
BOOST_AUTO_TEST_CASE(dbwrapper)
2525
{
2626
// Perform tests both obfuscated and non-obfuscated.
27-
for (int i = 0; i < 2; i++) {
28-
bool obfuscate = (bool)i;
27+
for (bool obfuscate : {false, true}) {
2928
fs::path ph = fs::temp_directory_path() / fs::unique_path();
3029
CDBWrapper dbw(ph, (1 << 20), true, false, obfuscate);
3130
char key = 'k';
@@ -45,8 +44,7 @@ BOOST_AUTO_TEST_CASE(dbwrapper)
4544
BOOST_AUTO_TEST_CASE(dbwrapper_batch)
4645
{
4746
// Perform tests both obfuscated and non-obfuscated.
48-
for (int i = 0; i < 2; i++) {
49-
bool obfuscate = (bool)i;
47+
for (bool obfuscate : {false, true}) {
5048
fs::path ph = fs::temp_directory_path() / fs::unique_path();
5149
CDBWrapper dbw(ph, (1 << 20), true, false, obfuscate);
5250

@@ -82,8 +80,7 @@ BOOST_AUTO_TEST_CASE(dbwrapper_batch)
8280
BOOST_AUTO_TEST_CASE(dbwrapper_iterator)
8381
{
8482
// Perform tests both obfuscated and non-obfuscated.
85-
for (int i = 0; i < 2; i++) {
86-
bool obfuscate = (bool)i;
83+
for (bool obfuscate : {false, true}) {
8784
fs::path ph = fs::temp_directory_path() / fs::unique_path();
8885
CDBWrapper dbw(ph, (1 << 20), true, false, obfuscate);
8986

@@ -211,12 +208,7 @@ BOOST_AUTO_TEST_CASE(iterator_ordering)
211208
}
212209

213210
std::unique_ptr<CDBIterator> it(const_cast<CDBWrapper&>(dbw).NewIterator());
214-
for (int c=0; c<2; ++c) {
215-
int seek_start;
216-
if (c == 0)
217-
seek_start = 0x00;
218-
else
219-
seek_start = 0x80;
211+
for (int seek_start : {0x00, 0x80}) {
220212
it->Seek((uint8_t)seek_start);
221213
for (int x=seek_start; x<256; ++x) {
222214
uint8_t key;
@@ -287,12 +279,7 @@ BOOST_AUTO_TEST_CASE(iterator_string_ordering)
287279
}
288280

289281
std::unique_ptr<CDBIterator> it(const_cast<CDBWrapper&>(dbw).NewIterator());
290-
for (int c=0; c<2; ++c) {
291-
int seek_start;
292-
if (c == 0)
293-
seek_start = 0;
294-
else
295-
seek_start = 5;
282+
for (int seek_start : {0, 5}) {
296283
snprintf(buf, sizeof(buf), "%d", seek_start);
297284
StringContentsSerializer seek_key(buf);
298285
it->Seek(seek_key);

0 commit comments

Comments
 (0)