Upp11 - C++11 lightweight single header unit test framework

upp11

Lightweight C++11 single header unit test framework

To use framework:

  1. Copy upp11.h in you project dir.
  2. Create unit test source files or modify existing file
#include "upp11.h"
  1. Write the tests
UP_TEST(test1)
{
	// test code
}

// tuple - for example. Any type possible, but params should be monotypes.
const auto params = {
	make_tuple(1, "str1"),
	make_tuple(2, "str222")
	// etc
};

UP_PARAMETRIZED_TEST(test2, params)
{
	const auto i = get<0>(params);
	const auto s = get<1>(params);
	// parametrized test code
}

struct fixture {
};

UP_FIXTURE_TEST(test3, fixture)
{
	// test code with fixture
}

// parametrized with fixture available too...
  1. Using test assertions
UP_TEST(test)
{
	UP_ASSERT(0 < 1);
	UP_ASSERT_EQUAL("right", "right");
	UP_ASSERT_NE(list<int>{1, 2, 3, 4, 5 }, vector<int>{5, 4, 3, 2, 1});

	// check exception by type
	UP_ASSERT_EXCEPTION(runtime_error, []{
		// code under test here...
	});

	// check exception by what
	UP_ASSERT_EXCEPTION(runtime_error, "exception message", []{
		// code under test here...
	});
}
  1. Group tests
UP_SUITE_BEGIN(suite_name);

// tests and child suites here

UP_SUITE_END();
  1. Compile and run the test
// once for all test source files of test runner
UP_MAIN();
$ runner [-q] [-t] [-s <seed>]
  1. Enjoy
Owner
Similar Resources

Kernel-mode C++ unit testing framework in BDD-style

There is a lack of unit testing frameworks that work in OS kernel. This library closes that gap and is targeted for windows driver developers.

Jun 11, 2022

The fastest feature-rich C++11/14/17/20 single-header testing framework

The fastest feature-rich C++11/14/17/20 single-header testing framework

master branch Windows All dev branch Windows All doctest is a new C++ testing framework but is by far the fastest both in compile times (by orders of

Aug 12, 2022

The fastest feature-rich C++11/14/17/20 single-header testing framework

The fastest feature-rich C++11/14/17/20 single-header testing framework

master branch dev branch doctest is a new C++ testing framework but is by far the fastest both in compile times (by orders of magnitude) and runtime c

Aug 17, 2022

End to end test framework designed for Juce applications

JUCE End to End test framework What is it? This package provides a mechanism to end-to-end test a JUCE application Prerequisites CMake. Must be 3.18 o

Aug 8, 2022

Handy C++ test framework

C++ Voyager Test Framework Voyager is a simple and handy C++ Unit Test framework. It is designed to be beautiful and expressive both. Try it to feel i

Mar 16, 2022

A micro unit-testing library for C/C++

µ-test A micro unit testing framework for C/C++ to get you up and running with unit-testing ASAP (even without libc). Usage Simply include the C and h

Dec 8, 2021

📝 One of the difficult unit tester for ft_containers project

📝 One of the difficult unit tester for ft_containers project

ft_containers-unit-test About ft containers unit test is a complete testing for project of school 21/ecole 42 and allowing you test your containers: V

Aug 7, 2022

Simple, fast, accurate single-header microbenchmarking functionality for C++11/14/17/20

ankerl::nanobench ankerl::nanobench is a platform independent microbenchmarking library for C++11/14/17/20. #includ

Aug 8, 2022

PlatformIO + BL602 Bouffalo Arduino Core Test

 PlatformIO + BL602 Bouffalo Arduino Core Test

PlatformIO + BL602 Bouffalo Arduino Core Test Description Uses A custom extension of the PlatformIO SiFive Platform (https://github.com/maxgerhardt/pl

May 31, 2022
Comments
  • framework does not compile for nullptr assert

    framework does not compile for nullptr assert

    when comparing UP_ASSERT_EQUAL or UP_ASSERT_NE with nullptr, it gives a following error:

    upp11.h:368:6: error: ambiguous overload for ‘operator<<’ (operand types are ‘std::ostringstream {aka std::basic_ostringstream}’ and ‘std::nullptr_t’) os << tt;

  • Add missing include.

    Add missing include.

    Fixes compile error on mac OS X.

    upp11 uses std::default_random_engine which is defined in , so it is odd that this even builds on linux. Regardless, this included is needed to build with upp11 on Mac OS X.

Related tags
A modern, C++-native, header-only, test framework for unit-tests, TDD and BDD - using C++11, C++14, C++17 and later (or C++03 on the Catch1.x branch)
A modern, C++-native, header-only, test framework for unit-tests, TDD and BDD - using C++11, C++14, C++17 and later (or C++03 on the Catch1.x branch)

Catch2 v3 is being developed! You are on the devel branch, where the next major version, v3, of Catch2 is being developed. As it is a significant rewo

Aug 16, 2022
A modern, C++11-native, single-file header-only, tiny framework for unit-tests, TDD and BDD (includes C++98 variant)

lest – lest errors escape testing This tiny C++11 test framework is based on ideas and examples by Kevlin Henney [1,2] and on ideas found in the CATCH

Aug 5, 2022
Various Framework to do Unit Test in C++
Various Framework to do Unit Test in C++

Unit Test in C++ There are many frameworks to performs unit test in C++, we will present the most popular ones and show how to use them. The testing f

Nov 18, 2021
TestFrame - This is a test framework that uses Raylib and ImGui together to help test and develop concepts
TestFrame - This is a test framework that uses Raylib and ImGui together to help test and develop concepts

This is a test framework that uses Raylib and ImGui together to help test and develop concepts. It is made using C++ because it uses classes for windows and views.

May 13, 2022
The C Unit Testing Library on GitHub is a library designed for easy unit testing in C

The C Unit Testing Library on GitHub is a library designed for easy unit testing in C. It was written by Brennan Hurst for the purpose of providing a J-Unit-like testing framework within C for personal projects.

Oct 11, 2021
A dynamic mock tool for C/C++ unit test on Linux&MacOS X86_64

lmock 接口 替换一个函数,修改机器指令,用新函数替换旧函数,支持全局函数(包括第三方和系统函数)、成员函数(包括静态和虚函数)

Jul 28, 2022
A complete unit testing framework in a header

liblittletest A complete unit testing framework in a header liblittletest is an easy to use all-in-an-header testing framework; all you have to do in

Nov 11, 2021
C unit tests with a small header-only library.
C unit tests with a small header-only library.

C unit tests Minimalistic unit tests in C. Uses the __attribute__((constructor)) which, as far as I know, is supported by GCC and clang. So this proba

May 10, 2022
UT: C++20 μ(micro)/Unit Testing Framework
UT: C++20 μ(micro)/Unit Testing Framework

"If you liked it then you "should have put a"_test on it", Beyonce rule UT / μt | Motivation | Quick Start | Overview | Tutorial | Examples | User Gui

Aug 7, 2022
Modern c++17 unit testing framework on Microsoft Windows, Apple macOS, Linux, iOS and android.
Modern c++17 unit testing framework on Microsoft Windows, Apple macOS, Linux, iOS and android.

tunit Modern c++17 unit testing framework on Windows, macOS, Linux, iOS and android. Continuous Integration build status Operating system Status Windo

Apr 5, 2022