diff options
| author | Fuwn <[email protected]> | 2022-06-14 20:08:51 -0700 |
|---|---|---|
| committer | Fuwn <[email protected]> | 2022-06-14 20:08:51 -0700 |
| commit | 0105c9d79d02f00182c40c29d33b907982c0556d (patch) | |
| tree | 3a5af6104a84a271bbbf359fdf2257ae14fcb233 /include | |
| download | tatl-0.1.0.tar.xz tatl-0.1.0.zip | |
feat: initial commit0.1.0
Diffstat (limited to 'include')
| -rw-r--r-- | include/meson.build | 1 | ||||
| -rw-r--r-- | include/tatl/context.h | 88 | ||||
| -rw-r--r-- | include/tatl/context/get.h | 47 | ||||
| -rw-r--r-- | include/tatl/context/meson.build | 1 | ||||
| -rw-r--r-- | include/tatl/context/set.h | 42 | ||||
| -rw-r--r-- | include/tatl/macros.h | 55 | ||||
| -rw-r--r-- | include/tatl/meson.build | 1 | ||||
| -rw-r--r-- | include/tatl/tatl.h | 28 |
8 files changed, 263 insertions, 0 deletions
diff --git a/include/meson.build b/include/meson.build new file mode 100644 index 0000000..bf4b9ec --- /dev/null +++ b/include/meson.build @@ -0,0 +1 @@ +subdir('tatl') diff --git a/include/tatl/context.h b/include/tatl/context.h new file mode 100644 index 0000000..05667ab --- /dev/null +++ b/include/tatl/context.h @@ -0,0 +1,88 @@ +/* + * This file is part of Tatl <https://github.com/Fuwn/tatl>. + * Copyright (C) 2022-2022 Fuwn <[email protected]> + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, version 3. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + * + * Copyright (C) 2022-2022 Fuwn <[email protected]> + * SPDX-License-Identifier: GPL-3.0-only + */ + +#ifndef TATL_CONTEXT_ +#define TATL_CONTEXT_ + +#include <time.h> + +/* Hold the tests that a Tatl should complete along with data about the Tatl + * context + */ +struct tatl_context { + /* Muting a Tatl context disables any output that the context may produce. */ + int _mute; + /* Set to failing if any tests within the test queue fail */ + int _exit_code; + /* The total number of tests that have been run */ + size_t _total; + /* The total number of passing tests that have been run */ + size_t _passed; + /* The total number of failing tests that have been run */ + size_t _failed; + /* The number of names of tests within the test queue */ + size_t _names_size; + /* The number of tests within the test queue */ + size_t _tests_size; + /* A timer to track the length of a test or group of tests */ + clock_t _timer; + /* The Tatl context's tag */ + char *_tag; + /* The names of tests within the test queue */ + const char **_names; + /* The test queue */ + int (**_tests)(void); +}; + +#ifdef __cplusplus +extern "C" { +#endif + +/* Initialise a Tatl context with safe defaults */ +void tatl_new(struct tatl_context *); +/* Clean up any resources that the Tatl context is using + * + * Called automatically by tatl_finish + */ +void tatl_destroy(struct tatl_context); +/* Summarise a Tatl context's test results + * + * Called automatically by tatl_finish + */ +void tatl_summary(struct tatl_context); +/* Add a test to the Tatl context's test queue */ +void tatl_add(struct tatl_context *, const char *, int (*)(void)); +/* Run all tests within the Tatl context's test queue + * + * Called automatically by tatl_finish + */ +void tatl_run(struct tatl_context *); +/* A comprehensive collection of tasks that calls many of the "finishing" Tatl + * operations + * + * Calls tatl_run, tatl_summary, and tatl_destroy---in that order + */ +void tatl_finish(struct tatl_context *); + +#ifdef __cplusplus +} +#endif + +#endif /* TATL_CONTEXT_ */ diff --git a/include/tatl/context/get.h b/include/tatl/context/get.h new file mode 100644 index 0000000..67296fd --- /dev/null +++ b/include/tatl/context/get.h @@ -0,0 +1,47 @@ +/* + * This file is part of Tatl <https://github.com/Fuwn/tatl>. + * Copyright (C) 2022-2022 Fuwn <[email protected]> + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, version 3. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + * + * Copyright (C) 2022-2022 Fuwn <[email protected]> + * SPDX-License-Identifier: GPL-3.0-only + */ + +#ifndef TATL_CONTEXT_GET +#define TATL_CONTEXT_GET + +#include <tatl/context.h> + +#ifdef __cplusplus +extern "C" { +#endif + +/* Get a Tatl context's total number of tests */ +size_t *tatl_context_get_total(struct tatl_context *); +/* Get a Tatl context's total number of passing tests */ +size_t *tatl_context_get_passed(struct tatl_context *); +/* Get a Tatl context's total number of failing tests */ +size_t *tatl_context_get_failed(struct tatl_context *); +/* Get a Tatl context's tag */ +char *tatl_context_get_tag(struct tatl_context *); +/* Get a Tatl context's mute status */ +int *tatl_context_get_mute(struct tatl_context *); +/* Get a Tatl context's exit code */ +int *tatl_context_get_exit_code(struct tatl_context *); + +#ifdef __cplusplus +} +#endif + +#endif /* TATL_CONTEXT_GET */ diff --git a/include/tatl/context/meson.build b/include/tatl/context/meson.build new file mode 100644 index 0000000..f67e989 --- /dev/null +++ b/include/tatl/context/meson.build @@ -0,0 +1 @@ +project_header_files += files('get.h', 'set.h') diff --git a/include/tatl/context/set.h b/include/tatl/context/set.h new file mode 100644 index 0000000..26d9ae5 --- /dev/null +++ b/include/tatl/context/set.h @@ -0,0 +1,42 @@ +/* + * This file is part of Tatl <https://github.com/Fuwn/tatl>. + * Copyright (C) 2022-2022 Fuwn <[email protected]> + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, version 3. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + * + * Copyright (C) 2022-2022 Fuwn <[email protected]> + * SPDX-License-Identifier: GPL-3.0-only + */ + +#ifndef TATL_CONTEXT_SET +#define TATL_CONTEXT_SET + +#include <tatl/context.h> + +#ifdef __cplusplus +extern "C" { +#endif + +/* Set a Tatl context's mute status + * + * Muting a Tatl context disables any output that the context may produce. + */ +void tatl_context_set_mute(struct tatl_context *, int); +/* Set a Tatl context's tag */ +void tatl_context_set_tag(struct tatl_context *, const char *); + +#ifdef __cplusplus +} +#endif + +#endif /* TATL_CONTEXT_SET */ diff --git a/include/tatl/macros.h b/include/tatl/macros.h new file mode 100644 index 0000000..2986b6b --- /dev/null +++ b/include/tatl/macros.h @@ -0,0 +1,55 @@ +/* + * This file is part of Tatl <https://github.com/Fuwn/tatl>. + * Copyright (C) 2022-2022 Fuwn <[email protected]> + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, version 3. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + * + * Copyright (C) 2022-2022 Fuwn <[email protected]> + * SPDX-License-Identifier: GPL-3.0-only + */ + +#ifndef TATL_MACROS +#define TATL_MACROS + +#include <tatl/context.h> + +/* Shorthand for creating and initialising a new Tatl context with safe defaults + * + * Creates a new tatl_context and calls tatl_new on that context + */ +#define TATL_NEW() \ + struct tatl_context __context; \ + \ + __context._total = 0; \ + \ + tatl_new(&__context) + +/* Shorthand for tatl_finish */ +#define TATL_FINISH() tatl_finish(&__context) + +/* Shorthand for tatl_add */ +#define TATL_ADD(tag, test) tatl_add(&__context, tag, test) + +/* Define and name a test */ +#define TATL_TEST(reference) \ + int reference(void); \ + \ + int reference(void) + +/* Access the global Tatl macro context */ +#define TATL_CONTEXT __context + +/* Evaluate two values' equality */ +#define TATL_IS(a, b) (a == b) + +#endif /* TATL_MACROS */ diff --git a/include/tatl/meson.build b/include/tatl/meson.build new file mode 100644 index 0000000..e5081c9 --- /dev/null +++ b/include/tatl/meson.build @@ -0,0 +1 @@ +project_header_files += files('context.h', 'macros.h', 'tatl.h') diff --git a/include/tatl/tatl.h b/include/tatl/tatl.h new file mode 100644 index 0000000..2707cc4 --- /dev/null +++ b/include/tatl/tatl.h @@ -0,0 +1,28 @@ +/* + * This file is part of Tatl <https://github.com/Fuwn/tatl>. + * Copyright (C) 2022-2022 Fuwn <[email protected]> + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, version 3. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + * + * Copyright (C) 2022-2022 Fuwn <[email protected]> + * SPDX-License-Identifier: GPL-3.0-only + */ + +#ifndef TATL_TATL +#define TATL_TATL + +#include <tatl/context.h> +#include <tatl/context/get.h> +#include <tatl/macros.h> + +#endif /* TATL_TATL */ |