From 4ce3973c7774be0837fda2d3df4b88aaa3a47683 Mon Sep 17 00:00:00 2001 From: Hans Dembinski Date: Tue, 28 Mar 2017 23:51:48 +0200 Subject: [PATCH] more tests and a fix --- .../histogram/storage/adaptive_storage.hpp | 2 +- test/adaptive_storage_test.cpp | 29 ++++++++++--------- 2 files changed, 17 insertions(+), 14 deletions(-) diff --git a/include/boost/histogram/storage/adaptive_storage.hpp b/include/boost/histogram/storage/adaptive_storage.hpp index d34db318..ff6279f5 100644 --- a/include/boost/histogram/storage/adaptive_storage.hpp +++ b/include/boost/histogram/storage/adaptive_storage.hpp @@ -241,7 +241,7 @@ private: (*this)(get>(buffer)); } - void operator()(array &b) const { b[idx] = value; } + void operator()(array &b) const { b[idx] = static_cast(value); } void operator()(array &b) const { b[idx] = value; } }; diff --git a/test/adaptive_storage_test.cpp b/test/adaptive_storage_test.cpp index bc10899e..914abe65 100644 --- a/test/adaptive_storage_test.cpp +++ b/test/adaptive_storage_test.cpp @@ -207,29 +207,31 @@ template void convert_container_storage_impl() { t.increase(0); while (t.value(0) < 1e20) t += t; - auto d = aref; - d = s; - BOOST_TEST_EQ(d.value(0), 1.0); - BOOST_TEST(d == s); - d.increase(0); - BOOST_TEST(!(d == s)); + d = t; - adaptive_storage<> e(s); + auto e = aref; + e = s; BOOST_TEST_EQ(e.value(0), 1.0); BOOST_TEST(e == s); e.increase(0); BOOST_TEST(!(e == s)); - auto f = aref; - f += s; + adaptive_storage<> f(s); BOOST_TEST_EQ(f.value(0), 1.0); - BOOST_TEST(c == s); - BOOST_TEST(s == c); + BOOST_TEST(f == s); + f.increase(0); + BOOST_TEST(!(f == s)); + + auto g = aref; + g += s; + BOOST_TEST_EQ(g.value(0), 1.0); + BOOST_TEST(g == s); + BOOST_TEST(s == g); container_storage> u(2); u.increase(0); - BOOST_TEST(!(c == u)); + BOOST_TEST(!(aref == u)); } template <> void convert_container_storage_impl() { @@ -253,7 +255,8 @@ template <> void convert_container_storage_impl() { container_storage> t(2); t.increase(0); - BOOST_TEST(!(c == t)); + auto d = aref; + BOOST_TEST(!(d == t)); } } // namespace histogram