Skip to main content

C/C++ DocTest

A C/C++ DocTest that runs tests using clang-repl interaction in comments. Supports Linux (macOS is untested).

Prerequisites

  • clang-repl-kernel version 0.1.8
  • libclang must be installed and functioning properly

Usage

sample.cpp

#include "sample.h"
namespace test {
/**
>>> test::Fac fac;
>>> %<< fac.fac(7);
5040
*/
int Fac::fac(int n) {
    return (n > 1) ? n * fac(n - 1) : 1;
}
/**
>>> test::Fac fac;
>>> %<< fac.fac2(5);
120
*/
int Fac::fac2(int n) {
    return (n > 1) ? n * fac(n - 1) : 1;
}
}

sample.h

#pragma once
/**
>>> test::Fac fac;
>>> %<< fac.fac(5);
120
>>> %<< fac.fac2(5);
120
*/
namespace test {
class Fac {
public:
/**
>>> test::Fac fac;
>>> %<< fac.fac(5);
120
*/
    int fac(int n);
    int fac2(int n);
};
}

Building the Shared Library on Linux

clang -c -o sample.o sample.cpp
clang -shared sample.o -o sample.so

Building the DLL on Windows

clang-cl -c -o sample.o sample.cpp
clang -shared sample.o -o sample.dll

Running Tests with Source Code and Shared Library on Linux

python3 -m cdoctest -cdtt=sample.h -cdtl=sample.so -cdtip=.

Running Tests with Source Code and DLL on Windows

python -m cdoctest -cdtt=sample.h -cdtl=sample.dll -cdtip=.

Support vscode extension

Can be used with vscode extension cdoctest_vscode_extension

Metadata

Release files for cdoctest 1.4.20

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Built distribution (wheel)

Table of built distributions (wheels) for cdoctest 1.4.20
File Interpreter ABI Platform
cdoctest-1.4.20-py3-none-any.whl Python 3 none any Details

Release files / cdoctest-1.4.20-py3-none-any.whl

Download URL cdoctest-1.4.20-py3-none-any.whl
Size 21.3 kB
Tags Python 3
SHA-256 checksum
How to use checksums
166fdd6d2fea5bfb745ad71bc0b3733b2be14c5fbd22023d42c7665db8161fac
BLAKE2b-256 checksum
How to use checksums
877e47899fe6115482a82cf9b7f790e9d6cced114e686145e92055f9ae9f3f52
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.13.2

Release history Release notifications | RSS feed

This release

1.4.20 This release

1 release file

1.4.18

1 release file

1.3.18

1 release file

1.1.0

1 release file

0.0.5

1 release file

0.0.2

1 release file

0.0.1

1 release file

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page