Skip to content

Commit 17ab5f2

Browse files
committed
fix lint
1 parent e8b0725 commit 17ab5f2

File tree

4 files changed

+81
-52
lines changed

4 files changed

+81
-52
lines changed

.vscode/tasks.json

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,9 @@
1313
]
1414
},
1515
{
16-
"label": "build_dbg",
16+
"label": "build-dev",
1717
"type": "shell",
18-
"command": "make config=dbg",
18+
"command": "make config=dev",
1919
"group": "build",
2020
"problemMatcher": [
2121
"$gcc"
@@ -54,17 +54,17 @@
5454
"problemMatcher": []
5555
},
5656
{
57-
"label": "test_dbg",
57+
"label": "test-dev",
5858
"type": "shell",
59-
"command": "make test config=dbg",
60-
"dependsOn": "build_dbg",
59+
"command": "make test config=dev",
60+
"dependsOn": "build-dev",
6161
"group": "build",
6262
"problemMatcher": []
6363
},
6464
{
6565
"label": "format",
6666
"type": "shell",
67-
"command": "make apply-format",
67+
"command": "make format",
6868
"group": "build",
6969
"problemMatcher": []
7070
}

src/tst/check.cpp

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,11 @@ namespace {
3434
const char* const default_fail_message = "check(false)";
3535
} // namespace
3636

37-
void tst::check(bool c, const std::function<void(std::ostream&)>& print, utki::source_location&& source_location)
37+
void tst::check(
38+
bool c, //
39+
const std::function<void(std::ostream&)>& print,
40+
utki::source_location source_location
41+
)
3842
{
3943
if (c) {
4044
return;
@@ -84,7 +88,10 @@ check_result::~check_result() noexcept(false)
8488
throw check_failed(std::move(message), std::move(this->source_location));
8589
}
8690

87-
check_result tst::check(bool c, utki::source_location&& source_location)
91+
check_result tst::check(
92+
bool c, //
93+
utki::source_location source_location
94+
)
8895
{
8996
#ifdef DEBUG
9097
// This piece of code is just to test move constructor of check_result,
@@ -93,11 +100,13 @@ check_result tst::check(bool c, utki::source_location&& source_location)
93100
// because check_result throws from destructor and should not be normally
94101
// constructed by users explicitly to prevent unexpected behavior.
95102
{
96-
check_result cr(std::move(source_location));
103+
check_result cr(source_location);
97104
ASSERT(cr.failed)
98105

99106
check_result mcr{std::move(cr)};
100107
ASSERT(mcr.failed)
108+
109+
// NOLINTNEXTLINE(bugprone-use-after-move, "intentionally for testing")
101110
ASSERT(!cr.failed)
102111

103112
mcr.failed = false;
@@ -108,5 +117,5 @@ check_result tst::check(bool c, utki::source_location&& source_location)
108117
return {};
109118
}
110119

111-
return std::move(source_location);
120+
return {std::move(source_location)};
112121
}

src/tst/check.hpp

Lines changed: 49 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -48,9 +48,9 @@ namespace tst {
4848
* @param source_location - object with source file:line information.
4949
*/
5050
void check(
51-
bool c,
51+
bool c, //
5252
const std::function<void(std::ostream&)>& print,
53-
utki::source_location&& source_location
53+
utki::source_location source_location
5454
#if CFG_CPP >= 20
5555
= utki::std_source_location::current()
5656
#endif
@@ -67,15 +67,19 @@ void check(
6767
*/
6868
template <class check_type>
6969
void check(
70-
const check_type& p,
70+
const check_type& p, //
7171
const std::function<void(std::ostream&)>& print,
72-
utki::source_location&& source_location
72+
utki::source_location source_location
7373
#if CFG_CPP >= 20
7474
= utki::std_source_location::current()
7575
#endif
7676
)
7777
{
78-
check(static_cast<bool>(p), print, std::move(source_location));
78+
check(
79+
static_cast<bool>(p), //
80+
print,
81+
std::move(source_location)
82+
);
7983
}
8084

8185
/**
@@ -88,15 +92,15 @@ void check(
8892
*/
8993
class check_result
9094
{
91-
friend check_result check(bool, utki::source_location&&);
95+
friend check_result check(bool, utki::source_location);
9296

9397
bool failed = false;
9498
utki::source_location source_location;
9599
std::stringstream ss;
96100

97101
check_result() = default;
98102

99-
check_result(utki::source_location&& source_location) :
103+
check_result(utki::source_location source_location) :
100104
failed(true),
101105
source_location(std::move(source_location))
102106
{}
@@ -142,7 +146,7 @@ class check_result
142146
*/
143147
check_result check(
144148
bool c,
145-
utki::source_location&& source_location
149+
utki::source_location source_location
146150
#if CFG_CPP >= 20
147151
= utki::std_source_location::current()
148152
#endif
@@ -158,13 +162,16 @@ check_result check(
158162
template <class check_type>
159163
check_result check(
160164
const check_type& p,
161-
utki::source_location&& source_location
165+
utki::source_location source_location
162166
#if CFG_CPP >= 20
163167
= utki::std_source_location::current()
164168
#endif
165169
)
166170
{
167-
return check(static_cast<bool>(p), std::move(source_location));
171+
return check(
172+
static_cast<bool>(p), //
173+
std::move(source_location)
174+
);
168175
}
169176

170177
/**
@@ -183,7 +190,7 @@ void check_eq(
183190
const parameter_type& a,
184191
const parameter_type& b,
185192
const std::function<void(std::ostream&)>& print,
186-
utki::source_location&& source_location
193+
utki::source_location source_location
187194
#if CFG_CPP >= 20
188195
= utki::std_source_location::current()
189196
#endif
@@ -212,9 +219,9 @@ void check_eq(
212219
*/
213220
template <class parameter_type>
214221
check_result check_eq(
215-
const parameter_type& a,
222+
const parameter_type& a, //
216223
const parameter_type& b,
217-
utki::source_location&& source_location
224+
utki::source_location source_location
218225
#if CFG_CPP >= 20
219226
= utki::std_source_location::current()
220227
#endif
@@ -238,10 +245,10 @@ check_result check_eq(
238245
*/
239246
template <class parameter_type>
240247
void check_ne(
241-
const parameter_type& a,
248+
const parameter_type& a, //
242249
const parameter_type& b,
243250
const std::function<void(std::ostream&)>& print,
244-
utki::source_location&& source_location
251+
utki::source_location source_location
245252
#if CFG_CPP >= 20
246253
= utki::std_source_location::current()
247254
#endif
@@ -270,9 +277,9 @@ void check_ne(
270277
*/
271278
template <class parameter_type>
272279
check_result check_ne(
273-
const parameter_type& a,
280+
const parameter_type& a, //
274281
const parameter_type& b,
275-
utki::source_location&& source_location
282+
utki::source_location source_location
276283
#if CFG_CPP >= 20
277284
= utki::std_source_location::current()
278285
#endif
@@ -296,10 +303,10 @@ check_result check_ne(
296303
*/
297304
template <class parameter_type>
298305
void check_lt(
299-
const parameter_type& a,
306+
const parameter_type& a, //
300307
const parameter_type& b,
301308
const std::function<void(std::ostream&)>& print,
302-
utki::source_location&& source_location
309+
utki::source_location source_location
303310
#if CFG_CPP >= 20
304311
= utki::std_source_location::current()
305312
#endif
@@ -328,9 +335,9 @@ void check_lt(
328335
*/
329336
template <class parameter_type>
330337
check_result check_lt(
331-
const parameter_type& a,
338+
const parameter_type& a, //
332339
const parameter_type& b,
333-
utki::source_location&& source_location
340+
utki::source_location source_location
334341
#if CFG_CPP >= 20
335342
= utki::std_source_location::current()
336343
#endif
@@ -354,10 +361,10 @@ check_result check_lt(
354361
*/
355362
template <class parameter_type>
356363
void check_gt(
357-
const parameter_type& a,
364+
const parameter_type& a, //
358365
const parameter_type& b,
359366
const std::function<void(std::ostream&)>& print,
360-
utki::source_location&& source_location
367+
utki::source_location source_location
361368
#if CFG_CPP >= 20
362369
= utki::std_source_location::current()
363370
#endif
@@ -386,9 +393,9 @@ void check_gt(
386393
*/
387394
template <class parameter_type>
388395
check_result check_gt(
389-
const parameter_type& a,
396+
const parameter_type& a, //
390397
const parameter_type& b,
391-
utki::source_location&& source_location
398+
utki::source_location source_location
392399
#if CFG_CPP >= 20
393400
= utki::std_source_location::current()
394401
#endif
@@ -412,10 +419,10 @@ check_result check_gt(
412419
*/
413420
template <class parameter_type>
414421
void check_le(
415-
const parameter_type& a,
422+
const parameter_type& a, //
416423
const parameter_type& b,
417424
const std::function<void(std::ostream&)>& print,
418-
utki::source_location&& source_location
425+
utki::source_location source_location
419426
#if CFG_CPP >= 20
420427
= utki::std_source_location::current()
421428
#endif
@@ -444,15 +451,18 @@ void check_le(
444451
*/
445452
template <class parameter_type>
446453
check_result check_le(
447-
const parameter_type& a,
454+
const parameter_type& a, //
448455
const parameter_type& b,
449-
utki::source_location&& source_location
456+
utki::source_location source_location
450457
#if CFG_CPP >= 20
451458
= utki::std_source_location::current()
452459
#endif
453460
)
454461
{
455-
auto ret = check(a <= b, std::move(source_location));
462+
auto ret = check(
463+
a <= b, //
464+
std::move(source_location)
465+
);
456466
ret << "check_le(" << a << ", " << b << ")";
457467
return ret;
458468
}
@@ -470,17 +480,17 @@ check_result check_le(
470480
*/
471481
template <class parameter_type>
472482
void check_ge(
473-
const parameter_type& a,
483+
const parameter_type& a, //
474484
const parameter_type& b,
475485
const std::function<void(std::ostream&)>& print,
476-
utki::source_location&& source_location
486+
utki::source_location source_location
477487
#if CFG_CPP >= 20
478488
= utki::std_source_location::current()
479489
#endif
480490
)
481491
{
482492
check(
483-
a >= b,
493+
a >= b, //
484494
[&](auto& o) {
485495
o << "check_ge(" << a << ", " << b << ")";
486496
if (print) {
@@ -502,15 +512,18 @@ void check_ge(
502512
*/
503513
template <class parameter_type>
504514
check_result check_ge(
505-
const parameter_type& a,
515+
const parameter_type& a, //
506516
const parameter_type& b,
507-
utki::source_location&& source_location
517+
utki::source_location source_location
508518
#if CFG_CPP >= 20
509519
= utki::std_source_location::current()
510520
#endif
511521
)
512522
{
513-
auto ret = check(a >= b, std::move(source_location));
523+
auto ret = check(
524+
a >= b, //
525+
std::move(source_location)
526+
);
514527
ret << "check_ge(" << a << ", " << b << ")";
515528
return ret;
516529
}

src/tst/runners_pool.hxx

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,11 @@ SOFTWARE.
2626

2727
#pragma once
2828

29+
#include <algorithm>
2930
#include <vector>
3031

32+
#include <utki/debug.hpp>
33+
3134
#include "runner.hxx"
3235

3336
namespace tst {
@@ -62,12 +65,16 @@ public:
6265

6366
void free_runner(runner* r)
6467
{
65-
ASSERT(
66-
std::find(this->free_runners.begin(), this->free_runners.end(), r) == this->free_runners.end(),
67-
[](auto& o) {
68-
o << "runner is already freed";
69-
}
70-
)
68+
utki::run_debug([&]() {
69+
auto i = std::find(this->free_runners.begin(), this->free_runners.end(), r);
70+
utki::assert(
71+
i == this->free_runners.end(),
72+
[](auto& o) {
73+
o << "runner is already freed";
74+
},
75+
SL
76+
);
77+
});
7178
this->free_runners.push_back(r);
7279
}
7380

0 commit comments

Comments
 (0)