diff --git a/Makefile b/Makefile index bd9c9a7..e2ddaf1 100644 --- a/Makefile +++ b/Makefile @@ -8,6 +8,10 @@ install: @echo "Installing..." cd src && $(MAKE) install +test: + @echo "Testing..." + cd test && $(MAKE) + install-cli-only: @echo "Installing command line interface only..." cd src/scripts && $(MAKE) install @@ -19,7 +23,7 @@ uninstall: clean-old: cd src && $(MAKE) clean-old -.PHONY: clean +.PHONY: clean test clean: cd src && $(MAKE) clean diff --git a/test/Makefile b/test/Makefile new file mode 100644 index 0000000..fc2aa5f --- /dev/null +++ b/test/Makefile @@ -0,0 +1,37 @@ +CC=gcc +PKGCONFIG = $(shell which pkg-config) + +CFLAGS=`pkg-config --cflags gtk+-3.0` -I./../src/ui + +LIBS=`pkg-config --libs gtk+-3.0 --libs x11` -lstdc++ -lpng -lqrencode + + +ODIR=./../build + +# Determine this makefile's path. +# Be sure to place this BEFORE `include` directives, if any. +THIS_FILE := $(lastword $(MAKEFILE_LIST)) + +_OBJ = util.o test_util.o +OBJ = $(patsubst %,$(ODIR)/%,$(_OBJ)) + + +.PHONY: clean + +all: $(OBJ) test + + +$(ODIR)/util.o: ../src/ui/util.c + $(CC) -c $? -o $@ $(CFLAGS) + +$(ODIR)/test_util.o: test_util.c + $(CC) -c $? -o $@ $(CFLAGS) + +test: $(OBJ) + $(CC) -o $(ODIR)/test $^ + @$(ODIR)/test + +clean: + rm -f $(OBJ) + rm -f $(ODIR)/test + diff --git a/test/test_util.c b/test/test_util.c new file mode 100644 index 0000000..50b3037 --- /dev/null +++ b/test/test_util.c @@ -0,0 +1,14 @@ +#include +#include +#include + +int main(int argc, char *argv[]){ + + assert(0 == isValidIPaddress("192.12.23.123")); + assert(0 == isValidIPaddress("255.255.255.255")); + assert(-1 == isValidIPaddress("255.255.255.256")); + assert(-1 == isValidIPaddress("255.255.255.2551")); + assert(-1 == isValidIPaddress("192.168.12")); + + return 0; +} \ No newline at end of file