TestCreation.hpp
1 // Distributed under the MIT License.
2 // See LICENSE.txt for details.
3 
4 #pragma once
5 
6 #include <memory>
7 #include <string>
8 
9 #include "Options/Options.hpp"
10 #include "Options/ParseOptions.hpp"
11 #include "Utilities/NoSuchType.hpp"
12 
13 namespace TestCreation_detail {
14 template <typename T>
15 struct Opt {
16  using type = T;
17  static constexpr OptionString help = {"halp"};
18 };
19 } // namespace TestCreation_detail
20 
21 /// \ingroup TestingFrameworkGroup
22 /// Construct an object from a given string. Each line in the string
23 /// must be indented.
24 template <typename T, typename Metavariables = NoSuchType>
25 T test_creation(const std::string& construction_string) noexcept {
27  options.parse("Opt:\n" + construction_string);
28  return options.template get<TestCreation_detail::Opt<T>, Metavariables>();
29 }
30 
31 /// \ingroup TestingFrameworkGroup
32 /// Construct a factory object from a given string. Each line in the
33 /// string must be indented.
34 template <typename BaseClass, typename Metavariables = NoSuchType>
36  const std::string& construction_string) noexcept {
37  return test_creation<std::unique_ptr<BaseClass>, Metavariables>(
38  construction_string);
39 }
T test_creation(const std::string &construction_string) noexcept
Construct an object from a given string. Each line in the string must be indented.
Definition: TestCreation.hpp:25
Defines classes and functions that handle parsing of input parameters.
Defines classes and functions for making classes creatable from input files.
const char *const OptionString
The string used in option structs.
Definition: Options.hpp:27
Definition: TestCreation.hpp:13
Class that handles parsing an input file.
Definition: ParseOptions.hpp:147
Definition: SolvePoissonProblem.hpp:38
std::unique_ptr< BaseClass > test_factory_creation(const std::string &construction_string) noexcept
Construct a factory object from a given string. Each line in the string must be indented.
Definition: TestCreation.hpp:35