// Copyright 2018 Hans Dembinski // // Distributed under the Boost Software License, Version 1.0. // (See accompanying file LICENSE_1_0.txt // or copy at http://www.boost.org/LICENSE_1_0.txt) #include #include #include #include #include #include using namespace boost::histogram; namespace tr = axis::transform; // tests requires a C++17 compatible compiler int main() { #if __cpp_deduction_guides >= 201611 { axis::regular a(1, 0.0, 1.0); axis::regular b(1, 0, 1); axis::regular c(1, 0.0f, 1.0f); axis::regular d(1, 0, 1, "foo"); axis::regular e(1, 0, 1, axis::null_type{}); axis::regular f(tr::sqrt(), 1, 0, 1); axis::regular g(tr::sqrt(), 1, 0, 1, "foo"); axis::regular h(tr::sqrt(), 1, 0, 1, axis::null_type{}); BOOST_TEST_TRAIT_TRUE((std::is_same>)); BOOST_TEST_TRAIT_TRUE((std::is_same>)); BOOST_TEST_TRAIT_TRUE((std::is_same>)); BOOST_TEST_TRAIT_TRUE((std::is_same>)); BOOST_TEST_TRAIT_TRUE( (std::is_same>)); BOOST_TEST_TRAIT_TRUE((std::is_same>)); BOOST_TEST_TRAIT_TRUE((std::is_same>)); BOOST_TEST_TRAIT_TRUE( (std::is_same>)); } { axis::integer a(1, 2); axis::integer b(1l, 2l); axis::integer c(1.0, 2.0); axis::integer d(1.0f, 2.0f); axis::integer e(1, 2, "foo"); axis::integer f(1, 2, axis::null_type{}); BOOST_TEST_TRAIT_TRUE((std::is_same>)); BOOST_TEST_TRAIT_TRUE((std::is_same>)); BOOST_TEST_TRAIT_TRUE((std::is_same>)); BOOST_TEST_TRAIT_TRUE((std::is_same>)); BOOST_TEST_TRAIT_TRUE((std::is_same>)); BOOST_TEST_TRAIT_TRUE( (std::is_same>)); } { axis::variable a{-1, 1}; axis::variable b{-1.f, 1.f}; axis::variable c{-1.0, 1.0}; axis::variable d({-1, 1}, "foo"); axis::variable e({-1, 1}, axis::null_type{}); std::vector vi{{-1, 1}}; std::vector vf{{-1.f, 1.f}}; axis::variable f(vi); axis::variable g(vf); axis::variable h(vi, "foo"); axis::variable i(vi, axis::null_type{}); BOOST_TEST_TRAIT_TRUE((std::is_same>)); BOOST_TEST_TRAIT_TRUE((std::is_same>)); BOOST_TEST_TRAIT_TRUE((std::is_same>)); BOOST_TEST_TRAIT_TRUE((std::is_same>)); BOOST_TEST_TRAIT_TRUE( (std::is_same>)); BOOST_TEST_TRAIT_TRUE((std::is_same>)); BOOST_TEST_TRAIT_TRUE((std::is_same>)); BOOST_TEST_TRAIT_TRUE((std::is_same>)); BOOST_TEST_TRAIT_TRUE( (std::is_same>)); } { auto a = histogram(std::make_tuple(axis::regular(3, -1, 1), axis::integer(0, 4))); BOOST_TEST_EQ(a.rank(), 2); BOOST_TEST_EQ(a.axis(0), axis::regular(3, -1, 1)); BOOST_TEST_EQ(a.axis(1), axis::integer(0, 4)); std::vector> axes{{axis::regular(3, -1, 1), axis::regular(5, 0, 5)}}; auto b = histogram(axes, weighted_storage()); BOOST_TEST_EQ(b.rank(), 2); BOOST_TEST_EQ(b.axis(0), axis::regular(3, -1, 1)); BOOST_TEST_EQ(b.axis(1), axis::regular(5, 0, 5)); } #endif return boost::report_errors(); }