NuTo
Numerics Tool
TestStructure.h
Go to the documentation of this file.
1 #pragma once
2 #include "BoostUnitTest.h"
3 #include <fakeit.hpp>
4 #include "nuto/base/Group.h"
7 
8 #include <boost/property_tree/ptree.hpp>
9 #include <boost/property_tree/xml_parser.hpp>
10 
11 namespace NuTo
12 {
13 namespace Test
14 {
15 
17 {
18  fakeit::Mock<NuTo::CellInterface> cell0;
19  fakeit::Mock<NuTo::CellInterface> cell1;
20  Quadrilateral myQuad;
21 
22 public:
24  {
25  Eigen::VectorXd bla = Eigen::Vector3d::Constant(1.0);
26  fakeit::When(ConstOverloadedMethod(cell0, Interpolate, Eigen::VectorXd(Eigen::VectorXd))).AlwaysReturn(bla);
27  fakeit::When(ConstOverloadedMethod(cell1, Interpolate, Eigen::VectorXd(Eigen::VectorXd))).AlwaysReturn(bla);
28  fakeit::When(Method(cell0, GetShape)).AlwaysReturn(myQuad);
29  fakeit::When(Method(cell1, GetShape)).AlwaysReturn(myQuad);
30  return {cell0.get(), cell1.get()};
31  }
32 };
33 
34 } /* Test */
35 } /* NuTo */
36 
37 namespace pt = boost::property_tree;
38 
40 {
41 public:
42  static void CheckNum(std::string filename, int expectedNumPoints, int expectedNumCells)
43  {
44  pt::ptree tree;
45  pt::read_xml(filename, tree);
46  int numOfPoints = tree.get<int>("VTKFile.UnstructuredGrid.Piece.<xmlattr>.NumberOfPoints");
47  int numOfCells = tree.get<int>("VTKFile.UnstructuredGrid.Piece.<xmlattr>.NumberOfCells");
48  BOOST_CHECK_EQUAL(numOfPoints, expectedNumPoints);
49  BOOST_CHECK_EQUAL(numOfCells, expectedNumCells);
50  }
51 };
Definition: TestStructure.h:16
Eigen::VectorXd Interpolate(const ElementInterface &element, NaturalCoords ipCoords)
Definition: ElementInterface.h:31
Definition: Quadrilateral.h:8
Definition: TestStructure.h:39
static void CheckNum(std::string filename, int expectedNumPoints, int expectedNumCells)
Definition: TestStructure.h:42
NuTo::Group< NuTo::CellInterface > Cells()
Definition: TestStructure.h:23
Definition: Exception.h:6