Skip to main content

doctest for C/C++ which run tests by using clang-repl interaction comments.

Project description

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

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

cdoctest-1.3.18-py3-none-any.whl (21.0 kB view details)

Uploaded Python 3

File details

Details for the file cdoctest-1.3.18-py3-none-any.whl.

File metadata

  • Download URL: cdoctest-1.3.18-py3-none-any.whl
  • Upload date:
  • Size: 21.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.2

File hashes

Hashes for cdoctest-1.3.18-py3-none-any.whl
Algorithm Hash digest
SHA256 2c4d9a77eab4ae69c4a1efb208a6e1de37d75a7394dbcf0b5245cc67c32cf926
MD5 eda477eadd46837701914f3f74b0c676
BLAKE2b-256 ec2086843366197b985665c5c45f378da79ee60347f50b98f4be2a428b4c2ccf

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page