Commit 44edc9a0 authored by jkvis's avatar jkvis
Browse files

Added test framework

parent e59a2cd6
CC = gcc CC = gcc
CFLAGS = -O3 -march=native CFLAGS = -O3 -march=native
CPPFLAGS = -Iinclude/ -Ilib/sais-lite-lcp/ -Wall -Wextra -pedantic CPPFLAGS = -Iinclude/ -Ilib/sais-lite-lcp/ -DNDEBUG -Wall -Wextra -pedantic
SOURCES = $(shell find src/ -name '*.c') SOURCES = $(shell find src/ -name '*.c')
OBJECTS = $(SOURCES:.c=.o) OBJECTS = $(SOURCES:.c=.o)
DEPS = $(OBJECTS:.o=.d) DEPS = $(OBJECTS:.o=.d)
LIBS = $(shell find lib/ -name '*.a') LIBS = $(shell find lib/ -name '*.a')
.PHONY: clean .PHONY: clean tests
libgesa.a: $(LIBS) $(OBJECTS) libgesa.a: $(LIBS) $(OBJECTS)
$(MAKE) -wC lib/ $(MAKE) -wC lib/
ar rcsT $@ $(LIBS) $(OBJECTS) ar rcsT $@ $(LIBS) $(OBJECTS)
tests: libgesa.a
$(MAKE) -wC tests/
clean: clean:
rm -f $(OBJECTS) $(DEPS) libgesa.a rm -f $(OBJECTS) $(DEPS) libgesa.a
......
CXXC = g++
CXXFLAGS = -O0 -march=native
CPPFLAGS = -I../include/ -Wall -Wextra -pedantic
SOURCES = $(shell find . -name '*.cc')
OBJECTS = $(SOURCES:.cc=.o)
DEPS = $(OBJECTS:.o=.d)
TARGET = gesa_test
.PHONY: all clean memory_check
all: $(TARGET)
./$<
memory_check: $(TARGET)
valgrind --leak-check=full ./$<
$(TARGET): $(OBJECTS)
$(CXXC) $(CXXFLAGS) $(CPPFLAGS) $(OBJECTS) -L.. -lgesa -o $@
clean:
rm -f $(OBJECTS) $(TARGET)
-include $(DEPS)
%.o: %.cc
$(CXXC) $(CXXFLAGS) $(CPPFLAGS) -MMD -o $@ -c $<
#include <cassert>
#include <cstdio> #include <cstdio>
#include <cstdlib> #include <cstdlib>
...@@ -10,7 +11,7 @@ int main(int, char* []) ...@@ -10,7 +11,7 @@ int main(int, char* [])
GESA test; GESA test;
if (GESA_create(&test, (GESA_char_t*) string, 9) != 0) if (GESA_create(&test, (GESA_char_t*) string, 8) != 0)
{ {
fprintf(stderr, "Error GESA_create()\n"); fprintf(stderr, "Error GESA_create()\n");
return EXIT_FAILURE; return EXIT_FAILURE;
...@@ -18,5 +19,7 @@ int main(int, char* []) ...@@ -18,5 +19,7 @@ int main(int, char* [])
printf("%s\n", test.string[0]); printf("%s\n", test.string[0]);
GESA_destroy(&test, GESA_KEEP_STRINGS);
return EXIT_SUCCESS; return EXIT_SUCCESS;
} // main } // main
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment