Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Human-friendly unit testing for C++11

License

NotificationsYou must be signed in to change notification settings

banditcpp/bandit

Repository files navigation

MIT LicenseContributorsWatchersStarsForksCommits per yearLast commitTravis CI StatusAppVeyor StatusCodecov BadgeCodacy BadgeCoverity Scan Build StatusIssuesPull RequestsfreenodeConan Center

Human-friendly unit testing for C++11

Bandit is a framework for C++11 that wants to make working with unit tests apleasant experience.

An example

This is a complete test application written in bandit:

#include<bandit/bandit.h>usingnamespacesnowhouse;usingnamespacebandit;// Tell bandit there are tests here.go_bandit([]() {// We're describing how a fuzzbox works.describe("fuzzbox", []() {    guitar_ptr guitar;    fuzzbox_ptr fuzzbox;// Make sure each test has a fresh setup with// a guitar with a fuzzbox connected to it.before_each([&]() {      guitar =guitar_ptr(newstructguitar());      fuzzbox =fuzzbox_ptr(newstructfuzzbox());      guitar->add_effect(fuzzbox.get());    });it("starts in clean mode", [&]() {AssertThat(guitar->sound(),Equals(sounds::clean));    });// Describe what happens when we turn on the fuzzbox.describe("in distorted mode", [&]() {// Turn on the fuzzbox.before_each([&]() {        fuzzbox->flip();      });it("sounds distorted", [&]() {AssertThat(guitar->sound(),Equals(sounds::distorted));      });    });  });});intmain(int argc,char* argv[]) {// Run the tests.returnbandit::run(argc, argv);}

Download

Clone the Git repository:

git clone --recursive https://github.com/banditcpp/bandit.git

or if you have already cloned the repository without--recursive, do

cd banditgit submodule update --init --recursive

The Git repository contains several directories besides bandit itself,that is, the specifications (or tests) for bandit (inspecs),the bandit website and documentation (indocs),and auxiliary tools for CMake (incmake) and continuous integration (inutil).

Installation

Bandit is header-only, so there is no need for additional compilation before youcan start using it. (CMake is only necessary to compile the specs for bandit itself.)

If you want to use bandit inside your projects,add the parent directory of thebandit directory to your project'sinclude directories and you are ready to go.

Note that you can remove all directories except thebandit directory.Also keep license and copyright information intact.You can also simply use theheaders-only branch as a submodule:

git submodule add -b headers-only https://github.com/banditcpp/bandit banditgit submodule update --init --recursive

Compilers

Bandit has been tested with the following compilers:

  • GCC ≥ 4.5
  • Clang ≥ 3.2
  • MSVC ≥ 2012

If you want to see if bandit works for your compiler, bandit is shipped with acmake project for generating bandit's self tests. Let us know how it goes.

If your compiler does not support the C++11 features required by Bandit, wesuggest that you take a look atIgloo, which isbuilt on the same philosophy but works without C++11.

Online resources


[8]ページ先頭

©2009-2025 Movatter.jp