cipra  1.2.1
A C++11 Unit Testing Framework based on Test::More
 All Classes Namespaces Functions Variables Typedefs Pages
cipra Documentation
Version 1.2

cipra is a simple, TAP-compatible Unit Testing Framework for C++. cipra is Free and Open Source Software, released under a 3-clause BSD-style license. It's written in 100% standard C++11 and is only a couple header files, making it easy to include in your C++11 project.

TAP, the Test Anything Protocol, is a standard output format for software unit test frameworks that was originally designed for Perl, but can serve other languages. It has a rich number of tools ("harnesses") that parse TAP formatted output and do useful things with it. TAP, however, is equally human-readable.

The name cipra (pronounced /ˈʃi.pɾaː/ "SHEE-prah") comes from the lojban phrase "lo cipra", which means "the test". It is properly written with an initial minuscule 'c', even when at the start of a sentence.

Included in this distribution are several other files for your reference:


You can find a tutorial on the Tutorial page or in the file in the doc/ directory.

Where possible, cipra's test interface is analogous to Perl's Test::More module.

To use cipra, just include the cipra.hpp header file in your test file. You do not need to link to any library. All methods are inline in the header files; there is no need to compile cipra.

// -*- c++ -*-
/* This file is a part of the cipra Unit Testing Framework.
* Copyright (C) 2012, Patrick M. Niedzielski.
* All rights reserved.
* See accompanying COPYING.bsd file for the license. When
* distributing this file independently , it's a good idea to replace
* this reference with the full license.
// Uncomment on GCC and other compilers that support abi:: functions.
//#define CIPRA_CXA_ABI
#include <cipra.hpp>
int main(int argc, char* argv[])
struct my_fixture : cipra::fixture {
virtual void test() override // define this function to run tests
plan(17); // Run 17 tests.
ok([]() { return true; }, "ok() succeeds on true");
ok([]() { return false; }, "ok() fails on false");
ok([]() { throw 0; return true; }, "ok() fails on throw");
ok(true, "ok() with just boolean arguments works");
throws([]() { throw 0; }, "throws() detects int throw");
throws([]() { }, "throws() fails on no throw");
throws<int>([]() { throw 0; }, "throws<int>() detects int throw");
throws<int>([]() { throw 'a'; },
"throws<int>() fails on char throw");
throws<int>([]() { }, "throws<int>() fails on no throw");
nothrows([]() { }, "nothrows() accepts no throw");
nothrows([]() { throw 0; }, "nothrows() fails on int throw");
nothrows<int>([]() { throw 'a'; },
"nothrows<int>() accepts char throw");
nothrows<int>([]() {}, "nothrows<int>() accepts no throw");
nothrows<int>([]() { throw 0; },
"nothrows<int>() fails on int throw");
// See the file variadic.cpp for examples of the
// new_ok<>() function.
pass("Will pass automatically.");
pass("No matter what.");
fail("Always fails.");
is(5, 5, "5 == 5");
is(5, 6, "5 == 6; this should fail.");
is(std::string("cipra"), std::string("cipra"), "String equality");
isnt(5, 6, "5 != 6");
isnt(5, 5, "5 != 5; this should fail.");
isnt(std::string(";,.pyfgcrl"), std::string("qwertyuiop"),
"Programmer Dvorak is not QWERTY");
} test;