Commit 9c95f479 authored by ESTERIE Pierre's avatar ESTERIE Pierre

variadic_container constructors and fix unit

parent e2d37eb6
......@@ -17,6 +17,8 @@
#include <scalfmm/utils/io_helpers.hpp>
#include <scalfmm/memory/aligned_allocator.hpp>
#include <xsimd/xsimd.hpp>
#include <inria/integer_sequence.hpp>
namespace scalfmm::container
......@@ -151,7 +153,7 @@ namespace scalfmm::container
*
* \return The new variadic_container
*/
variadic_container_impl(size_type count, const value_type& value,
explicit variadic_container_impl(size_type count, const value_type& value,
const allocator_type_tuple& alloc = allocator_type_tuple())
: _allocator_tuple(alloc)
{
......@@ -193,7 +195,7 @@ namespace scalfmm::container
* \return
*/
template<class InputIt>
variadic_container_impl(InputIt first, InputIt last, const allocator_type_tuple& alloc = allocator_type_tuple())
explicit variadic_container_impl(InputIt first, InputIt last, const allocator_type_tuple& alloc = allocator_type_tuple())
: _allocator_tuple(alloc)
{
this->assign(first, last);
......
......@@ -47,9 +47,9 @@ struct exceptionalize_static_assert<false>
// A macro redefinition of `static_assert`
#define static_assert(cond,gripe) \
struct _1_test \
: test::exceptionalize_static_assert<cond> \
: scalfmm::test::exceptionalize_static_assert<cond> \
{ _1_test() : \
test::exceptionalize_static_assert<cond>(gripe){}; \
scalfmm::test::exceptionalize_static_assert<cond>(gripe){}; \
}; \
_1_test _2_test
......
......@@ -13,14 +13,16 @@
#include <scalfmm/memory/aligned_allocator.hpp>
#include <scalfmm/tools/colorized.hpp>
#include <xsimd/xsimd.hpp>
TEMPLATE_TEST_CASE( "Variadic container construction", "[variadic_container]", double, float)
{
using namespace scalfmm;
static const int alignment{512};
static const int alignment{XSIMD_DEFAULT_ALIGNMENT};
constexpr std::size_t size_value{5};
constexpr TestType default_value{2.9};
const std::vector<std::tuple<TestType>> cv(size_value,std::make_tuple(default_value));
using var_t = container::variadic_container<memory::aligned_allocator<alignment,TestType>,TestType>;
using var_t = container::variadic_container<TestType>;
const var_t cv_var(size_value,default_value);
SECTION( "Default construction", "[default]" )
......@@ -109,14 +111,12 @@ bool all(Args... args){ return (... && args); }
TEST_CASE("Variadic vector access", "[vector-access]")
{
using namespace scalfmm;
static const int alignment{512};
using allocator_t = memory::aligned_allocator<alignment, std::tuple<double, float, int>>;
constexpr std::tuple<double,float,int> ct(double{3.0},float{2.0},int{1});
SECTION( "Front and back accessor", "[front-back-access]" )
{
container::variadic_container<allocator_t, std::tuple<double, float, int>> c(1, ct);
container::variadic_container<std::tuple<double, float, int>> c(1, ct);
REQUIRE( all(std::get<0>(c.front()) == std::get<0>(c.back()), std::get<0>(c.front()) == std::get<0>(ct), std::get<0>(c.back()) == std::get<0>(ct)) );
REQUIRE( all(std::get<1>(c.front()) == std::get<1>(c.back()), std::get<1>(c.front()) == std::get<1>(ct), std::get<1>(c.back()) == std::get<1>(ct)) );
......@@ -125,7 +125,7 @@ TEST_CASE("Variadic vector access", "[vector-access]")
SECTION( "Raw data accessor", "[raw-access]" )
{
container::variadic_container<allocator_t, double, float, int> c(10, ct);
container::variadic_container<double, float, int> c(10, ct);
REQUIRE( std::get<0>(c.data()) == &std::get<0>(c.front()) );
REQUIRE( std::get<1>(c.data()) == &std::get<1>(c.front()) );
......@@ -137,7 +137,7 @@ TEST_CASE("Variadic vector access", "[vector-access]")
SECTION( "Iterator access", "[iterator-access]" )
{
container::variadic_container<allocator_t, double, float, int> c(10, ct);
container::variadic_container<double, float, int> c(10, ct);
REQUIRE( std::distance(c.begin(), c.end()) == c.size() );
REQUIRE( std::distance(c.cbegin(), c.cend()) == c.size() );
REQUIRE( *c.begin() == ct );
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment