replace catch2 to embedded doctest

This commit is contained in:
BlackMATov
2020-11-29 23:59:33 +07:00
parent 61245bc7ea
commit 7d87cd34d3
11 changed files with 6362 additions and 150 deletions

View File

@@ -4,19 +4,19 @@
* Copyright (C) 2019-2020, by Matvey Cherevko (blackmatov@gmail.com)
******************************************************************************/
#define CATCH_CONFIG_FAST_COMPILE
#include <catch2/catch.hpp>
#include <flat.hpp/flat_multiset.hpp>
#include "doctest/doctest.h"
#include "flat_tests.hpp"
#include <deque>
#include <string>
#include <string_view>
#include <flat.hpp/flat_multiset.hpp>
using namespace flat_hpp;
namespace
{
using namespace flat_hpp;
template < typename T >
class dummy_less {
public:
@@ -57,11 +57,11 @@ namespace
}
TEST_CASE("flat_multiset") {
SECTION("detail") {
SUBCASE("detail") {
STATIC_REQUIRE(detail::is_transparent<std::less<>, int>::value);
STATIC_REQUIRE_FALSE(detail::is_transparent<std::less<int>, int>::value);
}
SECTION("sizeof") {
SUBCASE("sizeof") {
REQUIRE(sizeof(flat_multiset<int>) == sizeof(std::vector<int>));
struct vc : flat_multiset<int>::value_compare {
@@ -69,7 +69,7 @@ TEST_CASE("flat_multiset") {
};
REQUIRE(sizeof(vc) == sizeof(int));
}
SECTION("noexcept") {
SUBCASE("noexcept") {
using alloc_t = std::allocator<int>;
using set_t = flat_multiset<int, dummy_less<int>, std::vector<int, alloc_t>>;
using set2_t = flat_multiset<int, dummy_less2<int>>;
@@ -103,7 +103,7 @@ TEST_CASE("flat_multiset") {
STATIC_REQUIRE(noexcept(std::declval<set_t&>().clear()));
}
SECTION("types") {
SUBCASE("types") {
using set_t = flat_multiset<int>;
STATIC_REQUIRE(std::is_same_v<set_t::key_type, int>);
@@ -118,7 +118,7 @@ TEST_CASE("flat_multiset") {
STATIC_REQUIRE(std::is_same_v<set_t::pointer, int*>);
STATIC_REQUIRE(std::is_same_v<set_t::const_pointer, const int*>);
}
SECTION("ctors") {
SUBCASE("ctors") {
using alloc_t = std::allocator<int>;
using set_t = flat_multiset<int, std::less<int>, std::vector<int, alloc_t>>;
using set2_t = flat_multiset<int, std::greater<int>, std::vector<int, alloc_t>>;
@@ -196,7 +196,7 @@ TEST_CASE("flat_multiset") {
REQUIRE(s1 == set_t{1,2,3,3});
}
}
SECTION("capacity") {
SUBCASE("capacity") {
using set_t = flat_multiset<int>;
{
@@ -250,7 +250,7 @@ TEST_CASE("flat_multiset") {
REQUIRE(s1 == set2_t{1,2,3});
}
}
SECTION("inserts") {
SUBCASE("inserts") {
struct obj_t {
obj_t(int i) : i(i) {}
int i;
@@ -346,7 +346,7 @@ TEST_CASE("flat_multiset") {
REQUIRE(s1 == set_t{1,2,2,3});
}
}
SECTION("erasers") {
SUBCASE("erasers") {
using set_t = flat_multiset<int>;
{
set_t s0{1,2,3,4,5};
@@ -383,7 +383,7 @@ TEST_CASE("flat_multiset") {
REQUIRE(s1 == set_t{3,4,5});
}
}
SECTION("lookup") {
SUBCASE("lookup") {
using set_t = flat_multiset<int>;
{
set_t s0{1,2,3,3,4,5};
@@ -419,7 +419,7 @@ TEST_CASE("flat_multiset") {
REQUIRE(my_as_const(s0).lower_bound(7) == s0.cbegin() + 4);
}
}
SECTION("heterogeneous") {
SUBCASE("heterogeneous") {
flat_multiset<std::string, std::less<>> s0{"hello", "world"};
REQUIRE(s0.find(std::string_view("hello")) == s0.begin());
REQUIRE(my_as_const(s0).find(std::string_view("world")) == s0.begin() + 1);
@@ -435,7 +435,7 @@ TEST_CASE("flat_multiset") {
REQUIRE(s0.upper_bound(std::string_view("hello")) == s0.begin() + 1);
REQUIRE(my_as_const(s0).upper_bound(std::string_view("hello")) == s0.begin() + 1);
}
SECTION("observers") {
SUBCASE("observers") {
struct my_less {
int i;
my_less(int i) : i(i) {}
@@ -448,7 +448,7 @@ TEST_CASE("flat_multiset") {
REQUIRE(my_as_const(s0).key_comp().i == 42);
REQUIRE(my_as_const(s0).value_comp().i == 42);
}
SECTION("custom_less") {
SUBCASE("custom_less") {
using set_t = flat_multiset<int, dummy_less<int>>;
auto s0 = set_t(dummy_less<int>(42));
auto s1 = set_t(dummy_less<int>(21));
@@ -458,7 +458,7 @@ TEST_CASE("flat_multiset") {
REQUIRE(s0.key_comp().i == 21);
REQUIRE(s1.key_comp().i == 42);
}
SECTION("operators") {
SUBCASE("operators") {
using set_t = flat_multiset<int>;
REQUIRE(set_t{1,2,3} == set_t{3,2,1});