Add unit test suite and complete protocol documentation

- Add test framework (test.h) with assertion macros and test runner
- Add comprehensive unit tests (test_network.c) covering:
  - Packet parsing and error handling
  - User registration and authentication
  - Room operations (create, join, leave, delete, list)
  - Direct messaging functionality
  - Message broadcasting
  - Password hashing
- Update Makefile with 'make test' target
- Rewrite PROTOCOL file with complete specification:
  - All 14 packet types with data layouts
  - All error codes with descriptions
  - Typical usage flows
This commit is contained in:
Lorenzo Torres 2026-01-08 15:38:28 +01:00
parent 670e38a105
commit 238eff5bb3
9 changed files with 2156 additions and 27 deletions

View file

@ -30,8 +30,17 @@ users.h:
asfur: ${OBJ}
${CC} -o $@ ${OBJ} ${LDFLAGS}
test: test_network
./test_network
test_network: test_network.o network.o password.o
${CC} -o $@ test_network.o network.o password.o ${LDFLAGS}
test_network.o: test_network.c test.h network.h client.h password.h
${CC} -c ${CFLAGS} test_network.c
clean:
rm -f asfur ${OBJ} asfur-${VERSION}.tar.gz
rm -f asfur test_network ${OBJ} test_network.o asfur-${VERSION}.tar.gz
dist: clean
mkdir -p asfur-${VERSION}
@ -53,4 +62,4 @@ uninstall:
rm -f ${DESTDIR}${PREFIX}/bin/asfur\
${DESTDIR}${MANPREFIX}/man1/asfur.1
.PHONY: all options clean dist install uninstall
.PHONY: all options clean dist install uninstall test