https://mooseframework.inl.gov
EBSDMeshErrorTest.h
Go to the documentation of this file.
1 //* This file is part of the MOOSE framework
2 //* https://mooseframework.inl.gov
3 //*
4 //* All rights reserved, see COPYRIGHT for full restrictions
5 //* https://github.com/idaholab/moose/blob/master/COPYRIGHT
6 //*
7 //* Licensed under LGPL 2.1, please see LICENSE for details
8 //* https://www.gnu.org/licenses/lgpl-2.1.html
9 
10 #pragma once
11 
12 // CPPUnit includes
13 #include "gtest_include.h"
14 
15 // Moose includes
16 #include "EBSDMeshGenerator.h"
17 #include "InputParameters.h"
18 #include "MooseParsedFunction.h"
19 #include "PhaseFieldApp.h"
20 #include "AppFactory.h"
21 #include "MooseMain.h"
22 
23 class EBSDMeshErrorTest : public ::testing::Test
24 {
25 protected:
26  void SetUp()
27  {
28  const char * argv[2] = {"foo", "\0"};
29  _app = Moose::createMooseApp("PhaseFieldApp", 1, (char **)argv);
30  _factory = &_app->getFactory();
31  }
32 
33  template <typename T>
34  void testParam(unsigned int nparam, const char ** param_list, std::string name)
35  {
36  for (unsigned int i = 0; i < nparam; ++i)
37  {
38  // create a unique name
39  std::ostringstream oss;
40  oss << name << "_" << i;
41 
42  // generate input parameter set
44  params.addPrivateParam("_moose_app", _app.get());
45  params.set<std::string>("_object_name") = oss.str();
46  params.set<std::string>("_type") = "EBSDMeshGenerator";
47 
48  // set a single parameter
49  params.set<T>(param_list[i]) = T(1.0);
50 
51  // set filename (is a required param but not used in these tests)
52  params.set<FileName>("filename") = "DUMMY";
53 
54  try
55  {
56  // construct mesh object
57  auto mesh = std::make_unique<EBSDMeshGenerator>(params);
58  // TODO: fix and uncomment this - it was missing before.
59  // FAIL() << "mesh construction should have failed but didn't";
60  }
61  catch (const std::exception & e)
62  {
63  std::string msg(e.what());
64  ASSERT_TRUE(
65  msg.find("Do not specify mesh geometry information, it is read from the EBSD file.") !=
66  std::string::npos)
67  << "failed with unexpected error: " << msg;
68  }
69  }
70  }
71 
72  std::shared_ptr<MooseApp> _app;
74 };
std::shared_ptr< MooseApp > createMooseApp(const std::string &default_app_type, int argc, char *argv[])
static InputParameters validParams()
void addPrivateParam(const std::string &name, const T &value)
T & set(const std::string &name, bool quiet_mode=false)
MeshBase & mesh
void testParam(unsigned int nparam, const char **param_list, std::string name)
const std::string name
Definition: Setup.h:20
std::shared_ptr< MooseApp > _app