59typedef unsigned short int ushort;
60typedef unsigned int uint;
61typedef unsigned long int ulong;
63typedef long long int llint;
64typedef unsigned long long int ullint;
66#define BASIC_DEPENDENCY_TEST( \
67 DEPENDENCY, DEPTYPE, NUM_DEPENDEES, NUM_DEPENDENTS) \
68 std::string depXMLTag##DEPENDENCY = \
69 DummyObjectGetter< DEPTYPE >::getDummyObject()->getTypeAttributeValue(); \
71 TEST_ASSERT(DEPENDENCY->getTypeAttributeValue() == depXMLTag##DEPENDENCY ); \
72 TEST_ASSERT(DEPENDENCY->getDependents().size() == NUM_DEPENDENTS); \
73 TEST_ASSERT(DEPENDENCY->getDependees().size() == NUM_DEPENDEES); \
75#define VERIFY_DEPENDENT(DEPENDENCY, DEPENDENT) \
77 DEPENDENCY->getDependents().find(DEPENDENT) \
79 DEPENDENCY->getDependents().end() \
82#define VERIFY_DEPENDEE(DEPENDENCY, DEPENDEE) \
84 DEPENDENCY->getDependees().find(DEPENDEE) \
86 DEPENDENCY->getDependees().end()); \
88#define CREATE_DEPENDEE(POSTFIX, VALUE) \
89 RCP<ParameterEntry> dependeeParam##POSTFIX = rcp( \
90 new ParameterEntry( VALUE ));
92#define CREATE_DEPENDENT(POSTFIX, VALUE) \
93 RCP<ParameterEntry> dependentParam##POSTFIX = \
94 rcp(new ParameterEntry( VALUE )); \
96#define EXCEPTION_TEST_BOILERPLATE(DEPENDEE_VAL, DEPENDENT_VAL) \
97 CREATE_DEPENDEE(1, DEPENDEE_VAL); \
98 CREATE_DEPENDEE(Extra, DEPENDEE_VAL); \
99 CREATE_DEPENDENT(1, DEPENDENT_VAL); \
101 XMLParameterListWriter::EntryIDsMap writerEntryMap; \
102 writerEntryMap[dependeeParam1] = 1; \
103 writerEntryMap[dependentParam1] = 2; \
104 writerEntryMap[dependeeParamExtra] = 3; \
105 ValidatortoIDMap writerValiMap; \
107 XMLParameterListReader::EntryIDsMap readerEntryMap; \
108 readerEntryMap[1] = dependeeParam1; \
109 readerEntryMap[2] = dependentParam1; \
110 readerEntryMap[3] = dependeeParamExtra; \
111 IDtoValidatorMap readerValiMap; \
113#define CONVERT_DEP_TO_XML(DEPENDENCY) \
114 XMLObject DEPENDENCY##XML = DependencyXMLConverterDB::convertDependency( \
115 DEPENDENCY , writerEntryMap, writerValiMap); \
117#define TOO_MANY_DEPENDEE_TEST(DEPENDENCY) \
118 XMLObject extraDependee(DependencyXMLConverter::getDependeeTagName()); \
119 extraDependee.addAttribute<ParameterEntry::ParameterEntryID>( \
120 DependencyXMLConverter::getParameterIdAttributeName(), \
121 writerEntryMap[dependeeParamExtra]); \
122 XMLObject tooManyTempXML = DEPENDENCY##XML.deepCopy(); \
123 tooManyTempXML.addChild(extraDependee); \
126 DependencyXMLConverterDB::convertXML( \
127 tooManyTempXML , readerEntryMap, readerValiMap), \
128 TooManyDependeesException); \
130#define COPY_DEPTAG_WITHOUT_CHILD(TAG, CHILDTAG, NEWTAG) \
131 XMLObject NEWTAG(TAG.getTag()); \
132 NEWTAG.addAttribute( \
133 DependencyXMLConverter::getTypeAttributeName(), \
134 TAG.getAttribute(DependencyXMLConverter::getTypeAttributeName())); \
135 for(int i =0; i< TAG.numChildren(); i++){ \
136 if(TAG.getChild(i).getTag() != CHILDTAG) \
138 NEWTAG.addChild(TAG.getChild(i).deepCopy()); \
143#define INSERT_VALIDATOR_TO_MAPS(VALIDATOR) \
144 writerValiMap.insert( VALIDATOR ); \
145 readerValiMap.insert( \
146 IDtoValidatorMap::IDValidatorPair( \
147 writerValiMap.find( VALIDATOR )->second, VALIDATOR )); \
412#define NUMBER_VIS_TEST(T) \
413TEUCHOS_UNIT_TEST_TEMPLATE_1_INSTANT( \
414 Teuchos_Dependencies, NumberVisualDepSerialization, T)
523#define ArrayModifierTest(DEPENDENCYTYPE, ARRAY_TYPE) \
524TEUCHOS_UNIT_TEST_TEMPLATE_2_DECL( \
525 Teuchos_Dependencies, \
526 DEPENDENCYTYPE##_serialization_tests, \
530 std::string dependee1 = "dependee param"; \
531 std::string dependee2 = "dependee param2"; \
532 std::string dependent1 = "dependent param1"; \
533 std::string dependent2 = "dependent param2"; \
534 ParameterList myDepList("Array modifier dep list"); \
535 RCP<DependencySheet> myDepSheet = rcp(new DependencySheet); \
536 myDepList.set(dependee1, ScalarTraits<DependeeType>::one()); \
537 myDepList.set(dependee2, ScalarTraits<DependeeType>::one()); \
538 myDepList.set(dependent1, ARRAY_TYPE<DependentType>()); \
539 myDepList.set(dependent2, ARRAY_TYPE<DependentType>()); \
542 RCP<DEPENDENCYTYPE<DependeeType, DependentType> > basicArrayDep = \
543 rcp(new DEPENDENCYTYPE<DependeeType, DependentType>( \
544 myDepList.getEntryRCP(dependee1), \
545 myDepList.getEntryRCP(dependent1))); \
547 DependeeType one = ScalarTraits< DependeeType >::one(); \
548 RCP<AdditionFunction< DependeeType > > functionTester = \
549 rcp(new AdditionFunction<DependeeType>(one)); \
551 RCP<DEPENDENCYTYPE<DependeeType, DependentType> > funcArrayDep = \
552 rcp(new DEPENDENCYTYPE<DependeeType, DependentType>( \
553 myDepList.getEntryRCP(dependee2), \
554 myDepList.getEntryRCP(dependent2), \
558 myDepSheet->addDependency(basicArrayDep); \
559 myDepSheet->addDependency(funcArrayDep); \
561 RCP<DependencySheet> readInDepSheet = rcp(new DependencySheet); \
563 XMLParameterListWriter plWriter; \
564 XMLObject xmlOut = plWriter.toXML(myDepList, myDepSheet); \
565 out << xmlOut.toString(); \
567 RCP<ParameterList> readInList = \
568 writeThenReadPL(myDepList, myDepSheet, readInDepSheet); \
570 RCP<ParameterEntry> readinDependee1 = readInList->getEntryRCP(dependee1); \
571 RCP<ParameterEntry> readinDependent1 = readInList->getEntryRCP(dependent1); \
572 RCP<ParameterEntry> readinDependee2 = readInList->getEntryRCP(dependee2); \
573 RCP<ParameterEntry> readinDependent2 = readInList->getEntryRCP(dependent2); \
575 RCP<Dependency> readinDep1 = \
576 *(readInDepSheet->getDependenciesForParameter(readinDependee1)->begin()); \
577 RCP<Dependency> readinDep2 = \
578 *(readInDepSheet->getDependenciesForParameter(readinDependee2)->begin()); \
580 typedef DEPENDENCYTYPE<DependeeType, DependentType> deptype; \
581 BASIC_DEPENDENCY_TEST(readinDep1, deptype, 1, 1); \
582 VERIFY_DEPENDEE(readinDep1, readinDependee1); \
583 VERIFY_DEPENDENT(readinDep1, readinDependent1); \
585 BASIC_DEPENDENCY_TEST(readinDep2, deptype, 1, 1); \
586 VERIFY_DEPENDEE(readinDep2, readinDependee2); \
587 VERIFY_DEPENDENT(readinDep2, readinDependent2); \
589 RCP<DEPENDENCYTYPE<DependeeType, DependentType> > castedDep1 = \
590 rcp_dynamic_cast<DEPENDENCYTYPE<DependeeType, DependentType> >( \
592 TEST_ASSERT(castedDep1 != null); \
594 RCP<DEPENDENCYTYPE<DependeeType, DependentType> > castedDep2 = \
595 rcp_dynamic_cast<DEPENDENCYTYPE<DependeeType, DependentType> >( \
597 TEST_ASSERT(castedDep2 != null); \
599 RCP<const SimpleFunctionObject< DependeeType > > readInFunc = \
600 castedDep2->getFunctionObject(); \
601 TEST_ASSERT(readInFunc != null); \
603 RCP<const AdditionFunction< DependeeType > > castedFunc = \
604 rcp_dynamic_cast<const AdditionFunction< DependeeType > >(readInFunc); \
605 TEST_ASSERT(castedFunc != null); \
607 castedFunc->getModifiyingOperand(), \
608 functionTester->getModifiyingOperand()); \
613#define NUM_ARRAY_LENGTH_TEST(DependeeType, DependentType) \
614TEUCHOS_UNIT_TEST_TEMPLATE_2_INSTANT( \
615 Teuchos_Dependencies, \
616 NumberArrayLengthDependency_serialization_tests, \
624#define NUM_ARRAY_LENGTH_TEST_GROUP(DependeeType) \
625 NUM_ARRAY_LENGTH_TEST(DependeeType, int) \
626 NUM_ARRAY_LENGTH_TEST(DependeeType, float) \
627 NUM_ARRAY_LENGTH_TEST(DependeeType, double) \
628 NUM_ARRAY_LENGTH_TEST(DependeeType, llint)
635#define TWODROW_TEST(DependeeType, DependentType) \
636TEUCHOS_UNIT_TEST_TEMPLATE_2_INSTANT( \
637 Teuchos_Dependencies, \
638 TwoDRowDependency_serialization_tests, \
646#define TWODROW_TEST_GROUP(DependeeType) \
647 TWODROW_TEST(DependeeType, int) \
648 TWODROW_TEST(DependeeType, float) \
649 TWODROW_TEST(DependeeType, double) \
650 TWODROW_TEST(DependeeType, llint)
657#define TWODCOL_TEST(DependeeType, DependentType) \
658TEUCHOS_UNIT_TEST_TEMPLATE_2_INSTANT( \
659 Teuchos_Dependencies, \
660 TwoDColDependency_serialization_tests, \
668#define TWODCOL_TEST_GROUP(DependeeType) \
669 TWODCOL_TEST(DependeeType, int) \
670 TWODCOL_TEST(DependeeType, float) \
671 TWODCOL_TEST(DependeeType, double) \
672 TWODCOL_TEST(DependeeType, llint)
764 castedDep1->getValuesAndValidators().find(
"val1")->second,
true)->getMax(),
768 castedDep2->getValuesAndValidators().find(
"val1")->second,
true)->getMax(),
773 castedDep1->getValuesAndValidators().find(
"val2")->second,
true)->getMax(),
777 castedDep2->getValuesAndValidators().find(
"val2")->second,
true)->getMax(),
782 castedDep2->getDefaultValidator(),
true)->getMax(),
870 castedDep1->getTrueValidator(),
true)->getMax(),
874 castedDep1->getFalseValidator(),
true)->getMax(),
878 castedDep2->getTrueValidator(),
true)->getMax(),
887 std::string
dependee1 =
"dependee param";
888 std::string
dependee2 =
"dependee param2";
1020#define RANGE_VALIDATOR_TEST(T) \
1021TEUCHOS_UNIT_TEST_TEMPLATE_1_INSTANT( \
1022 Teuchos_Dependencies, RangeValidatorDepSerialization, T)
1035 getParametersFromXmlFile(
"MissingDependeeTag.xml",
depSheet),
1038 getParametersFromXmlFile(
"MissingDependentTag.xml",
depSheet),
1041 getParametersFromXmlFile(
"MissingDependee.xml",
depSheet),
1044 getParametersFromXmlFile(
"MissingDependent.xml",
depSheet),
#define TWODROW_TEST_GROUP(DependeeType)
#define TOO_MANY_DEPENDEE_TEST(DEPENDENCY)
#define NUMBER_VIS_TEST(T)
#define INSERT_VALIDATOR_TO_MAPS(VALIDATOR)
#define TWODCOL_TEST_GROUP(DependeeType)
#define VERIFY_DEPENDENT(DEPENDENCY, DEPENDENT)
#define EXCEPTION_TEST_BOILERPLATE(DEPENDEE_VAL, DEPENDENT_VAL)
#define COPY_DEPTAG_WITHOUT_CHILD(TAG, CHILDTAG, NEWTAG)
#define RANGE_VALIDATOR_TEST(T)
#define VERIFY_DEPENDEE(DEPENDENCY, DEPENDEE)
#define BASIC_DEPENDENCY_TEST(DEPENDENCY, DEPTYPE, NUM_DEPENDEES, NUM_DEPENDENTS)
#define CONVERT_DEP_TO_XML(DEPENDENCY)
#define NUM_ARRAY_LENGTH_TEST_GROUP(DependeeType)
#define ArrayModifierTest(DEPENDENCYTYPE, ARRAY_TYPE)
DataStructure keeping track of dependencies.
A database for DependencyXMLConverters.
#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.
Standard Conditions to be used.
A collection of standard dependencies.
A collection of standard DependencyXMLConverters.
#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.
Simple helper functions that make it easy to read and write XML to and from a parameterlist.
A Bool Logic Condition that returns the result or perfroming a logical AND on the conditions.
A Bool Condition is a Parameter Condition that evaluates whether or not a Boolean parameter is ture.
A BoolValidatorDependency says the following about the relationship between two parameters: Dependeni...
An xml converter for BoolVisualDepenencies.
A bool visual dependency says the following about the relationship between two elements in a Paramete...
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 const std::string & getXMLTagName()
A Dependency sheet keeps track of dependencies between various ParameterEntries.
static RCP< Dependency > convertXML(const XMLObject &xmlObject, const XMLParameterListReader::EntryIDsMap &entryIDsMap, const IDtoValidatorMap &validatorIDsMap)
Given an XMLObject converts the XMLObject to a Dependency.
std::set< RCP< ParameterEntry >, RCPComp > ParameterEntryList
A list of Dependees.
static RCP< T > getDummyObject()
Retrieves a dummy object of type T.
std::pair< ParameterEntryValidator::ValidatorID, RCP< ParameterEntryValidator > > IDValidatorPair
Thrown when no condtion tag is found when converting a ConditionVisualDependency from XML.
Thrown when no dependes of a dependency can't be found when converting the dependency to or from XML.
Thrown when no dependess of a dependency are specified when converting the dependency from XML.
Thrown when a dependent of a dependency cant be found when converting the dependency to or from XML.
Thrown when no dependents of a dependency are specified when converting the dependency from XML.
Thrown when the rangesAndValidators tag for the RangeValidatorDepencyConverter can't be found.
Thrown when converting a dependency that has validaotrs to and from XML. This excetpion indicates tha...
Thrown when converting a StrinvValidatorDependcny from XML and no valuesAndValidators tag is found.
A NumberArrayLengthDependency says the following about the relationship between two parameters: The l...
This object is held as the "value" in the Teuchos::ParameterList std::map.
A list of parameters of arbitrary type.
ParameterList & set(std::string const &name, T const &value, std::string const &docString="", RCP< const ParameterEntryValidator > const &validator=null)
Set a parameter whose value has type T.
RCP< ParameterEntry > getEntryRCP(const std::string &name)
Retrieves the RCP for an entry with the name name if it exists.
An xml converter for RangeValidatorDependencies.
A RangeValidatorDependency says the following about the relationship between two parameters: Dependen...
std::map< Range, RCP< const ParameterEntryValidator > > RangeToValidatorMap
Convenience typedef.
std::pair< T, T > Range
Convenience typedef.
Concrete serial communicator subclass.
A String Condition is a Parameter Condition that evaluates whether or not a string parameter has take...
static const std::string & getValuesAndValidatorsTag()
A StringValidatorDependency says the following about the relationship between two parameters: Depende...
std::map< std::string, RCP< const ParameterEntryValidator > > ValueToValidatorMap
Conveniece typedef.
static const std::string & getStringValuesTagName()
Gets the StringValues Tag.
A string visual depdencies says the following about the relationship between two elements in a Parame...
A thin wrapper around the Array class which causes it to be interpreted as a 2D Array.
A dependency in which the number of rows in a parameter with a TwoDArray depends on the value of anot...
A dependency in which the number of rows in a parameter with a TwoDArray depends on the value of anot...
A class for mapping validators to integers.
Thrown when a StringVisualDependency is being converted from XML and no Values tag is found.
Representation of an XML data tree. XMLObject is a ref-counted handle to a XMLObjectImplem object,...
std::string toString() const
Represent this node and its children as a std::string.
Writes a ParameterList to an XML object.
std::map< RCP< const ParameterEntry >, ParameterEntry::ParameterEntryID, RCPConstComp > EntryIDsMap
XMLObject toXML(const ParameterList &p, RCP< const DependencySheet > depSheet=null) const
bool nonnull(const std::shared_ptr< T > &p)
Returns true if p.get()!=NULL.
unsigned long long int ullint
StringValidatorDepSerialization
Dependency::ParameterEntryList dependentList
RCP< ParameterEntry > readinDependent1
TEUCHOS_DEPRECATED RCP< T > rcp(T *p, Dealloc_T dealloc, bool owns_mem)
Deprecated.
ParameterList myDepList("String Vali Dep List")
RCP< StringValidatorDependency > castedDep2
StringValidatorDependency::ValueToValidatorMap valuesAndValidators
out<< xmlOut.toString();RCP< ParameterList > readInList
RCP< EnhancedNumberValidator< double > > defaultVali
RCP< Dependency > readinDep2
RCP< EnhancedNumberValidator< double > > double2Vali
RCP< StringValidatorDependency > basicStringValiDep
RCP< DependencySheet > readInDepSheet
RCP< ParameterEntry > readinDependee1
RCP< StringValidatorDependency > castedDep1
RCP< ParameterEntry > readinDependee2
RCP< EnhancedNumberValidator< double > > double1Vali
RCP< ParameterEntry > readinDependent2
XMLParameterListWriter plWriter
RCP< Dependency > readinDep1
RCP< StringValidatorDependency > complexStringValiDep
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...
RCP< DependencySheet > myDepSheet
This structure defines some basic traits for a scalar field type.
static T one()
Returns representation of one for this scalar type.