source: ThirdParty/vmg/test/unit_test/unit_test/polynomial_test.cpp

Candidate_v1.6.1
Last change on this file was 7faa5c, checked in by Frederik Heber <heber@…>, 9 years ago

Merge commit 'de061d9d851257a04e924d4472df4523d33bb08b' as 'ThirdParty/vmg'

  • Property mode set to 100644
File size: 1.9 KB
Line 
1/*
2 * vmg - a versatile multigrid solver
3 * Copyright (C) 2012 Institute for Numerical Simulation, University of Bonn
4 *
5 * vmg is free software: you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation, either version 3 of the License, or
8 * (at your option) any later version.
9 *
10 * vmg is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program. If not, see <http://www.gnu.org/licenses/>.
17 */
18
19#ifdef HAVE_CONFIG_H
20#include <libvmg_config.h>
21#endif
22
23#define BOOST_TEST_DYN_LINK
24#include <boost/test/unit_test.hpp>
25
26#include "base/polynomial.hpp"
27
28using namespace VMG;
29
30BOOST_AUTO_TEST_SUITE(PolynomialTest)
31
32BOOST_AUTO_TEST_CASE(PolynomialTest1)
33{
34 Polynomial p(2, 0.0, 0.0, 1.0);
35 BOOST_REQUIRE_CLOSE(p(2.0), 4.0, 0.0000001);
36}
37
38BOOST_AUTO_TEST_CASE(PolynomialTest2)
39{
40 Polynomial p(0, 4.0);
41 BOOST_REQUIRE_CLOSE(p(0.0), 4.0, 1.0e-16);
42 BOOST_REQUIRE_CLOSE(p(1.0), 4.0, 1.0e-16);
43 BOOST_REQUIRE_CLOSE(p(1000.0), 4.0, 1.0e-16);
44}
45
46BOOST_AUTO_TEST_CASE(PolynomialTest3)
47{
48 Polynomial p(4, -5.0, 7.0, -3.0, 4.5, -4.0);
49 BOOST_REQUIRE_CLOSE(p(1.5), -6.3125, 1.0e-16);
50 BOOST_REQUIRE_CLOSE(p(-7.5), -14780.9375, 1.0e-16);
51}
52
53BOOST_AUTO_TEST_CASE(PolynomialTestCopyConstructor)
54{
55 Polynomial p1(3, 2.5, 33.2, 7.0, 3.0);
56 Polynomial p2(p1);
57 BOOST_REQUIRE_CLOSE(p1(0.0), p2(0.0), 1.0e-16);
58 BOOST_REQUIRE_CLOSE(p1(32.3), p2(32.3), 1.0e-16);
59}
60
61BOOST_AUTO_TEST_CASE(PolynomialTestAssignment)
62{
63 Polynomial p1(3, 2.1, 5.3, -2.3, -4.3);
64 Polynomial p2;
65 p2 = p1;
66 BOOST_REQUIRE_CLOSE(p1(0.0), p2(0.0), 1.0e-16);
67 BOOST_REQUIRE_CLOSE(p1(32.3), p2(32.3), 1.0e-16);
68}
69
70BOOST_AUTO_TEST_SUITE_END()
Note: See TracBrowser for help on using the repository browser.