- Use CMocka, Unity, or Check for unit testing. Structure tests in a separate `tests/` directory.
- Use `assert`-style macros for test assertions. Each test function should test one behavior.
- Compile tests as a separate binary with their own `main()` — link against the production library, not the production `main()`.
- Use setup/teardown functions for allocating and freeing test resources.
- Use mock functions (CMocka `will_return`, `expect_*`) for isolating dependencies.
- Compile tests with AddressSanitizer (`-fsanitize=address`) to catch memory errors during testing.
- Test boundary conditions: NULL pointers, empty buffers, maximum sizes, integer overflow.