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::UnitTests
41{
43{
44public:
46 {
47 }
48 explicit PointTestClass(int data) : m_dataValue(data)
49 {
50 }
51 PointTestClass(const PointTestClass &) = default;
53 {
54 }
55
57 {
59 return *this;
60 }
61
62 int value() const
63 {
64 return m_dataValue;
65 }
66
67private:
69};
70
71bool operator==(const PointTestClass &lhs, const PointTestClass &rhs)
72{
73 return lhs.value() == rhs.value();
74}
75
76bool operator!=(const PointTestClass &lhs, const PointTestClass &rhs)
77{
78 return !(lhs == rhs);
79}
80
81class TestPoint : public Nektar::NekPoint<double>
82{
83public:
85 {
86 }
87 TestPoint(const TestPoint &rhs) : Nektar::NekPoint<double>(rhs)
88 {
89 }
90};
91
92void test()
93{
95 TestPoint p1(p);
96}
97
98struct TenD
99{
100 static const unsigned int Value = 10;
101};
102
103BOOST_AUTO_TEST_CASE(testNekPointConstruction)
104{
105 using namespace Nektar;
106
107 // Test the constructors on a numeric type.
108 {
110 BOOST_CHECK(p1.x() == 0.0);
111 BOOST_CHECK(p1.y() == 0.0);
112 BOOST_CHECK(p1.z() == 0.0);
113
114 NekPoint<double> p3(p1);
115 BOOST_CHECK(p1 == p3);
116 }
117
118 // Now test it on an arbitrary type.
119 {
121 BOOST_CHECK(p1.x() == PointTestClass(0));
122 BOOST_CHECK(p1.y() == PointTestClass(0));
123 BOOST_CHECK(p1.z() == PointTestClass(0));
124
125 BOOST_CHECK(p1.x() == PointTestClass());
126 BOOST_CHECK(p1.y() == PointTestClass());
127 BOOST_CHECK(p1.z() == PointTestClass());
128
130 BOOST_CHECK(p1 == p3);
131 }
132}
133
134} // namespace Nektar::UnitTests
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)
static const unsigned int Value