Skip to content

Commit

Permalink
Implement a first version of a simple test
Browse files Browse the repository at this point in the history
  • Loading branch information
thoni56 committed Jan 15, 2018
1 parent a5409f6 commit 58a5857
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 3 deletions.
1 change: 1 addition & 0 deletions src/tests/.gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
pycparser
*.so
*.d
4 changes: 3 additions & 1 deletion src/tests/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

vpath %.c ..

CFLAGS = -fPIC
CFLAGS = -fPIC -g -MMD

all: filetab.so
cgreen-runner $^
Expand All @@ -12,3 +12,5 @@ filetab.so: filetab_tests.o filetab.o misc_mock.o commons_mock.o

clean:
rm *.o *.so

-include *.d
13 changes: 12 additions & 1 deletion src/tests/filetab_tests.c
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,15 @@ Describe(FileTab);
BeforeEach(FileTab) {}
AfterEach(FileTab) {}

Ensure(FileTab, can_fetch_a_stored_filename) {}
static struct fileTab fileTab;

Ensure(FileTab, can_fetch_a_stored_filename) {
S_fileItem fileItem = {"file.c"};
int position = 1;
int fetched_position;

fileTabInit(&fileTab, 5);
fileTabAdd(&fileTab, &fileItem, &position);
assert_that(fileTabIsMember(&fileTab, &fileItem, &fetched_position));
assert_that(fetched_position, is_equal_to(position));
}
2 changes: 1 addition & 1 deletion src/tests/misc_mock.c
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ void stackMemoryInit() {
}

void *stackMemoryAlloc(int size) {
return (void *) mock(size);
return (void *) malloc(size);
}

void *stackMemoryPush(void *p, int size) {
Expand Down

0 comments on commit 58a5857

Please sign in to comment.