# Testing Every project here is tested the same way, with a convention the course called file-per-test. There is no Catch2 or GoogleTest. The whole harness is `` and the Makefile, which is the point: you see exactly what a test does because there is nothing between you and the assertion. ## One file, one test program Each `test_*.cpp` is a complete program with its own `main`. It does three things in order: 1. Set up a fixture (construct the objects under test). 2. Run the operation being tested. 3. Check the outcome with `assert`. A test usually packs several cases into separate `{ }` blocks so each one has its own scope. Here is the shape, from the BigInt addition test: ```cpp { bigint left(9); bigint right(1); bigint result; result = left + right; // run assert(left == 9); // verify assert(right == 1); assert(result == 10); } ``` If every assertion holds, the program prints a short "done" line and exits 0. The first assertion that fails calls `abort`, which exits non-zero, so a passing run and a clean exit code mean the same thing. ## How the Makefile builds them Each project's Makefile has a pattern rule that compiles any `test_*.cpp` against the class object file: ```make test_%: string.o test_%.o $(CPP) $(OPTIONS) string.o test_$*.o -o test_$* ``` and a `tests` target that builds the whole list and runs each binary in sequence. So `make tests` is the one command that checks a project. ## What each project tests - **BigInt**: constructors, equality, addition, multiplication, subscript, and the `times10` / `timesDigit` helpers. - **Custom String**: constructors, copy, assignment and swap, equality, less-than, concatenation, subscript, length and capacity, input, substring, find-char, find-string, and split. - **Assembler**: the stack, with default and copy construction, assignment, destruction, and push/pop across `int`, `double`, and `String`. ## A note on the generic test files Some folders contain `test_generic_*.cpp` files. These are the course's blank templates, with placeholder tokens like `X` and `YYY` where the real values would go. They are meant to be copied and filled in, so they do not compile or pass as written. The CI workflow skips any file matching `test_generic_*` and runs the rest. ## Running tests in CI The GitHub Actions workflow compiles each class and its tests with `g++ -std=c++11` and runs every non-template test. The course Makefiles pin `clang++` and `-std=c++17` and several run targets read data files from the project directory, so CI compiles directly rather than calling `make`. The code builds clean under both toolchains.