Add unit testing.
This commit is contained in:
parent
711e083563
commit
aa4fdf170d
2 changed files with 55 additions and 6 deletions
10
Makefile
10
Makefile
|
@ -5,19 +5,27 @@ LIBS = $(wildcard lib/**/*.c)
|
||||||
OBJS = $(patsubst %.c,%.o,$(DEPS) $(LIBS))
|
OBJS = $(patsubst %.c,%.o,$(DEPS) $(LIBS))
|
||||||
BINS = $(patsubst src/%,bin/%,$(patsubst %.c,%,$(SRC)))
|
BINS = $(patsubst src/%,bin/%,$(patsubst %.c,%,$(SRC)))
|
||||||
|
|
||||||
|
TEST_SRC = $(wildcard test/*.c)
|
||||||
|
TEST_BINS = $(patsubst test/%,bin/%,$(patsubst %.c,%.test,$(TEST_SRC)))
|
||||||
|
|
||||||
# CFLAGS = -std=c99 -Ideps -Wall -Wno-unused-function -U__STRICT_ANSI__
|
# CFLAGS = -std=c99 -Ideps -Wall -Wno-unused-function -U__STRICT_ANSI__
|
||||||
CFLAGS = -ggdb -std=c99 -Ideps -Ilib -Wall -Wno-unused-function -pedantic
|
CFLAGS = -ggdb -std=c99 -Ideps -Ilib -Wall -Wno-unused-function -pedantic
|
||||||
|
|
||||||
|
|
||||||
all: $(BINS)
|
all: $(BINS) $(TEST_BINS)
|
||||||
echo "BINS=$(BINS)"
|
echo "BINS=$(BINS)"
|
||||||
|
echo "TESTS=$(TEST_BINS)"
|
||||||
|
|
||||||
$(BINS): $(SRC) $(OBJS)
|
$(BINS): $(SRC) $(OBJS)
|
||||||
$(CC) $(CFLAGS) -o $@ src/$(notdir $@).c $(OBJS) $(LDFLAGS)
|
$(CC) $(CFLAGS) -o $@ src/$(notdir $@).c $(OBJS) $(LDFLAGS)
|
||||||
|
|
||||||
|
$(TEST_BINS): $(TEST_SRC) $(OBJS)
|
||||||
|
$(CC) $(CFLAGS) -o $@ test/$(notdir $(patsubst %.test,%.c,$@)) $(OBJS) $(LDFLAGS)
|
||||||
|
|
||||||
%.o: %.c
|
%.o: %.c
|
||||||
$(CC) $< -c -o $@ $(CFLAGS)
|
$(CC) $< -c -o $@ $(CFLAGS)
|
||||||
|
|
||||||
clean:
|
clean:
|
||||||
$(foreach c, $(BINS), rm -f $(c);)
|
$(foreach c, $(BINS), rm -f $(c);)
|
||||||
|
$(foreach c, $(TEST_BINS), rm -f $(c);)
|
||||||
rm -f $(OBJS)
|
rm -f $(OBJS)
|
||||||
|
|
41
test/csv-data-manipulation.c
Normal file
41
test/csv-data-manipulation.c
Normal file
|
@ -0,0 +1,41 @@
|
||||||
|
|
||||||
|
#include <minunit/minunit.h>
|
||||||
|
#include <libcsv/libcsv.h>
|
||||||
|
|
||||||
|
/*
|
||||||
|
CSV * csv;
|
||||||
|
|
||||||
|
printf("%s\n%s\n\n",TITLE, URL);
|
||||||
|
|
||||||
|
csv = csv_create(0, 0);
|
||||||
|
csv_open(csv, "fixtures/csv-data-manipulation.csv");
|
||||||
|
csv_display(csv);
|
||||||
|
|
||||||
|
csv_set(csv, 0, 0, "Column0");
|
||||||
|
csv_set(csv, 1, 1, "100");
|
||||||
|
csv_set(csv, 2, 2, "200");
|
||||||
|
csv_set(csv, 3, 3, "300");
|
||||||
|
csv_set(csv, 4, 4, "400");
|
||||||
|
csv_display(csv);
|
||||||
|
|
||||||
|
csv_save(csv, "tmp/csv-data-manipulation.result.csv");
|
||||||
|
csv_destroy(csv);
|
||||||
|
*/
|
||||||
|
|
||||||
|
MU_TEST(test_check) {
|
||||||
|
mu_check(5 == 7);
|
||||||
|
}
|
||||||
|
|
||||||
|
MU_TEST_SUITE(test_suite) {
|
||||||
|
MU_RUN_TEST(test_check);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Test
|
||||||
|
*/
|
||||||
|
int main(int argc, char ** argv) {
|
||||||
|
MU_RUN_SUITE(test_suite);
|
||||||
|
MU_REPORT();
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in a new issue