Skip to content

Commit

Permalink
tests: add test suite
Browse files Browse the repository at this point in the history
just picking any actively maintained embeddable framework to write a
bunch of tests with. will swap it out if I hate it.

this single initial test found a big one....
  • Loading branch information
dormando committed Aug 31, 2022
1 parent d030f8f commit 626e86b
Show file tree
Hide file tree
Showing 3 changed files with 1,470 additions and 0 deletions.
11 changes: 11 additions & 0 deletions tests/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
PREFIX=/usr/local

all:
gcc -g -Wall -Werror -pedantic -o main main.c ../mcmc.c

clean:
rm -f main main.o

dist: clean

distdir:
28 changes: 28 additions & 0 deletions tests/main.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
#include "utest.h"
#include "../mcmc.h"

struct tmc_fixt {
void *ctx;
};

UTEST_F_SETUP(tmc_fixt) {
utest_fixture->ctx = calloc(1, mcmc_size(MCMC_OPTION_BLANK));
ASSERT_TRUE(utest_fixture->ctx);
}

UTEST_F_TEARDOWN(tmc_fixt) {
free(utest_fixture->ctx);
}

UTEST_F(tmc_fixt, trial) {
mcmc_resp_t r;
char goodbuf[] = "VALUE foo 0 2\r\nhi\r\n";
char badbuf[] = "bad response\r\n";
int res = mcmc_parse_buf(utest_fixture->ctx, goodbuf, strlen(goodbuf), &r);
ASSERT_GE(res, MCMC_OK);

res = mcmc_parse_buf(utest_fixture->ctx, badbuf, strlen(badbuf), &r);
ASSERT_LT(res, MCMC_OK);
}

UTEST_MAIN()
Loading

0 comments on commit 626e86b

Please sign in to comment.