C++14 单元测试框架:mettle

jopen 10年前

mettle是一个适用于C++14的单元测试框架。它的目的是最大限度地提高可读性和清晰度,让您专注于写作的测试。

A picture is worth a thousand words, and code's almost as good (I'm sure it's worth at least 100 words), so let's take a look at a test file:

#include <mettle.hpp>  using namespace mettle;    suite<> basic("a basic suite", [](auto &_) {      _.test("a test", []() {      expect(true, equal_to(true));    });      for(int i = 0; i < 4; i++) {      _.test("test number " + std::to_string(i), [i]() {        expect(i % 2, less(2));      });    }      subsuite<>(_, "a subsuite", [](auto &_) {      _.test("a sub-test", []() {        expect(true, equal_to(true));      });    });    });

项目主页:http://www.open-open.com/lib/view/home/1412072873171