Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r52342 - sandbox/numeric_adaptor/libs/numeric_adaptor/test
From: bruno.lalande_at_[hidden]
Date: 2009-04-11 18:41:37


Author: bruno.lalande
Date: 2009-04-11 18:41:37 EDT (Sat, 11 Apr 2009)
New Revision: 52342
URL: http://svn.boost.org/trac/boost/changeset/52342

Log:
Added a test case
Added:
   sandbox/numeric_adaptor/libs/numeric_adaptor/test/Jamroot (contents, props changed)
   sandbox/numeric_adaptor/libs/numeric_adaptor/test/test_heron.cpp (contents, props changed)

Added: sandbox/numeric_adaptor/libs/numeric_adaptor/test/Jamroot
==============================================================================
--- (empty file)
+++ sandbox/numeric_adaptor/libs/numeric_adaptor/test/Jamroot 2009-04-11 18:41:37 EDT (Sat, 11 Apr 2009)
@@ -0,0 +1,16 @@
+# Boost Numeric Adaptor testing suite
+#
+# Copyright Bruno Lalande 2009
+# Copyright Barend Gehrels 2009, Geodan Holding B.V. Amsterdam, the Netherlands.
+# Use, modification and distribution is subject to 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)
+
+
+lib gmp : : <name>gmp ;
+
+project : requirements <include>../../.. <library>gmp ;
+
+import testing ;
+
+run test_heron.cpp : gmp ;

Added: sandbox/numeric_adaptor/libs/numeric_adaptor/test/test_heron.cpp
==============================================================================
--- (empty file)
+++ sandbox/numeric_adaptor/libs/numeric_adaptor/test/test_heron.cpp 2009-04-11 18:41:37 EDT (Sat, 11 Apr 2009)
@@ -0,0 +1,39 @@
+// Numeric Adaptor Library testing suite
+//
+// Copyright Barend Gehrels 2009, Geodan Holding B.V. Amsterdam, the Netherlands.
+// Copyright Bruno Lalande 2009
+// Use, modification and distribution is subject to 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/test/included/test_exec_monitor.hpp>
+#include <boost/test/floating_point_comparison.hpp>
+#include <boost/numeric_adaptor/numeric_adaptor.hpp>
+#include <boost/numeric_adaptor/ieee_policy.hpp>
+#include <boost/numeric_adaptor/gmp_policy.hpp>
+
+
+template <class Policy>
+double heron()
+{
+ typedef numeric_adaptor<Policy> num;
+
+ num a = 31622.77662;
+ num b = 0.000023;
+ num c = 31622.77661;
+ num s((a + b + c) / num(2.0));
+ return num::sqrt(s * (s - a) * (s - b) * (s - c));
+}
+
+int test_main(int, char*[])
+{
+ double epsilon = 0.0000001;
+
+ BOOST_CHECK_CLOSE(heron<ieee_policy<float> >(), 0.0, epsilon);
+ BOOST_CHECK_CLOSE(heron<ieee_policy<double> >(), 0.327490532778257, epsilon);
+ BOOST_CHECK_CLOSE(heron<ieee_policy<long double> >(), 0.327490459921098, epsilon);
+ BOOST_CHECK_CLOSE(heron<gmp_policy>(), 0.327490459942623, epsilon);
+
+ return 0;
+};


Boost-Commit list run by bdawes at acm.org, david.abrahams at rcn.com, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk