Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add constexpr usage checks #2

Merged
merged 2 commits into from Apr 2, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
3 changes: 3 additions & 0 deletions test/Jamfile.v2
Expand Up @@ -3,9 +3,12 @@
#~ (See accompanying file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)

import testing ;
import ../../config/checks/config : requires ;


test-suite rational
: [ run rational_example.cpp ]
[ run rational_test.cpp
/boost/test//boost_unit_test_framework/<link>static ]
[ run constexpr_test.cpp : : : [ requires cxx11_constexpr ] ]
;
26 changes: 26 additions & 0 deletions test/constexpr_test.cpp
@@ -0,0 +1,26 @@
///////////////////////////////////////////////////////////////////////////////
// Copyright 2015 John Maddock. 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/rational.hpp>


int main()
{
#ifndef BOOST_NO_CONSTEXPR
constexpr boost::rational<int> i1;
constexpr boost::rational<int> i2(3);
constexpr boost::rational<short> i3(i2);

static_assert(i1.numerator() == 0, "constexpr test");
static_assert(i1.denominator() == 1, "constexpr test");
static_assert(i2.numerator() == 3, "constexpr test");
static_assert(i2.denominator() == 1, "constexpr test");
static_assert(i3.numerator() == 3, "constexpr test");
static_assert(i3.denominator() == 1, "constexpr test");
static_assert(!i1, "constexpr test");
static_assert(i2, "constexpr test");
#endif
return 0;
}