Nektar++
testNekPoint.cpp
Go to the documentation of this file.
1///////////////////////////////////////////////////////////////////////////////
2//
3// File: testNekPoint.cpp
4//
5// For more information, please see: http://www.nektar.info
6//
7// The MIT License
8//
9// Copyright (c) 2006 Division of Applied Mathematics, Brown University (USA),
10// Department of Aeronautics, Imperial College London (UK), and Scientific
11// Computing and Imaging Institute, University of Utah (USA).
12//
13// Permission is hereby granted, free of charge, to any person obtaining a
14// copy of this software and associated documentation files (the "Software"),
15// to deal in the Software without restriction, including without limitation
16// the rights to use, copy, modify, merge, publish, distribute, sublicense,
17// and/or sell copies of the Software, and to permit persons to whom the
18// Software is furnished to do so, subject to the following conditions:
19//
20// The above copyright notice and this permission notice shall be included
21// in all copies or substantial portions of the Software.
22//
23// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
24// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
25// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
26// THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
27// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
28// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
29// DEALINGS IN THE SOFTWARE.
30//
31// Description: Test code for NekPoint
32//
33///////////////////////////////////////////////////////////////////////////////
34
36#include <UnitTests/util.h>
37#include <boost/test/tools/floating_point_comparison.hpp>
38#include <boost/test/unit_test.hpp>
39
40namespace Nektar
41{
42namespace UnitTests
43{
45{
46public:
48 {
49 }
50 explicit PointTestClass(int data) : m_dataValue(data)
51 {
52 }
53 PointTestClass(const PointTestClass &) = default;
55 {
56 }
57
59 {
61 return *this;
62 }
63
64 int value() const
65 {
66 return m_dataValue;
67 }
68
69private:
71};
72
73bool operator==(const PointTestClass &lhs, const PointTestClass &rhs)
74{
75 return lhs.value() == rhs.value();
76}
77
78bool operator!=(const PointTestClass &lhs, const PointTestClass &rhs)
79{
80 return !(lhs == rhs);
81}
82
83class TestPoint : public Nektar::NekPoint<double>
84{
85public:
87 {
88 }
89 TestPoint(const TestPoint &rhs) : Nektar::NekPoint<double>(rhs)
90 {
91 }
92};
93
94void test()
95{
97 TestPoint p1(p);
98}
99
100struct TenD
101{
102 static const unsigned int Value = 10;
103};
104
105BOOST_AUTO_TEST_CASE(testNekPointConstruction)
106{
107 using namespace Nektar;
108
109 // Test the constructors on a numeric type.
110 {
112 BOOST_CHECK(p1.x() == 0.0);
113 BOOST_CHECK(p1.y() == 0.0);
114 BOOST_CHECK(p1.z() == 0.0);
115
116 NekPoint<double> p3(p1);
117 BOOST_CHECK(p1 == p3);
118 }
119
120 // Now test it on an arbitrary type.
121 {
123 BOOST_CHECK(p1.x() == PointTestClass(0));
124 BOOST_CHECK(p1.y() == PointTestClass(0));
125 BOOST_CHECK(p1.z() == PointTestClass(0));
126
127 BOOST_CHECK(p1.x() == PointTestClass());
128 BOOST_CHECK(p1.y() == PointTestClass());
129 BOOST_CHECK(p1.z() == PointTestClass());
130
132 BOOST_CHECK(p1 == p3);
133 }
134}
135
136} // namespace UnitTests
137} // namespace Nektar
boost::call_traits< DataType >::const_reference x() const
Definition: NekPoint.hpp:160
boost::call_traits< DataType >::const_reference z() const
Definition: NekPoint.hpp:172
boost::call_traits< DataType >::const_reference y() const
Definition: NekPoint.hpp:166
PointTestClass(const PointTestClass &)=default
PointTestClass operator=(const PointTestClass &rhs)
TestPoint(const TestPoint &rhs)
bool operator!=(const PointTestClass &lhs, const PointTestClass &rhs)
std::vector< double > p(NPUPPER)
bool operator==(const PointTestClass &lhs, const PointTestClass &rhs)
BOOST_AUTO_TEST_CASE(TestGaussInt)
The above copyright notice and this permission notice shall be included.
Definition: CoupledSolver.h:2
static const unsigned int Value