Test multiple C++ standards; move tests to top level

This commit is contained in:
Josh Holtrop 2026-02-24 18:06:16 -05:00
parent 403db54664
commit 011460254d
4 changed files with 23 additions and 21 deletions

2
.gitignore vendored
View File

@ -1 +1 @@
/test/build/
/build/

View File

@ -1,7 +1,23 @@
.PHONY: test
test:
$(MAKE) -C test
# This Makefile is entirely for running unit tests for rcp.h
INCLUDE := include
STANDARDS := 11 14 17 20 23
BINARIES := $(addprefix build/tests-, $(STANDARDS))
.PHONY: all
all: $(BINARIES)
@for std in $(STANDARDS); do \
echo "=== Test C++$$std ==="; \
build/tests-$$std; \
valgrind --leak-check=full --error-exitcode=1 \
--log-file=build/valgrind-$$std.log build/tests-$$std \
|| { echo "valgrind failed for C++$$std (see build/valgrind-$$std.log)"; exit 1; }; \
done
build/tests-%: tests.cpp $(INCLUDE)/rcp.h
@mkdir -p $(dir $@)
$(CXX) -std=c++$* -g -Wall -I$(INCLUDE) -o $@ $<
.PHONY: clean
clean:
$(MAKE) -C test clean
rm -rf build

View File

@ -1,14 +0,0 @@
INCLUDE := ../include
.PHONY: all
all: build/tests
build/tests
valgrind --leak-check=full --error-exitcode=1 --log-file=build/valgrind.log build/tests
build/tests: tests.cpp $(INCLUDE)/rcp.h
mkdir -p $$(dirname $@)
$(CXX) -std=c++20 -g -Wall -I$(INCLUDE) -o $@ $<
.PHONY: clean
clean:
rm -rf build

View File

@ -114,11 +114,11 @@ void test_multi_construct_from_raw_pointers()
{
Receiver r;
auto myo = MyObj::create();
for (size_t i = 0u; i < 5u; i++)
for (int i = 0; i < 5; i++)
{
myo->add_to(r);
}
for (size_t i = 0u; i < 5u; i++)
for (int i = 0; i < 5; i++)
{
assert(r.objects[i]->v == 42);
}