histogram/test/detail_test.cpp
2018-07-21 16:17:36 +02:00

61 lines
1.5 KiB
C++

// Copyright 2015-2017 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 <boost/core/lightweight_test.hpp>
#include <boost/core/lightweight_test_trait.hpp>
#include <boost/histogram/detail/axis_visitor.hpp>
#include <boost/histogram/detail/cat.hpp>
#include <boost/histogram/detail/meta.hpp>
#include <boost/histogram/detail/utility.hpp>
#include <boost/histogram/literals.hpp>
#include <boost/mp11.hpp>
#include <sstream>
#include <string>
#include <tuple>
#include <type_traits>
#include <utility>
#include <vector>
#include "utility.hpp"
using namespace boost::histogram::detail;
int main() {
// escape0
{
std::ostringstream os;
escape(os, std::string("abc"));
BOOST_TEST_EQ(os.str(), std::string("'abc'"));
}
// escape1
{
std::ostringstream os;
escape(os, std::string("abc\n"));
BOOST_TEST_EQ(os.str(), std::string("'abc\n'"));
}
// escape2
{
std::ostringstream os;
escape(os, std::string("'abc'"));
BOOST_TEST_EQ(os.str(), std::string("'\\\'abc\\\''"));
}
// cat
{ BOOST_TEST_EQ(cat("foo", 1, "bar"), std::string("foo1bar")); }
// bool mask
{
auto v1 = bool_mask<i1, i2>(4, false);
BOOST_TEST_EQ(v1, std::vector<bool>({true, false, false, true}));
auto v2 = bool_mask<i1, i3>(4, true);
BOOST_TEST_EQ(v2, std::vector<bool>({false, true, false, true}));
}
return boost::report_errors();
}