Teuchos Package Browser (Single Doxygen Collection)  Version of the Day
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
FunctionObject_Serialization_UnitTests.cpp
Go to the documentation of this file.
1 // @HEADER
2 // *****************************************************************************
3 // Teuchos: Common Tools Package
4 //
5 // Copyright 2004 NTESS and the Teuchos contributors.
6 // SPDX-License-Identifier: BSD-3-Clause
7 // *****************************************************************************
8 // @HEADER
9 
14 
15 
16 namespace Teuchos{
17 
21 TEUCHOS_UNIT_TEST(Teuchos_Functions, SubtractionTests){
22  RCP<SubtractionFunction<int> > intTester = rcp(
23  new SubtractionFunction<int>(10));
24 
26  intTester);
27 
28  std::string type = subFuncXML.getRequired(
30  TEST_ASSERT(type == intTester->getTypeAttributeValue() );
31  int operand = subFuncXML.getRequired<int>(
33  TEST_ASSERT(operand == intTester->getModifiyingOperand());
34 
35  RCP<FunctionObject> readIn =
37  RCP<SubtractionFunction<int> > readInCasted =
38  rcp_dynamic_cast<SubtractionFunction<int> >(readIn);
39  TEST_ASSERT(readInCasted.get() != NULL);
41  readInCasted->getModifiyingOperand()
42  ==
43  intTester->getModifiyingOperand());
44 }
45 
46 TEUCHOS_UNIT_TEST(Teuchos_Functions, AdditionTests){
47  RCP<AdditionFunction<int> > intTester = rcp(
48  new AdditionFunction<int>(10));
49 
51  intTester);
52 
53  std::string type = addFuncXML.getRequired(
55  TEST_ASSERT(type == intTester->getTypeAttributeValue() );
56  int operand = addFuncXML.getRequired<int>(
58  TEST_ASSERT(operand == intTester->getModifiyingOperand());
59 
60  RCP<FunctionObject> readIn =
62  RCP<AdditionFunction<int> > readInCasted =
63  rcp_dynamic_cast<AdditionFunction<int> >(readIn);
64  TEST_ASSERT(readInCasted.get() != NULL);
66  readInCasted->getModifiyingOperand()
67  ==
68  intTester->getModifiyingOperand());
69 }
70 
71 TEUCHOS_UNIT_TEST(Teuchos_Functions, MultiplicationTests){
74 
76  intTester);
77 
78  std::string type = multiFuncXML.getRequired(
80  TEST_ASSERT(type == intTester->getTypeAttributeValue() );
81  int operand = multiFuncXML.getRequired<int>(
83  TEST_ASSERT(operand == intTester->getModifiyingOperand());
84 
85  RCP<FunctionObject> readIn =
87  RCP<MultiplicationFunction<int> > readInCasted =
88  rcp_dynamic_cast<MultiplicationFunction<int> >(readIn);
89  TEST_ASSERT(readInCasted.get() != NULL);
91  readInCasted->getModifiyingOperand()
92  ==
93  intTester->getModifiyingOperand());
94 }
95 
96 TEUCHOS_UNIT_TEST(Teuchos_Functions, DivisionTests){
97  RCP<DivisionFunction<int> > intTester = rcp(
98  new DivisionFunction<int>(10));
99 
101  intTester);
102 
103  std::string type = divisFuncXML.getRequired(
105  TEST_ASSERT(type == intTester->getTypeAttributeValue() );
106  int operand = divisFuncXML.getRequired<int>(
108  TEST_ASSERT(operand == intTester->getModifiyingOperand());
109 
110  RCP<FunctionObject> readIn =
112  RCP<DivisionFunction<int> > readInCasted =
113  rcp_dynamic_cast<DivisionFunction<int> >(readIn);
114  TEST_ASSERT(readInCasted.get() != NULL);
115  TEST_ASSERT(
116  readInCasted->getModifiyingOperand()
117  ==
118  intTester->getModifiyingOperand());
119 }
120 
121 
122 
123 } //namespace Teuchos
124 
#define TEST_ASSERT(v1)
Assert the given statement is true.
static XMLObject convertFunctionObject(RCP< const FunctionObject > function)
Given a FunctionObject, converts the FunctionObject to XML.
A simple function object that multiplys a specififed value from the given arguement in the runFunctio...
A simple function object that adds a specififed value from the given arguement in the runFunction fun...
T * get() const
Get the raw C++ pointer to the underlying object.
A database for FunctionObjectXMLConverters.
A simple function object that subtracts a specififed value from the given arguement in the runFunctio...
TEUCHOS_UNIT_TEST(ConstNonconstObjectContainer, create)
TEUCHOS_DEPRECATED RCP< T > rcp(T *p, Dealloc_T dealloc, bool owns_mem)
Deprecated.
Representation of an XML data tree. XMLObject is a ref-counted handle to a XMLObjectImplem object...
Unit testing support.
A simple function object that divides a specififed value from the given arguement in the runFunction ...
Smart reference counting pointer class for automatic garbage collection.
static RCP< FunctionObject > convertXML(const XMLObject &xmlObject)
Given an XMLObject, converts the XMLObject to a FunctionObject.
const std::string & getRequired(const std::string &name) const
Get an attribute, throwing an std::exception if it is not found.