Skip to content

Commit 692382f

Browse files
author
NMuleo
committed
indentation clang-format-18
1 parent dd0533e commit 692382f

12 files changed

+77
-76
lines changed

include/snitch/snitch_expression.hpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -204,7 +204,7 @@ struct extracted_unary_expression {
204204
// Operators we want to decompose.
205205
#define EXPR_OPERATOR(OP, OP_TYPE) \
206206
template<typename U> \
207-
constexpr extracted_binary_expression<Expected, T, OP_TYPE, U> operator OP(const U& rhs) \
207+
constexpr extracted_binary_expression<Expected, T, OP_TYPE, U> operator OP(const U & rhs) \
208208
const noexcept { \
209209
return {type, expected, lhs, rhs}; \
210210
}

include/snitch/snitch_macros_test_case.hpp

+16-14
Original file line numberDiff line numberDiff line change
@@ -15,26 +15,28 @@
1515
# define SNITCH_TEST_CASE(...) \
1616
SNITCH_TEST_CASE_IMPL(SNITCH_MACRO_CONCAT(test_fun_, __COUNTER__), __VA_ARGS__)
1717

18-
# define SNITCH_TEMPLATE_LIST_TEST_CASE_IMPL(ID, NAME, TAGS, TYPES) \
19-
template<typename TestType> \
20-
static void ID(); \
21-
static const char* SNITCH_MACRO_CONCAT(test_id_, __COUNTER__) [[maybe_unused]] = \
22-
snitch::tests.add_with_type_list<TYPES>( \
23-
{NAME, TAGS}, SNITCH_CURRENT_LOCATION, []<typename TestType>() { ID<TestType>(); });\
24-
template<typename TestType> \
18+
# define SNITCH_TEMPLATE_LIST_TEST_CASE_IMPL(ID, NAME, TAGS, TYPES) \
19+
template<typename TestType> \
20+
static void ID(); \
21+
static const char* SNITCH_MACRO_CONCAT(test_id_, __COUNTER__) [[maybe_unused]] = \
22+
snitch::tests.add_with_type_list<TYPES>( \
23+
{NAME, TAGS}, SNITCH_CURRENT_LOCATION, \
24+
[]<typename TestType>() { ID<TestType>(); }); \
25+
template<typename TestType> \
2526
void ID()
2627

2728
# define SNITCH_TEMPLATE_LIST_TEST_CASE(NAME, TAGS, TYPES) \
2829
SNITCH_TEMPLATE_LIST_TEST_CASE_IMPL( \
2930
SNITCH_MACRO_CONCAT(test_fun_, __COUNTER__), NAME, TAGS, TYPES)
3031

31-
# define SNITCH_TEMPLATE_TEST_CASE_IMPL(ID, NAME, TAGS, ...) \
32-
template<typename TestType> \
33-
static void ID(); \
34-
static const char* SNITCH_MACRO_CONCAT(test_id_, __COUNTER__) [[maybe_unused]] = \
35-
snitch::tests.add_with_types<__VA_ARGS__>( \
36-
{NAME, TAGS}, SNITCH_CURRENT_LOCATION, []<typename TestType>() { ID<TestType>(); });\
37-
template<typename TestType> \
32+
# define SNITCH_TEMPLATE_TEST_CASE_IMPL(ID, NAME, TAGS, ...) \
33+
template<typename TestType> \
34+
static void ID(); \
35+
static const char* SNITCH_MACRO_CONCAT(test_id_, __COUNTER__) [[maybe_unused]] = \
36+
snitch::tests.add_with_types<__VA_ARGS__>( \
37+
{NAME, TAGS}, SNITCH_CURRENT_LOCATION, \
38+
[]<typename TestType>() { ID<TestType>(); }); \
39+
template<typename TestType> \
3840
void ID()
3941

4042
# define SNITCH_TEMPLATE_TEST_CASE(NAME, TAGS, ...) \

include/snitch/snitch_matcher.hpp

+5-7
Original file line numberDiff line numberDiff line change
@@ -16,18 +16,16 @@ enum class match_status { failed, matched };
1616
namespace snitch {
1717
template<typename T, typename U>
1818
concept matcher_for = requires(const T& m, const U& value) {
19-
{ m.match(value) } -> convertible_to<bool>;
20-
{
21-
m.describe_match(value, matchers::match_status{})
22-
} -> convertible_to<std::string_view>;
23-
};
19+
{ m.match(value) } -> convertible_to<bool>;
20+
{ m.describe_match(value, matchers::match_status{}) } -> convertible_to<std::string_view>;
21+
};
2422
} // namespace snitch
2523

