28 EmptyModifier() : Teuchos::ParameterListModifier(
"Empty Modifier"){}
41 const std::string base_name =
"foo", non_base_name =
"bar";
42 const std::string param1 = base_name, param2 = base_name +
" 1";
43 const std::string sub1 = base_name +
"_sublist";
44 pl.
set(non_base_name, 1);
45 pl.
set(non_base_name + base_name, 2);
53 matches = empty_modifier->findMatchingBaseNames(pl, base_name,
true,
false);
54 expected = Teuchos::tuple(param1, param2);
56 matches = empty_modifier->findMatchingBaseNames(pl, base_name,
false,
true);
57 expected = Teuchos::tuple(sub1);
65 const std::string param_template_name =
"Template Parameter";
67 valid_pl.
set(param_template_name, 1);
68 auto valid_pl_copy = valid_pl;
71 empty_modifier->expandParameters(param_template_name, pl, valid_pl);
73 expected_valid_pl.
set(
"A", 1);
74 expected_valid_pl.
set(
"B", 1);
75 TEST_ASSERT(haveSameValuesSorted(expected_valid_pl, valid_pl,
true));
77 valid_pl = valid_pl_copy;
80 empty_modifier->expandParameters(param_template_name, pl, valid_pl, tuple<std::string>(
"C",
"D"));
81 TEST_ASSERT(haveSameValuesSorted(expected_valid_pl, valid_pl,
true));
88 const std::string sublist_template_name =
"Template Sublist";
91 valid_pl.
set(
"var", 1);
92 valid_pl.
sublist(sublist_template_name);
93 auto valid_pl_copy = valid_pl;
97 empty_modifier->expandSublists(sublist_template_name, pl, valid_pl);
100 expected_valid_pl.
sublist(
"B");
101 expected_valid_pl.
set(
"var", 1);
102 TEST_ASSERT(haveSameValuesSorted(expected_valid_pl, valid_pl,
true));
104 valid_pl = valid_pl_copy;
107 empty_modifier->expandSublists(sublist_template_name, pl, valid_pl, tuple<std::string>(
"C",
"D"));
108 TEST_ASSERT(haveSameValuesSorted(expected_valid_pl, valid_pl,
true));
116 const std::string base_name =
"A";
117 auto &vsub = valid_pl.
sublist(base_name, empty_modifier,
"Sublist A2");
122 empty_modifier->expandSublistsUsingBaseName(base_name, pl, valid_pl);
124 expected_valid_pl.
sublist(
"A1", empty_modifier,
"Sublist A2").
set(
"Val1", 1);
125 expected_valid_pl.
sublist(
"A2", empty_modifier,
"Sublist A2").
set(
"Val1", 1);
126 TEST_ASSERT(haveSameValuesSorted(expected_valid_pl, valid_pl,
true));
129 valid_pl = copy_valid_pl;
130 expected_valid_pl.
sublist(base_name, empty_modifier,
"Sublist A2").
set(
"Val1", 1);
131 empty_modifier->expandSublistsUsingBaseName(base_name, pl, valid_pl,
true);
132 TEST_ASSERT(haveSameValuesSorted(expected_valid_pl, valid_pl,
true));
134 valid_pl = copy_valid_pl;
135 TEST_THROW(empty_modifier->expandSublistsUsingBaseName(base_name, pl, valid_pl,
false), std::logic_error);
148 empty_modifier->setDefaultsInSublists(
"A", pl, tuple<std::string>(
"AA",
"AB"));
151 TEST_ASSERT(haveSameValuesSorted(expected_pl, pl,
true));
186 expected_pl.
sublist(
"Asub", modifier1);
#define TEST_INEQUALITY(v1, v2)
Assert the inequality of v1 and v2.
#define TEST_ASSERT(v1)
Assert the given statement is true.
#define TEST_EQUALITY(v1, v2)
Assert the equality of v1 and v2.
#define TEST_THROW(code, ExceptType)
Assert that the statement 'code' throws the exception 'ExceptType' (otherwise the test fails)...
ParameterList & set(std::string const &name, T &&value, std::string const &docString="", RCP< const ParameterEntryValidator > const &validator=null)
Templated set method.
Abstract interface for an object that can modify both a parameter list and the parameter list being u...
A std::string utilities class for Teuchos.
TEUCHOS_UNIT_TEST(ConstNonconstObjectContainer, create)
TEUCHOS_DEPRECATED RCP< T > rcp(T *p, Dealloc_T dealloc, bool owns_mem)
Deprecated.
Templated Parameter List class.
A list of parameters of arbitrary type.
SimpleModifier(const std::string &name)
Parameter List Modifier class.
ParameterList & sublist(const std::string &name, bool mustAlreadyExist=false, const std::string &docString="")
Creates an empty sublist and returns a reference to the sublist name. If the list already exists...
Smart reference counting pointer class for automatic garbage collection.
void setModifier(RCP< const ParameterListModifier > const &modifier)