Skip to content

Commit

Permalink
More adapted tests
Browse files Browse the repository at this point in the history
  • Loading branch information
wichtounet committed Mar 16, 2015
1 parent e443aad commit d0469d9
Show file tree
Hide file tree
Showing 4 changed files with 306 additions and 300 deletions.
7 changes: 5 additions & 2 deletions include/etl/dyn_matrix.hpp
Expand Up @@ -108,7 +108,7 @@ struct dyn_matrix final {
//Nothing to init
}

//Sizes followed by an initializer list
//Initializer-list construction for vector
dyn_matrix(std::initializer_list<value_type> list) :
_size(list.size()),
_data(list),
Expand Down Expand Up @@ -156,7 +156,10 @@ struct dyn_matrix final {
(sizeof...(S) == D),
std::is_convertible<std::size_t, typename cpp::first_type<S1, S...>::type>::value, //The first type must be convertible to size_t
cpp::is_sub_homogeneous<S1, S...>::value, //The first N-1 types must homegeneous
std::is_same<value_type, typename cpp::last_type<S1, S...>::type>::value //The last type must be exactly value_type
(std::is_arithmetic<typename cpp::last_type<S1, S...>::type>::value
? std::is_convertible<value_type, typename cpp::last_type<S1, S...>::type>::value //The last type must be convertible to value_type
: std::is_same<value_type, typename cpp::last_type<S1, S...>::type>::value //The last type must be exactly value_type
)
> = cpp::detail::dummy>
dyn_matrix(S1 s1, S... sizes) :
_size(dyn_detail::size(std::make_index_sequence<(sizeof...(S))>(), s1, sizes...)),
Expand Down
33 changes: 17 additions & 16 deletions test/direct.cpp
Expand Up @@ -7,14 +7,15 @@
#include <cmath>

#include "catch.hpp"
#include "template_test.hpp"

#include "etl/etl.hpp"

TEST_CASE( "direct_access/traits", "has_direct_access" ) {
etl::fast_matrix<double, 3, 2> a;
TEMPLATE_TEST_CASE_2( "direct_access/traits", "has_direct_access", Z, double, float) {
etl::fast_matrix<Z, 3, 2> a;

using expr_1 = etl::fast_matrix<double, 3, 2>;
using expr_2 = etl::dyn_matrix<double, 3>;
using expr_1 = etl::fast_matrix<Z, 3, 2>;
using expr_2 = etl::dyn_matrix<Z, 3>;

REQUIRE(etl::has_direct_access<expr_1>::value);
REQUIRE(etl::has_direct_access<expr_2>::value);
Expand All @@ -40,8 +41,8 @@ TEST_CASE( "direct_access/traits", "has_direct_access" ) {
REQUIRE(etl::has_direct_access<expr_10>::value);
}

TEST_CASE( "direct_access/fast_matrix", "direct_access" ) {
etl::fast_matrix<double, 5, 5> test_matrix{etl::magic<5>()};
TEMPLATE_TEST_CASE_2( "direct_access/fast_matrix", "direct_access", Z, double, float) {
etl::fast_matrix<Z, 5, 5> test_matrix{etl::magic<5>()};

REQUIRE(test_matrix.size() == 25);

Expand All @@ -60,8 +61,8 @@ TEST_CASE( "direct_access/fast_matrix", "direct_access" ) {
REQUIRE(it == end);
}

TEST_CASE( "direct_access/dyn_matrix", "direct_access" ) {
etl::dyn_matrix<double, 2> test_matrix{etl::magic(5)};
TEMPLATE_TEST_CASE_2( "direct_access/dyn_matrix", "direct_access", Z, double, float) {
etl::dyn_matrix<Z, 2> test_matrix{etl::magic(5)};

REQUIRE(test_matrix.size() == 25);

Expand All @@ -80,8 +81,8 @@ TEST_CASE( "direct_access/dyn_matrix", "direct_access" ) {
REQUIRE(it == end);
}

TEST_CASE( "direct_access/sub_view", "direct_access" ) {
etl::dyn_matrix<double, 2> test_matrix{etl::magic(5)};
TEMPLATE_TEST_CASE_2( "direct_access/sub_view", "direct_access", Z, double, float) {
etl::dyn_matrix<Z, 2> test_matrix{etl::magic(5)};

auto v = test_matrix(1);

Expand All @@ -100,8 +101,8 @@ TEST_CASE( "direct_access/sub_view", "direct_access" ) {
REQUIRE(it == end);
}

TEST_CASE( "direct_access/reshape", "direct_access" ) {
etl::dyn_matrix<double, 2> test_matrix{etl::magic(6)};
TEMPLATE_TEST_CASE_2( "direct_access/reshape", "direct_access", Z, double, float) {
etl::dyn_matrix<Z, 2> test_matrix{etl::magic(6)};

auto v = etl::reshape<3,12>(test_matrix);

Expand All @@ -120,8 +121,8 @@ TEST_CASE( "direct_access/reshape", "direct_access" ) {
REQUIRE(it == end);
}

TEST_CASE( "direct_access/reshape_dyn", "direct_access" ) {
etl::dyn_matrix<double, 2> test_matrix{etl::magic(6)};
TEMPLATE_TEST_CASE_2( "direct_access/reshape_dyn", "direct_access", Z, double, float) {
etl::dyn_matrix<Z, 2> test_matrix{etl::magic(6)};

auto v = etl::reshape(test_matrix, 3, 12);

Expand All @@ -140,8 +141,8 @@ TEST_CASE( "direct_access/reshape_dyn", "direct_access" ) {
REQUIRE(it == end);
}

TEST_CASE( "direct_access/dim_view", "direct_access" ) {
etl::dyn_matrix<double, 2> test_matrix{etl::magic(6)};
TEMPLATE_TEST_CASE_2( "direct_access/dim_view", "direct_access", Z, double, float) {
etl::dyn_matrix<Z, 2> test_matrix{etl::magic(6)};

auto v = row(test_matrix, 2);

Expand Down

0 comments on commit d0469d9

Please sign in to comment.