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:
@@ -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'));
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user