mirror of
https://github.com/BlackMATov/flat.hpp.git
synced 2025-12-13 17:48:14 +07:00
replace catch2 to embedded doctest
This commit is contained in:
@@ -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_set.hpp>
|
||||
|
||||
#include "doctest/doctest.h"
|
||||
#include "flat_tests.hpp"
|
||||
|
||||
#include <deque>
|
||||
|
||||
#include <string>
|
||||
#include <string_view>
|
||||
|
||||
#include <flat.hpp/flat_set.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_set") {
|
||||
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_set<int>) == sizeof(std::vector<int>));
|
||||
|
||||
struct vc : flat_set<int>::value_compare {
|
||||
@@ -69,7 +69,7 @@ TEST_CASE("flat_set") {
|
||||
};
|
||||
REQUIRE(sizeof(vc) == sizeof(int));
|
||||
}
|
||||
SECTION("noexcept") {
|
||||
SUBCASE("noexcept") {
|
||||
using alloc_t = std::allocator<int>;
|
||||
using set_t = flat_set<int, dummy_less<int>, std::vector<int, alloc_t>>;
|
||||
using set2_t = flat_set<int, dummy_less2<int>>;
|
||||
@@ -103,7 +103,7 @@ TEST_CASE("flat_set") {
|
||||
|
||||
STATIC_REQUIRE(noexcept(std::declval<set_t&>().clear()));
|
||||
}
|
||||
SECTION("types") {
|
||||
SUBCASE("types") {
|
||||
using set_t = flat_set<int>;
|
||||
|
||||
STATIC_REQUIRE(std::is_same_v<set_t::key_type, int>);
|
||||
@@ -118,7 +118,7 @@ TEST_CASE("flat_set") {
|
||||
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_set<int, std::less<int>, std::vector<int, alloc_t>>;
|
||||
using set2_t = flat_set<int, std::greater<int>, std::vector<int, alloc_t>>;
|
||||
@@ -196,7 +196,7 @@ TEST_CASE("flat_set") {
|
||||
REQUIRE(s1 == set_t{1,2,3});
|
||||
}
|
||||
}
|
||||
SECTION("capacity") {
|
||||
SUBCASE("capacity") {
|
||||
using set_t = flat_set<int>;
|
||||
|
||||
{
|
||||
@@ -250,7 +250,7 @@ TEST_CASE("flat_set") {
|
||||
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_set") {
|
||||
REQUIRE(s1 == set_t{1,2,3});
|
||||
}
|
||||
}
|
||||
SECTION("erasers") {
|
||||
SUBCASE("erasers") {
|
||||
using set_t = flat_set<int>;
|
||||
{
|
||||
set_t s0{1,2,3,4,5};
|
||||
@@ -382,7 +382,7 @@ TEST_CASE("flat_set") {
|
||||
REQUIRE(s1 == set_t{3,4,5});
|
||||
}
|
||||
}
|
||||
SECTION("lookup") {
|
||||
SUBCASE("lookup") {
|
||||
using set_t = flat_set<int>;
|
||||
{
|
||||
set_t s0{1,2,3,4,5};
|
||||
@@ -417,7 +417,7 @@ TEST_CASE("flat_set") {
|
||||
REQUIRE(my_as_const(s0).lower_bound(7) == s0.cbegin() + 3);
|
||||
}
|
||||
}
|
||||
SECTION("heterogeneous") {
|
||||
SUBCASE("heterogeneous") {
|
||||
flat_set<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);
|
||||
@@ -433,7 +433,7 @@ TEST_CASE("flat_set") {
|
||||
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) {}
|
||||
@@ -446,7 +446,7 @@ TEST_CASE("flat_set") {
|
||||
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_set<int, dummy_less<int>>;
|
||||
auto s0 = set_t(dummy_less<int>(42));
|
||||
auto s1 = set_t(dummy_less<int>(21));
|
||||
@@ -456,7 +456,7 @@ TEST_CASE("flat_set") {
|
||||
REQUIRE(s0.key_comp().i == 21);
|
||||
REQUIRE(s1.key_comp().i == 42);
|
||||
}
|
||||
SECTION("operators") {
|
||||
SUBCASE("operators") {
|
||||
using set_t = flat_set<int>;
|
||||
|
||||
REQUIRE(set_t{1,2,3} == set_t{3,2,1});
|
||||
|
||||
Reference in New Issue
Block a user