diff --git a/CMakeLists.txt b/CMakeLists.txt index 988f48dc..4eda2be8 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -96,6 +96,8 @@ compiled_test(test/array_storage_test.cpp) compiled_test(test/axis_test.cpp) compiled_test(test/detail_test.cpp) compiled_test(test/histogram_dynamic_add_fail.cpp) +compiled_test(test/histogram_dynamic_fill_one_dimensional_vector_fail.cpp) +compiled_test(test/histogram_dynamic_fill_one_dimensional_tuple_fail.cpp) compiled_test(test/histogram_dynamic_at_tuple_wrong_dimension_fail.cpp) compiled_test(test/histogram_dynamic_at_vector_wrong_dimension_fail.cpp) compiled_test(test/histogram_dynamic_at_wrong_dimension_fail.cpp) diff --git a/test/histogram_dynamic_fill_one_dimensional_tuple_fail.cpp b/test/histogram_dynamic_fill_one_dimensional_tuple_fail.cpp new file mode 100644 index 00000000..9ca22f44 --- /dev/null +++ b/test/histogram_dynamic_fill_one_dimensional_tuple_fail.cpp @@ -0,0 +1,14 @@ +// 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 + +using namespace boost::histogram; +int main() { + auto a = make_dynamic_histogram(axis::integer<>(0, 2)); + a(std::make_tuple(1)); +} diff --git a/test/histogram_dynamic_fill_one_dimensional_vector_fail.cpp b/test/histogram_dynamic_fill_one_dimensional_vector_fail.cpp new file mode 100644 index 00000000..9baeeba2 --- /dev/null +++ b/test/histogram_dynamic_fill_one_dimensional_vector_fail.cpp @@ -0,0 +1,14 @@ +// 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 + +using namespace boost::histogram; +int main() { + auto a = make_dynamic_histogram(axis::integer<>(0, 2)); + a(std::vector(1)); +} diff --git a/test/histogram_test.cpp b/test/histogram_test.cpp index 98966523..41936d0d 100644 --- a/test/histogram_test.cpp +++ b/test/histogram_test.cpp @@ -775,6 +775,14 @@ void run_tests() { auto i = {1, 1}; BOOST_TEST_EQ(h.at(i).variance(), 5); BOOST_TEST_EQ(h[i].variance(), 5); + + // also test special case of 1-dimensional histogram, which should unpack + // the argument in the "at" call, even though they do not unpack in the + // operator() call (because that is ambiguous) + auto h1 = make(Tag(), axis::integer<>(0, 2)); + h1(1); + BOOST_TEST_EQ(h1.at(std::make_tuple(0)), 0); + BOOST_TEST_EQ(h1.at(std::vector(1, 1)), 1); } // bad bin access