diff options
| author | Richard Qin <richard.qin.x@gmail.com> | 2026-09-24 19:22:15 +0800 |
|---|---|---|
| committer | Richard Qin <richard.qin.x@gmail.com> | 2026-09-24 19:22:15 +0800 |
| commit | 679fa4f220c40e552d4ba4e67669680f10c21a6d (patch) | |
| tree | 8d034761edc23e450577126f928a474c80b6ca0d /lab01/Makefile | |
| download | RUCDSA-679fa4f220c40e552d4ba4e67669680f10c21a6d.tar.gz RUCDSA-679fa4f220c40e552d4ba4e67669680f10c21a6d.tar.xz | |
lab01
Diffstat (limited to 'lab01/Makefile')
| -rw-r--r-- | lab01/Makefile | 51 |
1 files changed, 51 insertions, 0 deletions
diff --git a/lab01/Makefile b/lab01/Makefile new file mode 100644 index 0000000..527d7ed --- /dev/null +++ b/lab01/Makefile @@ -0,0 +1,51 @@ +CXX := g++ +CXXFLAGS := -std=c++11 -Wall -Wextra -Wpedantic -O2 + +TARGET := triplet +SOURCE := main.cc +HEADER := Triplet.hh + +.PHONY: build test + +build: $(TARGET) + +$(TARGET): $(SOURCE) $(HEADER) + $(CXX) $(CXXFLAGS) $(SOURCE) -o $(TARGET) + +test: build + @passed=0; \ + failed=0; \ + total=0; \ + for input in *.in; do \ + if [ ! -f "$$input" ]; then \ + continue; \ + fi; \ + total=$$((total + 1)); \ + base=$${input%.in}; \ + expected="$$base.out"; \ + actual="$$base.actual"; \ + if [ ! -f "$$expected" ]; then \ + echo "[FAIL] $$input: missing $$expected"; \ + failed=$$((failed + 1)); \ + continue; \ + fi; \ + if ./$(TARGET) < "$$input" > "$$actual"; then \ + if diff -u "$$expected" "$$actual" > /dev/null; then \ + echo "[PASS] $$base"; \ + passed=$$((passed + 1)); \ + else \ + echo "[FAIL] $$base"; \ + diff -u "$$expected" "$$actual" || true; \ + failed=$$((failed + 1)); \ + fi; \ + else \ + echo "[FAIL] $$base: program exited with an error"; \ + failed=$$((failed + 1)); \ + fi; \ + rm -f "$$actual"; \ + done; \ + echo; \ + echo "Passed: $$passed / $$total"; \ + if [ "$$failed" -ne 0 ]; then \ + exit 1; \ + fi |
