[ Web Proxy ]
URL:
Viewing: https://raw.githubusercontent.com/matwey/xtensor-python/reenable_test_python/test/test_sfinae.cpp [Back]  [Original]

/***************************************************************************
* Copyright (c) Wolf Vollprecht, Johan Mabille and Sylvain Corlay          *
* Copyright (c) QuantStack                                                 *
*                                                                          *
* Distributed under the terms of the BSD 3-Clause License.                 *
*                                                                          *
* The full license is in the file LICENSE, distributed with this software. *
****************************************************************************/

#include 

#include "gtest/gtest.h"
#include "xtensor-python/pytensor.hpp"
#include "xtensor-python/pyarray.hpp"
#include "xtensor/xarray.hpp"
#include "xtensor/xtensor.hpp"

namespace xt
{
    template  = 0>
    inline bool sfinae_has_fixed_rank(E&&)
    {
        return false;
    }

    template 
    inline bool sfinae_has_fixed_rank(E&&)
    {
        return true;
    }

    TEST(sfinae, fixed_rank)
    {
        xt::pyarray a = {{9, 9, 9}, {9, 9, 9}};
        xt::pytensor b = {9, 9};
        xt::pytensor c = {{9, 9}, {9, 9}};

        EXPECT_TRUE(sfinae_has_fixed_rank(a) == false);
        EXPECT_TRUE(sfinae_has_fixed_rank(b) == true);
        EXPECT_TRUE(sfinae_has_fixed_rank(c) == true);
    }

    TEST(sfinae, get_rank)
    {
        xt::pytensor A = xt::zeros({2});
        xt::pytensor B = xt::zeros({2, 2});
        xt::pyarray C = xt::zeros({2, 2});

        EXPECT_TRUE(xt::get_rank::value == 1ul);
        EXPECT_TRUE(xt::get_rank::value == 2ul);
        EXPECT_TRUE(xt::get_rank::value == SIZE_MAX);
    }
}

Web Proxy Viewer  |  New URL  |  Original Page