Direct-BT
v3.3.0-1-gc2d430c
Direct-BT - Direct Bluetooth Programming.
jaulib
include
jau
test
catch2_my_main.cpp
Go to the documentation of this file.
1
/*
2
* Author: Sven Gothel <sgothel@jausoft.com>
3
* Copyright (c) 2020 Gothel Software e.K.
4
*
5
* Permission is hereby granted, free of charge, to any person obtaining
6
* a copy of this software and associated documentation files (the
7
* "Software"), to deal in the Software without restriction, including
8
* without limitation the rights to use, copy, modify, merge, publish,
9
* distribute, sublicense, and/or sell copies of the Software, and to
10
* permit persons to whom the Software is furnished to do so, subject to
11
* the following conditions:
12
*
13
* The above copyright notice and this permission notice shall be
14
* included in all copies or substantial portions of the Software.
15
*
16
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
23
*
24
*************************************************************************
25
*
26
* Distributed under the Boost Software License, Version 1.0.
27
* (See accompanying file LICENSE_1_0.txt or copy at
28
* https://www.boost.org/LICENSE_1_0.txt)
29
*
30
* SPDX-License-Identifier: BSL-1.0
31
*/
32
33
#ifndef CATCH2_MY_MAIN_H
34
#define CATCH2_MY_MAIN_H
35
36
#define CATCH_AMALGAMATED_CUSTOM_MAIN 1
37
#include <catch2/catch_amalgamated.hpp>
38
39
/** The main argv[0] test executable path */
40
std::string
executable_path
;
41
42
/** Run w/o command-line args, i.e. default CI unit test. */
43
bool
catch_auto_run
;
44
45
/** Run w/ command-line arg '--perf_analysis'. */
46
bool
catch_perf_analysis
;
47
48
static
char
*
extra_args
[] = { (
char
*)
"--colour-mode"
, (
char
*)
"none"
};
49
static
int
extra_args_c
=
sizeof
(
extra_args
) /
sizeof
(
const
char
*);
50
51
int
main
(
int
argc,
char
* argv[] )
52
{
53
Catch::Session session;
// There must be exactly one instance
54
55
if
( 1 <= argc ) {
56
executable_path
= std::string(argv[0]);
57
}
else
{
58
executable_path
=
"undef"
;
59
}
60
61
catch_auto_run
= ( 1 >= argc );
62
63
int
argc_2=0;
64
char
* argv_2[argc+
extra_args_c
];
65
66
for
(
int
i=0; i<argc; i++) {
67
if
( 0 == strcmp(
"--perf_analysis"
, argv[i]) ) {
68
catch_perf_analysis
=
true
;
69
}
else
{
70
argv_2[argc_2++] = argv[i];
71
}
72
}
73
for
(
int
i=0; i<
extra_args_c
; i++) {
74
argv_2[argc_2++] =
extra_args
[i];
75
}
76
fprintf(stderr,
"argc %d -> %d, auto_run %d, perf_analysis %d\n"
,
77
argc, argc_2,
catch_auto_run
,
catch_perf_analysis
);
78
for
(
int
i=0; i<argc_2; i++) {
79
printf
(
"[%d] %s\n"
, i, argv_2[i]);
80
}
81
82
// writing to session.configData() here sets defaults
83
// this is the preferred way to set them
84
85
int
returnCode = session.applyCommandLine( argc_2, argv_2 );
86
87
if
( returnCode != 0 ) {
// Indicates a command line error
88
return
returnCode;
89
}
90
91
if
(
catch_auto_run
) {
92
const
char
* my_args[] = { argv[0],
93
"--benchmark-warmup-time"
,
"1"
,
94
"--benchmark-confidence-interval"
,
"0"
,
95
"--benchmark-samples"
,
"1"
,
96
"--benchmark-resamples"
,
"0"
,
97
"--benchmark-no-analysis"
98
};
99
int
res = session.applyCommandLine(
sizeof
(my_args)/
sizeof
(
char
*), my_args );
100
if
( 0 != res ) {
101
return
res;
102
}
103
// Catch::Config& config = session.config();
104
}
105
106
// writing to session.configData() or session.Config() here
107
// overrides command line args
108
// only do this if you know you need to
109
110
int
numFailed = session.run();
111
112
// numFailed is clamped to 255 as some unices only use the lower 8 bits.
113
// This clamping has already been applied, so just return it here
114
// You can also do any post run clean-up here
115
return
numFailed;
116
}
117
118
#endif
// CATCH2_MY_MAIN_H
119
main
int main(int argc, char *argv[])
Definition:
catch2_my_main.cpp:51
catch_perf_analysis
bool catch_perf_analysis
Run w/ command-line arg '–perf_analysis'.
Definition:
catch2_my_main.cpp:46
catch_auto_run
bool catch_auto_run
Run w/o command-line args, i.e.
Definition:
catch2_my_main.cpp:43
executable_path
std::string executable_path
The main argv[0] test executable path.
Definition:
catch2_my_main.cpp:40
extra_args_c
static int extra_args_c
Definition:
catch2_my_main.cpp:49
extra_args
static char * extra_args[]
Definition:
catch2_my_main.cpp:48
printf
int printf(const char *format,...)
Operating Systems predefined macros.
Generated on Sun May 12 2024 09:25:36 for Direct-BT by
1.9.4