catch2/projects/Benchmark/StringificationBench.cpp
Martin Hořeňovský 3b7511e564 First commit of benchmarks for Catch runtime perf.
So far its very much a WIP with some problems that are known already and
not very representative tests.
2017-01-14 21:55:37 +01:00

40 lines
1016 B
C++

#include "catch.hpp"
#include <vector>
///////////////////////////////////////////////////////////////////////////////
TEST_CASE("Successful tests -- REQUIRE", "[Success]") {
const size_t sz = 1 * 1024 * 1024;
std::vector<size_t> vec; vec.reserve(sz);
for (size_t i = 0; i < sz; ++i){
vec.push_back(i);
REQUIRE(vec.back() == i);
}
}
///////////////////////////////////////////////////////////////////////////////
TEST_CASE("Successful tests -- CHECK", "[Success]") {
const size_t sz = 1 * 1024 * 1024;
std::vector<size_t> vec; vec.reserve(sz);
for (size_t i = 0; i < sz; ++i){
vec.push_back(i);
CHECK(vec.back() == i);
}
}
///////////////////////////////////////////////////////////////////////////////
TEST_CASE("Unsuccessful tests -- CHECK", "[Failure]") {
const size_t sz = 128 * 1024;
std::vector<size_t> vec; vec.reserve(sz);
for (size_t i = 0; i < sz; ++i){
vec.push_back(i);
CHECK(vec.size() == i);
}
}