2624
namespace snitch::impl {
2725
template<typename T>
2826
concept exception_with_what = requires(const T& e) {
29-
{ e.what() } -> convertible_to<std::string_view>;
30-
};
27+
{ e.what() } -> convertible_to<std::string_view>;
28+
};
3129

3230
template<typename T, typename M>
3331
[[nodiscard]] constexpr auto match(T&& value, M&& matcher) noexcept {

include/snitch/snitch_registry.hpp

+5-5
Original file line numberDiff line numberDiff line change
@@ -108,11 +108,11 @@ struct registered_reporter {
108108
};
109109

110110
template<typename T>
111-
concept reporter_type =
112-
requires(registry& reg) { T{reg}; } &&
113-
requires(T& rep, registry& reg, std::string_view k, std::string_view v) {
114-
{ rep.configure(reg, k, v) } -> convertible_to<bool>;
115-
} && requires(T& rep, const registry& reg, const event::data& e) { rep.report(reg, e); };
111+
concept reporter_type = requires(registry& reg) {
112+
T{reg};
113+
} && requires(T& rep, registry& reg, std::string_view k, std::string_view v) {
114+
{ rep.configure(reg, k, v) } -> convertible_to<bool>;
115+
} && requires(T& rep, const registry& reg, const event::data& e) { rep.report(reg, e); };
116116

117117
class registry {
118118
// Contains all registered test cases.

src/snitch_main.cpp

+3-3
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@
33

44
#if SNITCH_DEFINE_MAIN
55
namespace snitch {
6-
int main(int argc, char* argv[]) {
7-
if constexpr(snitch::is_enabled) {
6+
int main(int argc, char* argv[]) {
7+
if constexpr (snitch::is_enabled) {
88
std::optional<snitch::cli::input> args = snitch::cli::parse_arguments(argc, argv);
99
if (!args) {
1010
return 1;
@@ -15,7 +15,7 @@ int main(int argc, char* argv[]) {
1515
return 0;
1616
}
1717
}
18-
}
18+
} // namespace snitch
1919

2020
SNITCH_EXPORT int main(int argc, char* argv[]) {
2121
return snitch::main(argc, argv);

src/snitch_registry.cpp

+33-33
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
#include "snitch/snitch_registry.hpp"
22

3-
# include "snitch/snitch_time.hpp"
3+
#include "snitch/snitch_time.hpp"
44

5-
# include <algorithm> // for std::sort
6-
# include <optional> // for std::optional
5+
#include <algorithm> // for std::sort
6+
#include <optional> // for std::optional
77

88
// Testing framework implementation.
99
// ---------------------------------
@@ -399,14 +399,14 @@ void register_assertion(bool success, impl::test_state& state) {
399399
++section.allowed_assertion_failure_count;
400400
}
401401

402-
# if SNITCH_WITH_EXCEPTIONS
402+
#if SNITCH_WITH_EXCEPTIONS
403403
if (state.held_info.has_value()) {
404404
for (auto& section : state.held_info.value().sections.current_section) {
405405
++section.assertion_count;
406406
++section.allowed_assertion_failure_count;
407407
}
408408
}
409-
# endif
409+
#endif
410410

411411
impl::set_state(state.test, impl::test_case_state::allowed_fail);
412412
} else {
@@ -418,14 +418,14 @@ void register_assertion(bool success, impl::test_state& state) {
418418
++section.assertion_failure_count;
419419
}
420420

421-
# if SNITCH_WITH_EXCEPTIONS
421+
#if SNITCH_WITH_EXCEPTIONS
422422
if (state.held_info.has_value()) {
423423
for (auto& section : state.held_info.value().sections.current_section) {
424424
++section.assertion_count;
425425
++section.assertion_failure_count;
426426
}
427427
}
428-
# endif
428+
#endif
429429

430430
impl::set_state(state.test, impl::test_case_state::failed);
431431
}
@@ -436,13 +436,13 @@ void register_assertion(bool success, impl::test_state& state) {
436436
++section.assertion_count;
437437
}
438438

439-
# if SNITCH_WITH_EXCEPTIONS
439+
#if SNITCH_WITH_EXCEPTIONS
440440
if (state.held_info.has_value()) {
441441
for (auto& section : state.held_info.value().sections.current_section) {
442442
++section.assertion_count;
443443
}
444444
}
445-
# endif
445+
#endif
446446
}
447447
}
448448

@@ -455,7 +455,7 @@ void report_assertion_impl(
455455

456456
register_assertion(success, state);
457457

458-
# if SNITCH_WITH_EXCEPTIONS
458+
#if SNITCH_WITH_EXCEPTIONS
459459
const bool use_held_info = (state.unhandled_exception || std::uncaught_exceptions() > 0) &&
460460
state.held_info.has_value();
461461

@@ -472,13 +472,13 @@ void report_assertion_impl(
472472
state.in_check
473473
? assertion_location{last_location.file, last_location.line, location_type::exact}
474474
: last_location;
475-
# else
475+
#else
476476
const auto captures_buffer = impl::make_capture_buffer(state.info.captures);
477477
const auto& current_section = state.info.sections.current_section;
478478
const auto& last_location = state.info.locations.back();
479479
const auto location =
480480
assertion_location{last_location.file, last_location.line, location_type::exact};
481-
# endif
481+
#endif
482482

483483
if (success) {
484484
if (r.verbose >= registry::verbosity::full) {
@@ -558,7 +558,7 @@ void registry::report_section_ended(const section& sec) noexcept {
558558

559559
const bool skipped = state.test.state == impl::test_case_state::skipped;
560560

561-
# if SNITCH_WITH_TIMINGS
561+
#if SNITCH_WITH_TIMINGS
562562
const auto duration = get_duration_in_seconds(sec.start_time, get_current_time());
563563
state.reg.report_callback(
564564
state.reg, event::section_ended{
@@ -569,7 +569,7 @@ void registry::report_section_ended(const section& sec) noexcept {
569569
.assertion_failure_count = sec.assertion_failure_count,
570570
.allowed_assertion_failure_count = sec.allowed_assertion_failure_count,
571571
.duration = duration});
572-
# else
572+
#else
573573
state.reg.report_callback(
574574
state.reg, event::section_ended{
575575
.id = sec.id,
@@ -578,7 +578,7 @@ void registry::report_section_ended(const section& sec) noexcept {
578578
.assertion_count = sec.assertion_count,
579579
.assertion_failure_count = sec.assertion_failure_count,
580580
.allowed_assertion_failure_count = sec.allowed_assertion_failure_count});
581-
# endif
581+
#endif
582582
}
583583

584584
impl::test_state registry::run(impl::test_case& test) noexcept {
@@ -610,13 +610,13 @@ impl::test_state registry::run(impl::test_case& test) noexcept {
610610
impl::test_state* previous_run = impl::try_get_current_test();
611611
impl::set_current_test(&state);
612612

613-
# if SNITCH_WITH_TIMINGS
613+
#if SNITCH_WITH_TIMINGS
614614
const auto time_start = get_current_time();
615-
# endif
615+
#endif
616616

617-
# if SNITCH_WITH_EXCEPTIONS
617+
#if SNITCH_WITH_EXCEPTIONS
618618
try {
619-
# endif
619+
#endif
620620

621621
do {
622622
// Reset section state.
@@ -640,7 +640,7 @@ impl::test_state registry::run(impl::test_case& test) noexcept {
640640
} while (!state.info.sections.levels.empty() &&
641641
state.test.state != impl::test_case_state::skipped);
642642

643-
# if SNITCH_WITH_EXCEPTIONS
643+
#if SNITCH_WITH_EXCEPTIONS
644644
state.in_check = true;
645645
report_assertion(true, "no exception caught");
646646
state.in_check = false;
@@ -660,7 +660,7 @@ impl::test_state registry::run(impl::test_case& test) noexcept {
660660
}
661661

662662
state.unhandled_exception = false;
663-
# endif
663+
#endif
664664

665665
if (state.should_fail) {
666666
state.should_fail = false;
@@ -671,12 +671,12 @@ impl::test_state registry::run(impl::test_case& test) noexcept {
671671
state.should_fail = true;
672672
}
673673

674-
# if SNITCH_WITH_TIMINGS
674+
#if SNITCH_WITH_TIMINGS
675675
state.duration = get_duration_in_seconds(time_start, get_current_time());
676-
# endif
676+
#endif
677677

678678
if (verbose >= registry::verbosity::high) {
679-
# if SNITCH_WITH_TIMINGS
679+
#if SNITCH_WITH_TIMINGS
680680
report_callback(
681681
*this, event::test_case_ended{
682682
.id = test.id,
@@ -686,7 +686,7 @@ impl::test_state registry::run(impl::test_case& test) noexcept {
686686
.allowed_assertion_failure_count = state.allowed_failures,
687687
.state = impl::convert_to_public_state(state.test.state),
688688
.duration = state.duration});
689-
# else
689+
#else
690690
report_callback(
691691
*this, event::test_case_ended{
692692
.id = test.id,
@@ -695,7 +695,7 @@ impl::test_state registry::run(impl::test_case& test) noexcept {
695695
.assertion_failure_count = state.failures,
696696
.allowed_assertion_failure_count = state.allowed_failures,
697697
.state = impl::convert_to_public_state(state.test.state)});
698-
# endif
698+
#endif
699699
}
700700

701701
impl::set_current_test(previous_run);
@@ -722,9 +722,9 @@ bool registry::run_selected_tests(
722722
std::size_t assertion_failure_count = 0;
723723
std::size_t allowed_assertion_failure_count = 0;
724724

725-
# if SNITCH_WITH_TIMINGS
725+
#if SNITCH_WITH_TIMINGS
726726
const auto time_start = get_current_time();
727-
# endif
727+
#endif
728728

729729
for (impl::test_case& t : this->test_cases()) {
730730
if (!predicate(t.id)) {
@@ -763,12 +763,12 @@ bool registry::run_selected_tests(
763763
}
764764
}
765765

766-
# if SNITCH_WITH_TIMINGS
766+
#if SNITCH_WITH_TIMINGS
767767
const float duration = get_duration_in_seconds(time_start, get_current_time());
768-
# endif
768+
#endif
769769

770770
if (verbose >= registry::verbosity::normal) {
771-
# if SNITCH_WITH_TIMINGS
771+
#if SNITCH_WITH_TIMINGS
772772
report_callback(
773773
*this, event::test_run_ended{
774774
.name = run_name,
@@ -783,7 +783,7 @@ bool registry::run_selected_tests(
783783
.duration = duration,
784784
.success = success,
785785
});
786-
# else
786+
#else
787787
report_callback(
788788
*this, event::test_run_ended{
789789
.name = run_name,
@@ -796,7 +796,7 @@ bool registry::run_selected_tests(
796796
.assertion_failure_count = assertion_failure_count,
797797
.allowed_assertion_failure_count = allowed_assertion_failure_count,
798798
.success = success});
799-
# endif
799+
#endif
800800
}
801801

802802
return success;

src/snitch_reporter_catch2_xml.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -243,7 +243,7 @@ void reporter::report(const registry& r, const snitch::event::data& event) noexc
243243
e.allowed_assertion_failure_count)},
244244
{"failures", make_string(e.assertion_failure_count)},
245245
{"expectedFailures", make_string(e.allowed_assertion_failure_count)},
246-
{"skipped", e.skipped?"true":"false"}
246+
{"skipped", e.skipped ? "true" : "false"}
247247
# if SNITCH_WITH_TIMINGS
248248
,
249249
{"durationInSeconds", make_string(e.duration)}

tests/runtime_tests/check.cpp

+3-3
Original file line numberDiff line numberDiff line change
@@ -1688,11 +1688,11 @@ TEST_CASE("require throws matches", "[test macros]") {
16881688
}
16891689

16901690
namespace {
1691-
#if SNITCH_ENABLE
1691+
# if SNITCH_ENABLE
16921692
[[nodiscard]]
1693-
#else
1693+
# else
16941694
[[maybe_unused]]
1695-
#endif
1695+
# endif
16961696
int nodiscard_function() {
16971697
return 1;
16981698
}

tests/runtime_tests/function_ref.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ bool function_called = false;
88
#if !SNITCH_ENABLE
99
[[maybe_unused]]
1010
#endif
11-
int return_value = 0u;
11+
int return_value = 0u;
1212

1313
struct test_object {
1414
test_object() noexcept {

tests/runtime_tests/string_utility.cpp

+2-1
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,8 @@ struct frob {
1919
#if !SNITCH_ENABLE
2020
[[maybe_unused]]
2121
#endif
22-
void foo() {}
22+
void foo() {
23+
}
2324

2425
using function_ptr_type = void (*)();
2526
using member_function_ptr_type = void (frob::*)();

0 commit comments

Comments
 (0)