mirror of
https://github.com/krgamestudios/Toy.git
synced 2026-04-15 14:54:07 +10:00
Working on refactoring, read more
The main program segfaults, but right now I'm working on the tests, mainly.
This commit is contained in:
@@ -9,11 +9,17 @@ TARGETS = $(filter-out $(wildcard ../source/*main.c),$(wildcard ../source/*.c))
|
||||
TESTS = $(wildcard *.c)
|
||||
OBJ = $(addprefix $(ODIR)/,$(TARGETS:../source/%.c=%.o)) $(addprefix $(ODIR)/,$(TESTS:.c=.o))
|
||||
|
||||
.PRECIOUS: $(TESTS:%.c=../$(OUTDIR)/%.exe)
|
||||
|
||||
all: $(OBJ) $(TESTS:%.c=../$(OUTDIR)/%.exe)
|
||||
|
||||
../$(OUTDIR)/%.exe: $(ODIR)/%.o
|
||||
@$(CC) -o $@ $< $(TARGETS:../source/%.c=$(ODIR)/%.o) $(CFLAGS) $(LIBS)
|
||||
$@
|
||||
ifeq ($(shell uname),Linux)
|
||||
valgrind $@
|
||||
else
|
||||
@echo please run these tests with valgrind on linux
|
||||
endif
|
||||
|
||||
$(OBJ): | $(ODIR)
|
||||
|
||||
@@ -29,4 +35,4 @@ $(ODIR)/%.o: ../source/%.c
|
||||
.PHONY: clean
|
||||
|
||||
clean:
|
||||
$(RM) $(ODIR)
|
||||
$(RM) $(ODIR)
|
||||
|
||||
@@ -49,12 +49,6 @@ int main() {
|
||||
freeLiteral(literal);
|
||||
}
|
||||
|
||||
//check allocated memory
|
||||
if (getAllocatedMemoryCount() != 0) {
|
||||
fprintf(stderr, ERROR "ERROR: Dangling memory detected: %d byes\n" RESET, getAllocatedMemoryCount());
|
||||
return -1;
|
||||
}
|
||||
|
||||
printf(NOTICE "All good\n" RESET);
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -67,12 +67,6 @@ int main() {
|
||||
freeLiteralArray(&array);
|
||||
}
|
||||
|
||||
//check allocated memory
|
||||
if (getAllocatedMemoryCount() != 0) {
|
||||
fprintf(stderr, ERROR "ERROR: Dangling memory detected: %d byes\n" RESET, getAllocatedMemoryCount());
|
||||
return -1;
|
||||
}
|
||||
|
||||
printf(NOTICE "All good\n" RESET);
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -10,11 +10,6 @@ int main() {
|
||||
int* integer = ALLOCATE(int, 1);
|
||||
|
||||
FREE(int, integer);
|
||||
|
||||
if (getAllocatedMemoryCount() != 0) {
|
||||
fprintf(stderr, ERROR "ERROR: integer failed to be allocated and freed correctly\n" RESET);
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
{
|
||||
@@ -22,11 +17,6 @@ int main() {
|
||||
int* array = ALLOCATE(int, 10);
|
||||
|
||||
FREE_ARRAY(int, array, 10);
|
||||
|
||||
if (getAllocatedMemoryCount() != 0) {
|
||||
fprintf(stderr, ERROR "ERROR: integer array failed to be allocated and freed correctly\n" RESET);
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
{
|
||||
@@ -36,11 +26,6 @@ int main() {
|
||||
|
||||
FREE_ARRAY(int, array1, 10);
|
||||
FREE_ARRAY(int, array2, 10);
|
||||
|
||||
if (getAllocatedMemoryCount() != 0) {
|
||||
fprintf(stderr, ERROR "ERROR: integer array failed to be allocated and freed correctly\n" RESET);
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
printf(NOTICE "All good\n" RESET);
|
||||
|
||||
Reference in New Issue
Block a user