Github User Fetcher 1.0.0
C Application with Server and GUI
Loading...
Searching...
No Matches
criterion.h
Go to the documentation of this file.
1/*
2 * The MIT License (MIT)
3 *
4 * Copyright © 2015-2016 Franklin "Snaipe" Mathieu <http://snai.pe/>
5 *
6 * Permission is hereby granted, free of charge, to any person obtaining a copy
7 * of this software and associated documentation files (the "Software"), to deal
8 * in the Software without restriction, including without limitation the rights
9 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 * copies of the Software, and to permit persons to whom the Software is
11 * furnished to do so, subject to the following conditions:
12 *
13 * The above copyright notice and this permission notice shall be included in
14 * all copies or substantial portions of the Software.
15 *
16 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
22 * THE SOFTWARE.
23 */
24/**
25 * @file
26 * @brief Include this to use criterion
27 *****************************************************************************/
28#ifndef CRITERION_H_
29#define CRITERION_H_
30
31#include "types.h"
32#include "assert.h"
33#include "alloc.h"
34
35/**
36 * Defines a new test.
37 *
38 * @param Suite The name of the test suite containing this test.
39 * @param Name The name of the test.
40 * @param ... An optional sequence of designated initializer key/value
41 * pairs as described in the `criterion_test_extra_data` structure
42 * (see criterion/types.h).\n
43 * Example: .exit_code = 1
44 */
45#define Test(Suite, Name, ...) internal
46
47/**
48 * Explicitely defines a test suite and its options.
49 *
50 * @param Name The name of the test suite.
51 * @param ... An optional sequence of designated initializer key/value
52 * pairs as described in the `criterion_test_extra_data` structure
53 * (see criterion/types.h).
54 * These options will provide the defaults for each test.
55 */
56#define TestSuite(Name, ...) internal
57
59
60/**
61 * Initializes criterion and builds a set of all discovered tests.
62 *
63 * Using any of the functions and macros provided by criterion before calling
64 * this results in undefined behaviour.
65 *
66 * @returns the set of tests
67 */
69
70/**
71 * Release all resources allocated by criterion.
72 *
73 * Using any of the functions and macros provided by criterion except
74 * criterion_initialize after this function is called results in undefined
75 * behaviour.
76 */
78
79/**
80 * Run all the tests in the test set.
81 *
82 * @param[in] tests The set of tests that are to be executed.
83 *
84 * @returns 1 if all tests succeeded or criterion_options.always_succeed
85 * is true, 0 otherwise.
86 */
88
89/**
90 * Handles all default command-line parameters, as documented in:
91 * <http://criterion.readthedocs.org/en/latest/env.html>, and appropriately
92 * sets criterion_options.
93 *
94 * @param[in] argc The number of arguments in argv.
95 * @param[in] argv A null-terminated array of strings representing the arguments.
96 * @param[in] handle_unknown_arg Whether the function should print a message
97 * and exit when an unknown parameter is encountered. Use false if you want
98 * to handle additional parameters yourself.
99 *
100 * @returns 0 if the process should exit immediately after, for instance after
101 * printing the help message.
102 */
103CR_API int criterion_handle_args(int argc, char *argv[], bool handle_unknown_arg);
104
105/**
106 * Manually registers a new test within the specified test set.
107 *
108 * @param[in] tests The set of tests you want to insert the test in.
109 * @param[in] test The newly created test.
110 */
112 struct criterion_test *test);
113
114CR_API extern const struct criterion_test *const criterion_current_test;
115CR_API extern const struct criterion_suite *const criterion_current_suite;
116
118
119#include "internal/test.h"
120
121#endif /* !CRITERION_H_ */
Test intern memory managment.
Assertion API.
#define CR_BEGIN_C_API
Definition common.h:54
#define CR_API
Definition common.h:128
#define CR_END_C_API
Definition common.h:55
CR_API const struct criterion_test *const criterion_current_test
CR_API void criterion_finalize(struct criterion_test_set *tests)
CR_BEGIN_C_API CR_API struct criterion_test_set * criterion_initialize(void)
CR_API const struct criterion_suite *const criterion_current_suite
CR_API void criterion_register_test(struct criterion_test_set *tests, struct criterion_test *test)
CR_API int criterion_run_all_tests(struct criterion_test_set *tests)
CR_API int criterion_handle_args(int argc, char *argv[], bool handle_unknown_arg)
Types for tests.