本文整理汇总了C++中Teuchos::writeThenReadPL方法的典型用法代码示例。如果您正苦于以下问题:C++ Teuchos::writeThenReadPL方法的具体用法?C++ Teuchos::writeThenReadPL怎么用?C++ Teuchos::writeThenReadPL使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Teuchos
的用法示例。
在下文中一共展示了Teuchos::writeThenReadPL方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: myList
TEUCHOS_UNIT_TEST(Teuchos_Validator, fileNameValidatorConverter)
{
std::string defaultParameterName = "default";
std::string nonDefaultParameterName = "non default";
RCP<FileNameValidator> defaultValidator =
rcp(new FileNameValidator);
RCP<FileNameValidator> nonDefaultValidator =
rcp(new FileNameValidator(true));
ParameterList myList("FileName Validator List");
myList.set("default", "", "parameter for default validator",
defaultValidator);
myList.set("non default", "blah.txt", "parameter for non default validator",
nonDefaultValidator);
RCP<ParameterList> readInPL = writeThenReadPL(myList);
RCP<const FileNameValidator> readinDefault =
rcp_dynamic_cast<const FileNameValidator>(
readInPL->getEntry(defaultParameterName).validator(), true);
TEST_EQUALITY(readinDefault->fileMustExist(), defaultValidator->fileMustExist());
RCP<const FileNameValidator> readinNonDefault =
rcp_dynamic_cast<const FileNameValidator>(
readInPL->getEntry(nonDefaultParameterName).validator(), true);
TEST_EQUALITY(readinNonDefault->fileMustExist(), nonDefaultValidator->fileMustExist());
}
示例2: AnyNumberParameterEntryValidator
TEUCHOS_UNIT_TEST(Teuchos_Validator, anynumberValidatorConverter)
{
std::string xmlFileName = "AnyNumberValidatorList.xml";
std::string defaultParameterName = "default";
std::string nonDefaultParameterName = "preferred and accepted";
RCP<AnyNumberParameterEntryValidator> defaultValidator =
rcp(new AnyNumberParameterEntryValidator());
AnyNumberParameterEntryValidator::AcceptedTypes acceptedTypes;
acceptedTypes.allowDouble(false);
RCP<AnyNumberParameterEntryValidator> nonDefaultValidator =
rcp(
new AnyNumberParameterEntryValidator(
AnyNumberParameterEntryValidator::PREFER_INT,
acceptedTypes
)
);
ParameterList myList("AnyNumberValidatorList");
myList.set(defaultParameterName, 10.0,
"A parameter with the default AnyNumberValidator on it", defaultValidator);
myList.set(nonDefaultParameterName, 1,
"A prameter with an AnyNumberValidator on it that has the preferred and accepted types differnet from the default",
nonDefaultValidator);
RCP<ParameterList> readInPL = writeThenReadPL(myList);
RCP<const AnyNumberParameterEntryValidator> readinDefaultValidator =
rcp_dynamic_cast<const AnyNumberParameterEntryValidator>(
readInPL->getEntry(defaultParameterName).validator(), true);
TEST_EQUALITY(readinDefaultValidator->isDoubleAllowed(),
defaultValidator->isDoubleAllowed());
TEST_EQUALITY(readinDefaultValidator->isIntAllowed(),
defaultValidator->isIntAllowed());
TEST_EQUALITY(readinDefaultValidator->isStringAllowed(),
defaultValidator->isStringAllowed());
TEST_EQUALITY(readinDefaultValidator->getPreferredType(),
defaultValidator->getPreferredType());
RCP<const AnyNumberParameterEntryValidator> readinNonDefaultValidator =
rcp_dynamic_cast<const AnyNumberParameterEntryValidator>(
readInPL->getEntry(nonDefaultParameterName).validator(), true);
TEST_EQUALITY(readinNonDefaultValidator->isDoubleAllowed(),
nonDefaultValidator->isDoubleAllowed());
TEST_EQUALITY(readinNonDefaultValidator->isIntAllowed(),
nonDefaultValidator->isIntAllowed());
TEST_EQUALITY(readinNonDefaultValidator->isStringAllowed(),
nonDefaultValidator->isStringAllowed());
TEST_EQUALITY(readinNonDefaultValidator->getPreferredType(),
nonDefaultValidator->getPreferredType());
}
示例3: pl
TEUCHOS_UNIT_TEST(Teuchos_Validator, existingPrototypeTest){
ParameterList pl("ExsitingPrototypeList");
RCP<StringValidator> stringVali = rcp(new StringValidator());
RCP<ArrayValidator<StringValidator, std::string> > arrayStringVali
= rcp(new ArrayValidator<StringValidator, std::string>(stringVali));
Array<std::string> strArray = tuple<std::string>("blah", "blah", "blah");
pl.set("string param", "hi", "a string param", stringVali);
pl.set("string array param", strArray,
"a string array parameter", arrayStringVali);
RCP<ParameterList> readInPL = writeThenReadPL(pl);
RCP<const ArrayValidator<StringValidator, std::string> >
inArrayValidator =
rcp_dynamic_cast<const ArrayValidator<StringValidator, std::string> >(
readInPL->getEntry("string array param").validator(), true);
TEST_ASSERT(readInPL->getEntry("string param").validator()
== inArrayValidator->getPrototype());
}
示例4: rcp
TEUCHOS_UNIT_TEST_TEMPLATE_1_DECL(Teuchos_Validator, TwoDArrayNumberValidatorConverterTest, T)
{
std::string arrayParameterName = "array";
ParameterList myList;
const T arrayValidatorLen = as<T>(11);
RCP<TwoDArrayNumberValidator< T > > arrayValidator =
rcp(new TwoDArrayNumberValidator< T >(
rcp(new EnhancedNumberValidator<T>(as<T>(0), arrayValidatorLen))));
myList.set(arrayParameterName,
TwoDArray< T >(4,4, 10), "array parameter", arrayValidator);
RCP<ParameterList> readInPL = writeThenReadPL(myList);
RCP<const EnhancedNumberValidator< T > > readInPrototypeValidator =
rcp_dynamic_cast<const TwoDArrayValidator<EnhancedNumberValidator<T>, T > >(
readInPL->getEntry(
arrayParameterName).validator(), true)->getPrototype();
RCP<const EnhancedNumberValidator< T > > actualPrototypeValidator =
arrayValidator->getPrototype();
TEST_EQUALITY(
readInPrototypeValidator->getMin(),
actualPrototypeValidator->getMin()
);
TEST_EQUALITY(
readInPrototypeValidator->getMax(),
actualPrototypeValidator->getMax()
);
TEST_EQUALITY(
readInPrototypeValidator->getStep(),
actualPrototypeValidator->getStep()
);
TEST_EQUALITY(
readInPrototypeValidator->getPrecision(),
actualPrototypeValidator->getPrecision()
);
TEST_EQUALITY(
readInPrototypeValidator->hasMin(),
actualPrototypeValidator->hasMin()
);
TEST_EQUALITY(
readInPrototypeValidator->hasMax(),
actualPrototypeValidator->hasMax()
);
}
示例5: StringValidator
TEUCHOS_UNIT_TEST(Teuchos_Validator, stringValidatorConverter)
{
std::string defaultParameterName = "default";
std::string nonDefaultParameterName = "non default";
RCP<StringValidator> nonDefaultValidator = rcp(
new StringValidator(tuple<std::string>("value1", "cheese", "kurtis", "is", "awesome")));
ParameterList myList("String Validator List");
myList.set("non default", "kurtis", "parameter for non default validator",
nonDefaultValidator);
RCP<ParameterList> readInPL = writeThenReadPL(myList);
RCP<const StringValidator> readinNonDefault =
rcp_dynamic_cast<const StringValidator>(
readInPL->getEntry(nonDefaultParameterName).validator(), true);
TEST_COMPARE_ARRAYS(*(readinNonDefault->validStringValues()),
*(nonDefaultValidator->validStringValues()));
}