infix
A JIT-Powered FFI Library for C
Loading...
Searching...
No Matches
double_tap.h File Reference

A lightweight, single-header TAP (Test Anything Protocol) library. More...

This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Macros

#define plan(count)   ((void)0)
 
#define done()   (0)
 
#define bail_out(...)
 
#define ok(cond, ...)   (true)
 
#define pass(...)   ((void)0)
 
#define fail(...)   ((void)0)
 
#define subtest(name)   if (0)
 
#define skip(count, ...)   ((void)0)
 
#define skip_all(...)   ((void)0)
 
#define TODO(reason, ...)   if (0)
 
#define diag(...)   ((void)0)
 
#define note(...)   ((void)0)
 
#define TEST    int main(void) { return 0; }
 

Detailed Description

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:

  1. Define DBLTAP_ENABLE and DBLTAP_IMPLEMENTATION in a single test file.
  2. Write all test logic within a function named test_body(void) using the TEST macro.
  3. 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.

Macro Definition Documentation

◆ bail_out

#define bail_out (   ...)
Value:
do { \
fprintf(stderr, "Bail out! "); \
fprintf(stderr, __VA_ARGS__); \
fprintf(stderr, "\n"); \
exit(1); \
} while (0)

◆ diag

#define diag (   ...)    ((void)0)

◆ done

#define done ( )    (0)

◆ fail

#define fail (   ...)    ((void)0)

◆ note

#define note (   ...)    ((void)0)

◆ ok

#define ok (   cond,
  ... 
)    (true)

◆ pass

#define pass (   ...)    ((void)0)

◆ plan

#define plan (   count)    ((void)0)

◆ skip

#define skip (   count,
  ... 
)    ((void)0)

◆ skip_all

#define skip_all (   ...)    ((void)0)

◆ subtest

#define subtest (   name)    if (0)

◆ TEST

#define TEST    int main(void) { return 0; }

◆ TODO

#define TODO (   reason,
  ... 
)    if (0)