|
Teuchos Package Browser (Single Doxygen Collection)
Version of the Day
|
00001 // @HEADER 00002 // *********************************************************************** 00003 // 00004 // Teuchos: Common Tools Package 00005 // Copyright (2004) Sandia Corporation 00006 // 00007 // Under terms of Contract DE-AC04-94AL85000, there is a non-exclusive 00008 // license for use of this work by or on behalf of the U.S. Government. 00009 // 00010 // Redistribution and use in source and binary forms, with or without 00011 // modification, are permitted provided that the following conditions are 00012 // met: 00013 // 00014 // 1. Redistributions of source code must retain the above copyright 00015 // notice, this list of conditions and the following disclaimer. 00016 // 00017 // 2. Redistributions in binary form must reproduce the above copyright 00018 // notice, this list of conditions and the following disclaimer in the 00019 // documentation and/or other materials provided with the distribution. 00020 // 00021 // 3. Neither the name of the Corporation nor the names of the 00022 // contributors may be used to endorse or promote products derived from 00023 // this software without specific prior written permission. 00024 // 00025 // THIS SOFTWARE IS PROVIDED BY SANDIA CORPORATION "AS IS" AND ANY 00026 // EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 00027 // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 00028 // PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL SANDIA CORPORATION OR THE 00029 // CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 00030 // EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 00031 // PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 00032 // PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF 00033 // LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 00034 // NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 00035 // SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 00036 // 00037 // Questions? Contact Michael A. Heroux (maherou@sandia.gov) 00038 // 00039 // *********************************************************************** 00040 // @HEADER 00041 00042 #include "Teuchos_VerboseObject.hpp" 00043 #include "Teuchos_StandardFunctionObjects.hpp" 00044 #include "Teuchos_FunctionObjectXMLConverterDB.hpp" 00045 #include "Teuchos_UnitTestHarness.hpp" 00046 00047 00048 namespace Teuchos{ 00049 00053 TEUCHOS_UNIT_TEST(Teuchos_Functions, SubtractionTests){ 00054 RCP<SubtractionFunction<int> > intTester = rcp( 00055 new SubtractionFunction<int>(10)); 00056 00057 XMLObject subFuncXML = FunctionObjectXMLConverterDB::convertFunctionObject( 00058 intTester); 00059 00060 std::string type = subFuncXML.getRequired( 00061 FunctionObjectXMLConverter::getTypeAttributeName()); 00062 TEST_ASSERT(type == intTester->getTypeAttributeValue() ); 00063 int operand = subFuncXML.getRequired<int>( 00064 SimpleFunctionXMLConverter<int>::getOperandAttributeName()); 00065 TEST_ASSERT(operand == intTester->getModifiyingOperand()); 00066 00067 RCP<FunctionObject> readIn = 00068 FunctionObjectXMLConverterDB::convertXML(subFuncXML); 00069 RCP<SubtractionFunction<int> > readInCasted = 00070 rcp_dynamic_cast<SubtractionFunction<int> >(readIn); 00071 TEST_ASSERT(readInCasted.get() != NULL); 00072 TEST_ASSERT( 00073 readInCasted->getModifiyingOperand() 00074 == 00075 intTester->getModifiyingOperand()); 00076 } 00077 00078 TEUCHOS_UNIT_TEST(Teuchos_Functions, AdditionTests){ 00079 RCP<AdditionFunction<int> > intTester = rcp( 00080 new AdditionFunction<int>(10)); 00081 00082 XMLObject addFuncXML = FunctionObjectXMLConverterDB::convertFunctionObject( 00083 intTester); 00084 00085 std::string type = addFuncXML.getRequired( 00086 FunctionObjectXMLConverter::getTypeAttributeName()); 00087 TEST_ASSERT(type == intTester->getTypeAttributeValue() ); 00088 int operand = addFuncXML.getRequired<int>( 00089 SimpleFunctionXMLConverter<int>::getOperandAttributeName()); 00090 TEST_ASSERT(operand == intTester->getModifiyingOperand()); 00091 00092 RCP<FunctionObject> readIn = 00093 FunctionObjectXMLConverterDB::convertXML(addFuncXML); 00094 RCP<AdditionFunction<int> > readInCasted = 00095 rcp_dynamic_cast<AdditionFunction<int> >(readIn); 00096 TEST_ASSERT(readInCasted.get() != NULL); 00097 TEST_ASSERT( 00098 readInCasted->getModifiyingOperand() 00099 == 00100 intTester->getModifiyingOperand()); 00101 } 00102 00103 TEUCHOS_UNIT_TEST(Teuchos_Functions, MultiplicationTests){ 00104 RCP<MultiplicationFunction<int> > intTester = rcp( 00105 new MultiplicationFunction<int>(10)); 00106 00107 XMLObject multiFuncXML = FunctionObjectXMLConverterDB::convertFunctionObject( 00108 intTester); 00109 00110 std::string type = multiFuncXML.getRequired( 00111 FunctionObjectXMLConverter::getTypeAttributeName()); 00112 TEST_ASSERT(type == intTester->getTypeAttributeValue() ); 00113 int operand = multiFuncXML.getRequired<int>( 00114 SimpleFunctionXMLConverter<int>::getOperandAttributeName()); 00115 TEST_ASSERT(operand == intTester->getModifiyingOperand()); 00116 00117 RCP<FunctionObject> readIn = 00118 FunctionObjectXMLConverterDB::convertXML(multiFuncXML); 00119 RCP<MultiplicationFunction<int> > readInCasted = 00120 rcp_dynamic_cast<MultiplicationFunction<int> >(readIn); 00121 TEST_ASSERT(readInCasted.get() != NULL); 00122 TEST_ASSERT( 00123 readInCasted->getModifiyingOperand() 00124 == 00125 intTester->getModifiyingOperand()); 00126 } 00127 00128 TEUCHOS_UNIT_TEST(Teuchos_Functions, DivisionTests){ 00129 RCP<DivisionFunction<int> > intTester = rcp( 00130 new DivisionFunction<int>(10)); 00131 00132 XMLObject divisFuncXML = FunctionObjectXMLConverterDB::convertFunctionObject( 00133 intTester); 00134 00135 std::string type = divisFuncXML.getRequired( 00136 FunctionObjectXMLConverter::getTypeAttributeName()); 00137 TEST_ASSERT(type == intTester->getTypeAttributeValue() ); 00138 int operand = divisFuncXML.getRequired<int>( 00139 SimpleFunctionXMLConverter<int>::getOperandAttributeName()); 00140 TEST_ASSERT(operand == intTester->getModifiyingOperand()); 00141 00142 RCP<FunctionObject> readIn = 00143 FunctionObjectXMLConverterDB::convertXML(divisFuncXML); 00144 RCP<DivisionFunction<int> > readInCasted = 00145 rcp_dynamic_cast<DivisionFunction<int> >(readIn); 00146 TEST_ASSERT(readInCasted.get() != NULL); 00147 TEST_ASSERT( 00148 readInCasted->getModifiyingOperand() 00149 == 00150 intTester->getModifiyingOperand()); 00151 } 00152 00153 00154 00155 } //namespace Teuchos 00156
1.7.6.1