Here is an example test for our customer library written in Catch2:
#include "customer/customer.h"
#define CATCH_CONFIG_MAIN // This tells Catch to provide a main() - only do
// this in one cpp file
#include "catch2/catch.hpp"
TEST_CASE("Basic responses",
"Given Name When Prepare Responses Then Greets Friendly") {
auto name = "Bob";
auto code_and_string = responder{}.prepare_response(name);
REQUIRE(code_and_string.first == web::http::status_codes::OK);
REQUIRE(code_and_string.second == web::json::value("Hello, Bob!"));
}
It looks pretty similar to the previous one. Some keywords differ (TEST and TEST_CASE) and there's a slightly different way to check the results (REQUIRE(a == b) instead of ASSERT_EQ(a,b)). Both are pretty compact and readable anyway.