summaryrefslogtreecommitdiffstats
path: root/src/boost/libs/safe_numerics/test/test_add_constexpr.hpp
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-07 18:45:59 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-07 18:45:59 +0000
commit19fcec84d8d7d21e796c7624e521b60d28ee21ed (patch)
tree42d26aa27d1e3f7c0b8bd3fd14e7d7082f5008dc /src/boost/libs/safe_numerics/test/test_add_constexpr.hpp
parentInitial commit. (diff)
downloadceph-6d07fdb6bb33b1af39833b850bb6cf8af79fe293.tar.xz
ceph-6d07fdb6bb33b1af39833b850bb6cf8af79fe293.zip
Adding upstream version 16.2.11+ds.upstream/16.2.11+dsupstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to '')
-rw-r--r--src/boost/libs/safe_numerics/test/test_add_constexpr.hpp30
1 files changed, 30 insertions, 0 deletions
diff --git a/src/boost/libs/safe_numerics/test/test_add_constexpr.hpp b/src/boost/libs/safe_numerics/test/test_add_constexpr.hpp
new file mode 100644
index 000000000..3c67e2b02
--- /dev/null
+++ b/src/boost/libs/safe_numerics/test/test_add_constexpr.hpp
@@ -0,0 +1,30 @@
+#ifndef BOOST_TEST_ADD_CONSTEXPR_HPP
+#define BOOST_TEST_ADD_CONSTEXPR_HPP
+
+// Copyright (c) 2015 Robert Ramey
+//
+// 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/safe_numerics/safe_integer.hpp>
+
+template<class T1, class T2>
+constexpr bool test_add_constexpr(
+ T1 v1,
+ T2 v2,
+ char expected_result
+){
+ using namespace boost::safe_numerics;
+ // if we don't expect the operation to pass, we can't
+ // check the constexpr version of the calculation so
+ // just return success.
+ if(expected_result == 'x')
+ return true;
+ safe_t<T1>(v1) + v2;
+ v1 + safe_t<T2>(v2);
+ safe_t<T1>(v1) + safe_t<T2>(v2);
+ return true; // correct result
+}
+
+#endif // BOOST_TEST_ADD_CONSTEXPR_HPP