1
1
#include " snitch/snitch_registry.hpp"
2
2
3
- # include " snitch/snitch_time.hpp"
3
+ #include " snitch/snitch_time.hpp"
4
4
5
- # include < algorithm> // for std::sort
6
- # include < optional> // for std::optional
5
+ #include < algorithm> // for std::sort
6
+ #include < optional> // for std::optional
7
7
8
8
// Testing framework implementation.
9
9
// ---------------------------------
@@ -399,14 +399,14 @@ void register_assertion(bool success, impl::test_state& state) {
399
399
++section.allowed_assertion_failure_count ;
400
400
}
401
401
402
- # if SNITCH_WITH_EXCEPTIONS
402
+ #if SNITCH_WITH_EXCEPTIONS
403
403
if (state.held_info .has_value ()) {
404
404
for (auto & section : state.held_info .value ().sections .current_section ) {
405
405
++section.assertion_count ;
406
406
++section.allowed_assertion_failure_count ;
407
407
}
408
408
}
409
- # endif
409
+ #endif
410
410
411
411
impl::set_state (state.test , impl::test_case_state::allowed_fail);
412
412
} else {
@@ -418,14 +418,14 @@ void register_assertion(bool success, impl::test_state& state) {
418
418
++section.assertion_failure_count ;
419
419
}
420
420
421
- # if SNITCH_WITH_EXCEPTIONS
421
+ #if SNITCH_WITH_EXCEPTIONS
422
422
if (state.held_info .has_value ()) {
423
423
for (auto & section : state.held_info .value ().sections .current_section ) {
424
424
++section.assertion_count ;
425
425
++section.assertion_failure_count ;
426
426
}
427
427
}
428
- # endif
428
+ #endif
429
429
430
430
impl::set_state (state.test , impl::test_case_state::failed);
431
431
}
@@ -436,13 +436,13 @@ void register_assertion(bool success, impl::test_state& state) {
436
436
++section.assertion_count ;
437
437
}
438
438
439
- # if SNITCH_WITH_EXCEPTIONS
439
+ #if SNITCH_WITH_EXCEPTIONS
440
440
if (state.held_info .has_value ()) {
441
441
for (auto & section : state.held_info .value ().sections .current_section ) {
442
442
++section.assertion_count ;
443
443
}
444
444
}
445
- # endif
445
+ #endif
446
446
}
447
447
}
448
448
@@ -455,7 +455,7 @@ void report_assertion_impl(
455
455
456
456
register_assertion (success, state);
457
457
458
- # if SNITCH_WITH_EXCEPTIONS
458
+ #if SNITCH_WITH_EXCEPTIONS
459
459
const bool use_held_info = (state.unhandled_exception || std::uncaught_exceptions () > 0 ) &&
460
460
state.held_info .has_value ();
461
461
@@ -472,13 +472,13 @@ void report_assertion_impl(
472
472
state.in_check
473
473
? assertion_location{last_location.file , last_location.line , location_type::exact}
474
474
: last_location;
475
- # else
475
+ #else
476
476
const auto captures_buffer = impl::make_capture_buffer (state.info .captures );
477
477
const auto & current_section = state.info .sections .current_section ;
478
478
const auto & last_location = state.info .locations .back ();
479
479
const auto location =
480
480
assertion_location{last_location.file , last_location.line , location_type::exact};
481
- # endif
481
+ #endif
482
482
483
483
if (success) {
484
484
if (r.verbose >= registry::verbosity::full) {
@@ -558,7 +558,7 @@ void registry::report_section_ended(const section& sec) noexcept {
558
558
559
559
const bool skipped = state.test .state == impl::test_case_state::skipped;
560
560
561
- # if SNITCH_WITH_TIMINGS
561
+ #if SNITCH_WITH_TIMINGS
562
562
const auto duration = get_duration_in_seconds (sec.start_time , get_current_time ());
563
563
state.reg .report_callback (
564
564
state.reg , event::section_ended{
@@ -569,7 +569,7 @@ void registry::report_section_ended(const section& sec) noexcept {
569
569
.assertion_failure_count = sec.assertion_failure_count ,
570
570
.allowed_assertion_failure_count = sec.allowed_assertion_failure_count ,
571
571
.duration = duration});
572
- # else
572
+ #else
573
573
state.reg .report_callback (
574
574
state.reg , event::section_ended{
575
575
.id = sec.id ,
@@ -578,7 +578,7 @@ void registry::report_section_ended(const section& sec) noexcept {
578
578
.assertion_count = sec.assertion_count ,
579
579
.assertion_failure_count = sec.assertion_failure_count ,
580
580
.allowed_assertion_failure_count = sec.allowed_assertion_failure_count });
581
- # endif
581
+ #endif
582
582
}
583
583
584
584
impl::test_state registry::run (impl::test_case& test) noexcept {
@@ -610,13 +610,13 @@ impl::test_state registry::run(impl::test_case& test) noexcept {
610
610
impl::test_state* previous_run = impl::try_get_current_test ();
611
611
impl::set_current_test (&state);
612
612
613
- # if SNITCH_WITH_TIMINGS
613
+ #if SNITCH_WITH_TIMINGS
614
614
const auto time_start = get_current_time ();
615
- # endif
615
+ #endif
616
616
617
- # if SNITCH_WITH_EXCEPTIONS
617
+ #if SNITCH_WITH_EXCEPTIONS
618
618
try {
619
- # endif
619
+ #endif
620
620
621
621
do {
622
622
// Reset section state.
@@ -640,7 +640,7 @@ impl::test_state registry::run(impl::test_case& test) noexcept {
640
640
} while (!state.info .sections .levels .empty () &&
641
641
state.test .state != impl::test_case_state::skipped);
642
642
643
- # if SNITCH_WITH_EXCEPTIONS
643
+ #if SNITCH_WITH_EXCEPTIONS
644
644
state.in_check = true ;
645
645
report_assertion (true , " no exception caught" );
646
646
state.in_check = false ;
@@ -660,7 +660,7 @@ impl::test_state registry::run(impl::test_case& test) noexcept {
660
660
}
661
661
662
662
state.unhandled_exception = false ;
663
- # endif
663
+ #endif
664
664
665
665
if (state.should_fail ) {
666
666
state.should_fail = false ;
@@ -671,12 +671,12 @@ impl::test_state registry::run(impl::test_case& test) noexcept {
671
671
state.should_fail = true ;
672
672
}
673
673
674
- # if SNITCH_WITH_TIMINGS
674
+ #if SNITCH_WITH_TIMINGS
675
675
state.duration = get_duration_in_seconds (time_start, get_current_time ());
676
- # endif
676
+ #endif
677
677
678
678
if (verbose >= registry::verbosity::high) {
679
- # if SNITCH_WITH_TIMINGS
679
+ #if SNITCH_WITH_TIMINGS
680
680
report_callback (
681
681
*this , event::test_case_ended{
682
682
.id = test.id ,
@@ -686,7 +686,7 @@ impl::test_state registry::run(impl::test_case& test) noexcept {
686
686
.allowed_assertion_failure_count = state.allowed_failures ,
687
687
.state = impl::convert_to_public_state (state.test .state ),
688
688
.duration = state.duration });
689
- # else
689
+ #else
690
690
report_callback (
691
691
*this , event::test_case_ended{
692
692
.id = test.id ,
@@ -695,7 +695,7 @@ impl::test_state registry::run(impl::test_case& test) noexcept {
695
695
.assertion_failure_count = state.failures ,
696
696
.allowed_assertion_failure_count = state.allowed_failures ,
697
697
.state = impl::convert_to_public_state (state.test .state )});
698
- # endif
698
+ #endif
699
699
}
700
700
701
701
impl::set_current_test (previous_run);
@@ -722,9 +722,9 @@ bool registry::run_selected_tests(
722
722
std::size_t assertion_failure_count = 0 ;
723
723
std::size_t allowed_assertion_failure_count = 0 ;
724
724
725
- # if SNITCH_WITH_TIMINGS
725
+ #if SNITCH_WITH_TIMINGS
726
726
const auto time_start = get_current_time ();
727
- # endif
727
+ #endif
728
728
729
729
for (impl::test_case& t : this ->test_cases ()) {
730
730
if (!predicate (t.id )) {
@@ -763,12 +763,12 @@ bool registry::run_selected_tests(
763
763
}
764
764
}
765
765
766
- # if SNITCH_WITH_TIMINGS
766
+ #if SNITCH_WITH_TIMINGS
767
767
const float duration = get_duration_in_seconds (time_start, get_current_time ());
768
- # endif
768
+ #endif
769
769
770
770
if (verbose >= registry::verbosity::normal ) {
771
- # if SNITCH_WITH_TIMINGS
771
+ #if SNITCH_WITH_TIMINGS
772
772
report_callback (
773
773
*this , event::test_run_ended{
774
774
.name = run_name,
@@ -783,7 +783,7 @@ bool registry::run_selected_tests(
783
783
.duration = duration,
784
784
.success = success,
785
785
});
786
- # else
786
+ #else
787
787
report_callback (
788
788
*this , event::test_run_ended{
789
789
.name = run_name,
@@ -796,7 +796,7 @@ bool registry::run_selected_tests(
796
796
.assertion_failure_count = assertion_failure_count,
797
797
.allowed_assertion_failure_count = allowed_assertion_failure_count,
798
798
.success = success});
799
- # endif
799
+ #endif
800
800
}
801
801
802
802
return success;
0 commit comments