Refactored types out of criterion.h

This commit is contained in:
Snaipe 2015-03-23 00:40:56 +01:00
parent 2f680b486a
commit 45793a9ede
12 changed files with 69 additions and 60 deletions

View file

@ -29,6 +29,7 @@ subdirinclude_HEADERS = \
include/criterion/event.h \
include/criterion/hooks.h \
include/criterion/logging.h \
include/criterion/types.h \
include/criterion/options.h \
include/criterion/ordered-set.h \
include/criterion/stats.h

View file

@ -27,7 +27,7 @@
# include <string.h>
# include <stdlib.h>
# include <stdbool.h>
# include "criterion.h"
# include "types.h"
# include "stats.h"
# include "hooks.h"
# include "event.h"

View file

@ -1,59 +1,9 @@
/*
* The MIT License (MIT)
*
* Copyright © 2015 Franklin "Snaipe" Mathieu <http://snai.pe/>
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
#ifndef CRITERION_H_
# define CRITERION_H_
# include <stdbool.h>
# include <stddef.h>
# include "common.h"
# include "assert.h"
struct criterion_test_extra_data {
int sentinel_;
const char *const file_;
const unsigned line_;
void (*init)(void);
void (*fini)(void);
int signal;
bool disabled;
void *data;
};
struct criterion_test {
const char *name;
const char *category;
void (*test)(void);
struct criterion_test_extra_data *const data;
};
struct criterion_suite {
const char *name;
struct criterion_test_extra_data *const data;
#if 1
void *pad[2];
#endif
};
# include "types.h"
# define IDENTIFIER_(Category, Name, Suffix) \
Category ## _ ## Name ## _ ## Suffix

View file

@ -27,6 +27,7 @@
# include <stdbool.h>
# include "common.h"
# include "ordered-set.h"
# include "stats.h"
enum criterion_logging_level {
CRITERION_INFO = 1,

View file

@ -24,8 +24,7 @@
#ifndef CRITERION_ORDERED_SET_H_
# define CRITERION_ORDERED_SET_H_
# include <stddef.h>
# include "criterion.h"
# include "types.h"
struct criterion_ordered_set {
struct criterion_ordered_set_node *first;

View file

@ -24,9 +24,7 @@
#ifndef CRITERION_STATS_H_
# define CRITERION_STATS_H_
# include <stdbool.h>
# include <stddef.h>
# include "criterion.h"
# include "types.h"
struct criterion_assert_stats {
int kind;

56
include/criterion/types.h Normal file
View file

@ -0,0 +1,56 @@
/*
* The MIT License (MIT)
*
* Copyright © 2015 Franklin "Snaipe" Mathieu <http://snai.pe/>
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
#ifndef CRITERION_TYPES_H_
# define CRITERION_TYPES_H_
# include <stdbool.h>
# include <stddef.h>
struct criterion_test_extra_data {
int sentinel_;
const char *const file_;
const unsigned line_;
void (*init)(void);
void (*fini)(void);
int signal;
bool disabled;
void *data;
};
struct criterion_test {
const char *name;
const char *category;
void (*test)(void);
struct criterion_test_extra_data *const data;
};
struct criterion_suite {
const char *name;
struct criterion_test_extra_data *const data;
#if 1
void *pad[2];
#endif
};
#endif /* !CRITERION_TYPES_H_ */

View file

@ -22,6 +22,8 @@
* THE SOFTWARE.
*/
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "criterion/stats.h"
#include "criterion/logging.h"
#include "criterion/options.h"

View file

@ -27,7 +27,7 @@
#include <sys/wait.h>
#include <csptr/smart_ptr.h>
#include "criterion/criterion.h"
#include "criterion/types.h"
#include "criterion/options.h"
#include "process.h"
#include "event.h"

View file

@ -23,8 +23,9 @@
*/
#define _GNU_SOURCE
#include <stdio.h>
#include <stdlib.h>
#include <fnmatch.h>
#include "criterion/criterion.h"
#include "criterion/types.h"
#include "criterion/stats.h"
#include "criterion/logging.h"
#include "criterion/options.h"

View file

@ -25,6 +25,7 @@
#include <stdio.h>
#include <unistd.h>
#include <csptr/smart_ptr.h>
#include "criterion/criterion.h"
#include "criterion/options.h"
#include "criterion/ordered-set.h"
#include "stats.h"

View file

@ -24,7 +24,7 @@
#ifndef CRITERION_RUNNER_H_
# define CRITERION_RUNNER_H_
# include "criterion/criterion.h"
# include "criterion/types.h"
DECL_SECTION_LIMITS(struct criterion_test, criterion_tests);
DECL_SECTION_LIMITS(struct criterion_suite, crit_suites);