diff options
| author | David Faulkner <[email protected]> | 2026-08-07 23:40:47 -0500 |
|---|---|---|
| committer | David Faulkner <[email protected]> | 2026-08-07 23:40:47 -0500 |
| commit | b3e9e62599532050fc776c5e8f076915b56c2235 (patch) | |
| tree | af252346106a61b18cc6fc6fdbd32e962d096f1c /test_circular.c | |
Import official C23 code examples for Modern C (Jens Gustedt, 2024)HEADupstream-importmain
- Add official C source files, Makefile, c23-fallback.h, and LICENSE
- Update README.md with study mirror notice
Diffstat (limited to 'test_circular.c')
| -rw-r--r-- | test_circular.c | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/test_circular.c b/test_circular.c new file mode 100644 index 0000000..338e16a --- /dev/null +++ b/test_circular.c @@ -0,0 +1,22 @@ +#include <stdlib.h> +#include "circular.h" + +int main(int argc, char* argv[]) { + size_t len = argc > 1 ? strtoull(argv[1], nullptr, 0) : 10; + fprintf(stderr, "starting with %zu elements in total\n", len); + circular* c = circular_new(len); + circular_fput(c, stderr); + for (size_t i = 0; i < len-1; ++i) { + if (!circular_append(c, i)) break; + } + circular_fput(c, stderr); + for (size_t i = 0; i < len/2; ++i) { + if (!circular_append(c, circular_pop(c))) break; + } + circular_fput(c, stderr); + c = circular_resize(c, 2*len); + circular_fput(c, stderr); + c = circular_resize(c, len); + circular_fput(c, stderr); + circular_delete(c); +} |
