From 7a811406dd16e057204bed1aa15cfe33d81ccb6b Mon Sep 17 00:00:00 2001 From: Kimplul Date: Sun, 17 Aug 2025 23:36:54 +0300 Subject: initial commit --- tests/pass.c | 39 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) create mode 100644 tests/pass.c (limited to 'tests/pass.c') diff --git a/tests/pass.c b/tests/pass.c new file mode 100644 index 0000000..bd5bfc3 --- /dev/null +++ b/tests/pass.c @@ -0,0 +1,39 @@ +#include +#include + +#include "test.h" + +/* this is a well behaved program that prints out a smiley face */ + +int main() +{ +#if defined(COVERAGE) + assert(!covsrv_init()); + atexit(covsrv_destroy); +#endif + + /* alloc memory for the smiley */ + char *p = mallocc(2 * sizeof(char)); + if (!p) { + fprintf(stderr, "oops, malloc failed :(\n"); + return -1; + } + + p[0] = ':'; + p[1] = ')'; + + /* oops, forgot the terminating null, let's realloc */ + char *new_p = reallocc(p, 3 * sizeof(char)); + if (!new_p) { + fprintf(stderr, "oops, realloc failed :(\n"); + free(p); + return -1; + } + + p = new_p; + + p[2] = '\0'; + printf("%s\n", p); + + free(p); +} -- cgit v1.2.3