/******************************************************************************* * This file is part of the "https://github.com/blackmatov/flat.hpp" * For conditions of distribution and use, see copyright notice in LICENSE.md * Copyright (C) 2019, by Matvey Cherevko (blackmatov@gmail.com) ******************************************************************************/ #define CATCH_CONFIG_FAST_COMPILE #include "catch.hpp" #include "flat_set.hpp" using namespace flat_hpp; namespace { template < typename T > class dummy_allocator { public: using value_type = T; T* allocate(std::size_t n) { (void)n; return nullptr; } void deallocate(T* p, std::size_t n) { (void)p; (void)n; } }; } TEST_CASE("flat_set") { { using set_t = flat_set; static_assert( std::is_same::value, "unit test static error"); static_assert( std::is_same::value, "unit test static error"); static_assert( std::is_same::value, "unit test static error"); static_assert( std::is_same::value, "unit test static error"); static_assert( std::is_same::value, "unit test static error"); static_assert( std::is_same::value, "unit test static error"); static_assert( std::is_same::value, "unit test static error"); static_assert( std::is_same::value, "unit test static error"); } { using alloc_t = dummy_allocator; using set_t = flat_set, alloc_t>; { auto s0 = set_t(); auto s1 = set_t(alloc_t()); auto s2 = set_t(std::less()); auto s3 = set_t(std::less(), alloc_t()); } { std::vector v; auto s0 = set_t(v.cbegin(), v.cend()); auto s1 = set_t(v.cbegin(), v.cend(), alloc_t()); auto s2 = set_t(v.cbegin(), v.cend(), std::less()); auto s3 = set_t(v.cbegin(), v.cend(), std::less(), alloc_t()); } { auto s0 = set_t({0,1,2}); auto s1 = set_t({0,1,2}, alloc_t()); auto s2 = set_t({0,1,2}, std::less()); auto s3 = set_t({0,1,2}, std::less(), alloc_t()); } } }