2
0
mirror of https://github.com/boostorg/hana.git synced 2026-02-03 09:12:14 +00:00

Use finer grained assertions acknowledging Constants

This commit is contained in:
Louis Dionne
2014-08-05 10:37:54 -04:00
parent bf5eb10c46
commit d132db0ebf
436 changed files with 2672 additions and 2554 deletions

View File

@@ -6,9 +6,8 @@ Distributed under the Boost Software License, Version 1.0.
#include <boost/hana/type.hpp>
#include <boost/hana/detail/static_assert.hpp>
#include <boost/hana/detail/assert.hpp>
#include <cassert>
#include <initializer_list>
#include <utility>
#include <vector>
@@ -16,14 +15,13 @@ using namespace boost::hana;
int main() {
BOOST_HANA_STATIC_ASSERT(type<int>() == int{});
BOOST_HANA_STATIC_ASSERT(type<int>(2) == int{2});
BOOST_HANA_STATIC_ASSERT(type<float>(2.42f) == float{2.42});
BOOST_HANA_STATIC_ASSERT(type<double>(2.42) == double{2.42});
BOOST_HANA_STATIC_ASSERT(type<double>(2.2f) == double{2.2f});
BOOST_HANA_STATIC_ASSERT(type<float>(2.2) == float{2.2});
BOOST_HANA_CONSTEXPR_ASSERT(type<int>() == int{});
BOOST_HANA_CONSTEXPR_ASSERT(type<int>(2) == int{2});
BOOST_HANA_CONSTEXPR_ASSERT(type<float>(2.42f) == float{2.42});
BOOST_HANA_CONSTEXPR_ASSERT(type<double>(2.42) == double{2.42});
BOOST_HANA_CONSTEXPR_ASSERT(type<double>(2.2f) == double{2.2f});
BOOST_HANA_CONSTEXPR_ASSERT(type<float>(2.2) == float{2.2});
// double parentheses are because `assert` is a macro
assert((type<std::vector<int>>(std::initializer_list<int>{1, 2, 3}) == std::vector<int>{1, 2, 3}));
assert((type<std::pair<int, char>>(1, '2') == std::make_pair(1, '2')));
BOOST_HANA_RUNTIME_ASSERT(type<std::vector<int>>(std::initializer_list<int>{1, 2, 3}) == std::vector<int>{1, 2, 3});
BOOST_HANA_RUNTIME_ASSERT(type<std::pair<int, char>>(1, '2') == std::make_pair(1, '2'));
}