From 90b263ae540e36f85f8d8786a5bdb7f548e98628 Mon Sep 17 00:00:00 2001 From: administrateur Date: Thu, 13 Jun 2024 18:20:09 +0200 Subject: [PATCH] Ajouter newtest.c --- newtest.c | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) create mode 100644 newtest.c diff --git a/newtest.c b/newtest.c new file mode 100644 index 0000000..02b8dfb --- /dev/null +++ b/newtest.c @@ -0,0 +1,30 @@ +/** + * A simple counter. + * https://cylab.be/blog/271/unit-testing-c-code + */ + +#include + +#include "counter.h" + +struct Counter { + int value; +}; + +struct Counter * counter(void) +{ + struct Counter* c = malloc(sizeof(struct Counter)); + c->value = 0; + + return c; +} + +void increment(struct Counter* c) +{ + c->value++; +} + +int value(struct Counter* c) +{ + return c->value; +} \ No newline at end of file