mirror of
https://github.com/boostorg/histogram.git
synced 2025-05-12 13:41:48 +00:00
more tests
This commit is contained in:
parent
bf9cfb81bd
commit
aaae031733
@ -9,10 +9,11 @@
|
|||||||
#include <boost/test/test_tools.hpp>
|
#include <boost/test/test_tools.hpp>
|
||||||
#include <boost/histogram/storage/adaptive_storage.hpp>
|
#include <boost/histogram/storage/adaptive_storage.hpp>
|
||||||
#include <boost/histogram/storage/container_storage.hpp>
|
#include <boost/histogram/storage/container_storage.hpp>
|
||||||
#include <boost/histogram/detail/utility.hpp>
|
#include <boost/histogram/serialization.hpp>
|
||||||
#include <type_traits>
|
#include <boost/archive/text_oarchive.hpp>
|
||||||
|
#include <boost/archive/text_iarchive.hpp>
|
||||||
|
#include <sstream>
|
||||||
#include <limits>
|
#include <limits>
|
||||||
#include <tuple>
|
|
||||||
using namespace boost::histogram;
|
using namespace boost::histogram;
|
||||||
|
|
||||||
namespace boost {
|
namespace boost {
|
||||||
@ -289,3 +290,58 @@ BOOST_AUTO_TEST_CASE(convert_container_storage)
|
|||||||
convert_container_storage_impl<uint64_t>();
|
convert_container_storage_impl<uint64_t>();
|
||||||
convert_container_storage_impl<detail::weight>();
|
convert_container_storage_impl<detail::weight>();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
template <typename T>
|
||||||
|
void serialization_impl()
|
||||||
|
{
|
||||||
|
const auto a = storage_access::set_value(1, T(1));
|
||||||
|
std::ostringstream os;
|
||||||
|
std::string buf;
|
||||||
|
{
|
||||||
|
std::ostringstream os;
|
||||||
|
boost::archive::text_oarchive oa(os);
|
||||||
|
oa << a;
|
||||||
|
buf = os.str();
|
||||||
|
}
|
||||||
|
adaptive_storage<> b;
|
||||||
|
BOOST_CHECK(!(a == b));
|
||||||
|
{
|
||||||
|
std::istringstream is(buf);
|
||||||
|
boost::archive::text_iarchive ia(is);
|
||||||
|
ia >> b;
|
||||||
|
}
|
||||||
|
BOOST_CHECK(a == b);
|
||||||
|
}
|
||||||
|
|
||||||
|
template <>
|
||||||
|
void serialization_impl<void>()
|
||||||
|
{
|
||||||
|
adaptive_storage<> a(1);
|
||||||
|
std::ostringstream os;
|
||||||
|
std::string buf;
|
||||||
|
{
|
||||||
|
std::ostringstream os;
|
||||||
|
boost::archive::text_oarchive oa(os);
|
||||||
|
oa << a;
|
||||||
|
buf = os.str();
|
||||||
|
}
|
||||||
|
adaptive_storage<> b;
|
||||||
|
BOOST_CHECK(!(a == b));
|
||||||
|
{
|
||||||
|
std::istringstream is(buf);
|
||||||
|
boost::archive::text_iarchive ia(is);
|
||||||
|
ia >> b;
|
||||||
|
}
|
||||||
|
BOOST_CHECK(a == b);
|
||||||
|
}
|
||||||
|
|
||||||
|
BOOST_AUTO_TEST_CASE(serialization_test)
|
||||||
|
{
|
||||||
|
serialization_impl<detail::weight>();
|
||||||
|
serialization_impl<void>();
|
||||||
|
serialization_impl<uint8_t>();
|
||||||
|
serialization_impl<uint16_t>();
|
||||||
|
serialization_impl<uint32_t>();
|
||||||
|
serialization_impl<uint64_t>();
|
||||||
|
serialization_impl<detail::weight>();
|
||||||
|
}
|
||||||
|
@ -16,10 +16,10 @@
|
|||||||
#include <boost/histogram/storage/container_storage.hpp>
|
#include <boost/histogram/storage/container_storage.hpp>
|
||||||
#include <boost/archive/text_oarchive.hpp>
|
#include <boost/archive/text_oarchive.hpp>
|
||||||
#include <boost/archive/text_iarchive.hpp>
|
#include <boost/archive/text_iarchive.hpp>
|
||||||
#include <limits>
|
|
||||||
#include <sstream>
|
#include <sstream>
|
||||||
#include <array>
|
#include <limits>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
#include <array>
|
||||||
|
|
||||||
using namespace boost::histogram;
|
using namespace boost::histogram;
|
||||||
namespace mpl = boost::mpl;
|
namespace mpl = boost::mpl;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user