Ajouter newtest.c

This commit is contained in:
administrateur 2024-06-13 18:20:09 +02:00
parent 2bcc143bff
commit 90b263ae54
1 changed files with 30 additions and 0 deletions

30
newtest.c Normal file
View File

@ -0,0 +1,30 @@
/**
* A simple counter.
* https://cylab.be/blog/271/unit-testing-c-code
*/
#include <stdlib.h>
#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;
}