A lightweight, single-header TAP (Test Anything Protocol) library.
Copyright (c) 2025 Sanko Robinson
This source code is dual-licensed under the Artistic License 2.0 or the MIT License. You may choose to use this code under the terms of either license.
SPDX-License-Identifier: (Artistic-2.0 OR MIT)
The documentation blocks within this file are licensed under the Creative Commons Attribution 4.0 International License (CC BY 4.0).
SPDX-License-Identifier: CC-BY-4.0
This file provides a simple, self-contained testing harness that produces TAP-compliant output, which is ideal for integration with CI/CD systems and other testing tools. It is used for all unit and regression tests within the infix project.
The library is designed to be trivial to use:
- Define
DBLTAP_ENABLE and DBLTAP_IMPLEMENTATION in a single test file.
- Write all test logic within a function named
test_body(void) using the TEST macro.
- Use the provided macros (
plan, ok, subtest, etc.) to structure tests.
The library provides its own main function that initializes the harness, calls the user-defined test_body, and reports the final results.
Thread Safety
The design uses thread-local storage (_Thread_local, __thread) to manage the test state (test counts, subtest nesting, etc.). This allows multiple threads to run tests concurrently without interfering with each other's output or results, making it suitable for testing thread-safe code. Global counters use atomic operations where available to ensure correctness.