Teuchos Package Browser (Single Doxygen Collection) Version of the Day
Loading...
Searching...
No Matches
Condition_Serialization_UnitTests.cpp
Go to the documentation of this file.
1// @HEADER
2// ***********************************************************************
3//
4// Teuchos: Common Tools Package
5// Copyright (2004) Sandia Corporation
6//
7// Under terms of Contract DE-AC04-94AL85000, there is a non-exclusive
8// license for use of this work by or on behalf of the U.S. Government.
9//
10// Redistribution and use in source and binary forms, with or without
11// modification, are permitted provided that the following conditions are
12// met:
13//
14// 1. Redistributions of source code must retain the above copyright
15// notice, this list of conditions and the following disclaimer.
16//
17// 2. Redistributions in binary form must reproduce the above copyright
18// notice, this list of conditions and the following disclaimer in the
19// documentation and/or other materials provided with the distribution.
20//
21// 3. Neither the name of the Corporation nor the names of the
22// contributors may be used to endorse or promote products derived from
23// this software without specific prior written permission.
24//
25// THIS SOFTWARE IS PROVIDED BY SANDIA CORPORATION "AS IS" AND ANY
26// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
27// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
28// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL SANDIA CORPORATION OR THE
29// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
30// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
31// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
32// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
33// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
34// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
35// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
36//
37// Questions? Contact Michael A. Heroux (maherou@sandia.gov)
38//
39// ***********************************************************************
40// @HEADER
41
52
54
55
56namespace Teuchos{
57
58
64 std::string paramName1 = "string param";
65 std::string paramName2 = "string param2";
66 std::string dependent1Name = "dependent1";
67 std::string dependent2Name = "dependent2";
68 std::string paramValue = "cheese";
71 tuple<std::string>("steve", "blah", "your face");
72 ParameterList testList("Condition Test List");
81 testList.getEntryRCP(paramName2), conditionVal2));
82
86 testList.getEntryRCP(dependent1Name)));
87
91 testList.getEntryRCP(dependent2Name)));
92
94 depSheet1->addDependency(simpleConDep);
95 depSheet1->addDependency(complexConDep);
96
97 writeParameterListToXmlOStream(testList, out, depSheet1);
98
102
105
108 *(depSheetIn->getDependenciesForParameter(readInDependee1)->begin()));
110 simpleReadInDep->getCondition()->getTypeAttributeValue(),
111 DummyObjectGetter<StringCondition>::getDummyObject()->getTypeAttributeValue());
115
116
119 *(depSheetIn->getDependenciesForParameter(readInDependee2)->begin()));
121 complexReadInDep->getCondition()->getTypeAttributeValue(),
122 DummyObjectGetter<StringCondition>::getDummyObject()->getTypeAttributeValue());
126
127
129 simpleReadInCon->getValueList(), simpleStringCon->getValueList());
131 complexReadInCon->getValueList(), complexStringCon->getValueList());
132
133}
134
137 std::string paramName1 = "bool param";
138 std::string dependent1Name = "dependent1";
139 bool paramValue = true;
140 std::string dependentValue = "hi there!";
141 ParameterList testList("Condition Test List");
145 rcp(new BoolCondition(testList.getEntryRCP(paramName1)));
146
149 boolCon,
150 testList.getEntryRCP(dependent1Name)));
151
153 depSheet1->addDependency(boolConDep);
154
158
160
163 *(depSheetIn->getDependenciesForParameter(readInDependee1)->begin()));
165 simpleReadInDep->getCondition()->getTypeAttributeValue(),
166 DummyObjectGetter<BoolCondition>::getDummyObject()->getTypeAttributeValue());
170
171}
172
175 std::string paramName1 = "T param";
176 std::string paramName2 = "T param 2";
177 std::string dependent1Name = "dependent1";
178 std::string dependent2Name = "dependent2";
181 std::string dependentValue = "hi there!";
182 ParameterList testList("Condition Test List");
187
189 rcp(new NumberCondition< T >(testList.getEntryRCP(paramName1)));
190
193
196
199 numberCon,
200 testList.getEntryRCP(dependent1Name)));
201
205 testList.getEntryRCP(dependent2Name)));
206
208 depSheet1->addDependency(numberConDep);
209 depSheet1->addDependency(funcNumberConDep);
210
214
217
218
219
220
223 *(depSheetIn->getDependenciesForParameter(readInDependee1)->begin()));
225 simpleReadInDep->getCondition()->getTypeAttributeValue(),
226 DummyObjectGetter<NumberCondition< T > >::getDummyObject()->getTypeAttributeValue());
230
231
234 *(depSheetIn->getDependenciesForParameter(readInDependee2)->begin()));
235 TEST_ASSERT(funcReadInDep != null);
236
239
240 TEST_ASSERT(funcReadInCon != null);
241
244 funcReadInCon->getFunctionObject());
247 funcReadInFunc->getModifiyingOperand(),
248 funcTester->getModifiyingOperand());
249
250
251}
252
253#define NUMBER_PARAM_TYPE_TEST( T ) \
254TEUCHOS_UNIT_TEST_TEMPLATE_1_INSTANT(Teuchos_Conditions, NumberConditionSerialization, T )
255
256typedef unsigned int uint;
257typedef unsigned short ushort;
258typedef unsigned long ulong;
259
268typedef long long int llint;
269typedef unsigned long long int ullint;
272
275 std::string paramName1 = "bool param1";
276 std::string paramName2 = "bool param2";
277 std::string dependent1Name = "dependent1";
278 bool paramValue1 = true;
279 bool paramValue2 = false;
280 std::string dependentValue = "hi there!";
281 ParameterList testList("Condition Test List");
286 rcp(new BoolCondition(testList.getEntryRCP(paramName1)));
288 rcp(new BoolCondition(testList.getEntryRCP(paramName1)));
289
292
294
297 binCon,
298 testList.getEntryRCP(dependent1Name)));
299
301 depSheet1->addDependency(binConDep);
302
306
309
312 *(depSheetIn->getDependenciesForParameter(readInDependee1)->begin()));
315 *(depSheetIn->getDependenciesForParameter(readInDependee1)->begin()));
316 TEST_EQUALITY(readInDep1.get(), readInDep1.get());
318 readInDep1->getCondition()->getTypeAttributeValue(),
319 DummyObjectGetter< BinCondition >::getDummyObject()->getTypeAttributeValue());
323
326
327}
328
329#define BIN_CON_TEST( BinCondition ) \
330TEUCHOS_UNIT_TEST_TEMPLATE_1_INSTANT(Teuchos_Conditions, BoolLogicConditionSerialization, BinCondition)
331
332BIN_CON_TEST(AndCondition)
333BIN_CON_TEST(OrCondition)
334BIN_CON_TEST(EqualsCondition)
335
338 std::string paramName1 = "bool param1";
339 std::string dependent1Name = "dependent1";
340 bool paramValue1 = true;
341 std::string dependentValue = "hi there!";
342 ParameterList testList("Condition Test List");
346 rcp(new BoolCondition(testList.getEntryRCP(paramName1)));
347
348
350
353 notCon,
354 testList.getEntryRCP(dependent1Name)));
355
357 depSheet1->addDependency(notConDep);
358
362
364
367 *(depSheetIn->getDependenciesForParameter(readInDependee1)->begin()));
369 readInDep1->getCondition()->getTypeAttributeValue(),
370 DummyObjectGetter<NotCondition>::getDummyObject()->getTypeAttributeValue());
374}
375
403
404
405} // namespace Teuchos
#define NUMBER_PARAM_TYPE_TEST(T)
#define BIN_CON_TEST(BinCondition)
A database for ConditionXMLConverters.
#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).
#define TEST_COMPARE_ARRAYS(a1, a2)
Assert that a1.size()==a2.size() and a[i]==b[i], i=0....
Templated Parameter List class.
A collection of standard ConditionXMLConverters.
Standard Conditions to be used.
A collection of standard dependencies.
Unit testing support.
#define TEUCHOS_UNIT_TEST_TEMPLATE_1_DECL(TEST_GROUP, TEST_NAME, TYPE)
Macro for defining a templated unit test with one template parameter.
#define TEUCHOS_UNIT_TEST(TEST_GROUP, TEST_NAME)
Macro for defining a (non-templated) unit test.
A collection of Exceptions thrown when converting Conditions to and from XML.
Simple helper functions that make it easy to read and write XML to and from a parameterlist.
A collection of Exceptions that can be potentially thrown when converting a ParameterList to and from...
A Bool Condition is a Parameter Condition that evaluates whether or not a Boolean parameter is ture.
int size(const Comm< Ordinal > &comm)
Get the number of processes in the communicator.
A condition visual dependency says the following about the relationship between elements in a Paramet...
static void printKnownConverters(std::ostream &out)
prints the xml tags associated with all known converters
A Dependency sheet keeps track of dependencies between various ParameterEntries.
Class for retrieving a dummy object of type T.
Thrown when a referenced ParameterEntry can't be found.
Thrown when a StringConditon is missing it's Value tag.
A Not condition returns the result of performing a logical NOT on a given condition.
This object is held as the "value" in the Teuchos::ParameterList std::map.
A list of parameters of arbitrary type.
Concrete serial communicator subclass.
A String Condition is a Parameter Condition that evaluates whether or not a string parameter has take...
Representation of an XML data tree. XMLObject is a ref-counted handle to a XMLObjectImplem object,...
std::map< RCP< const ParameterEntry >, ParameterEntry::ParameterEntryID, RCPConstComp > EntryIDsMap
bool nonnull(const std::shared_ptr< T > &p)
Returns true if p.get()!=NULL.
TEUCHOS_DEPRECATED RCP< T > rcp(T *p, Dealloc_T dealloc, bool owns_mem)
Deprecated.
TEUCHOSPARAMETERLIST_LIB_DLL_EXPORT RCP< ParameterList > writeThenReadPL(ParameterList &myList)
Write a parameter list to xml and then read that xml back in via a string. The intent of this functio...
static T one()
Returns representation of one for this scalar type.