44 TEST_ASSERT(intVali2->getMin() == std::numeric_limits<int>::min());
45 TEST_ASSERT(intVali2->getMax() == std::numeric_limits<int>::max());
47 intList->
set(
"Int Parameter", 5,
"int parameter", intVali);
51 TEST_THROW(intList->
set(
"Double Parameter", 5.0,
"double parameter", intVali),
57 TEST_NOTHROW(validList->set(
"Int Parameter", 4,
"int parameter",
59 #ifdef HAVE_TEUCHOSCORE_CXX11
72 TEST_NOTHROW(userList->validateParametersAndSetDefaults(*validList));
74 TEST_NOTHROW(userList->validateParametersAndSetDefaults(*validList));
75 int readInt = userList->getEntry(
"Int Parameter").getValue<
int>(&readInt);
81 TEST_THROW(userList->validateParameters(*validList),
100 TEST_ASSERT(shortVali2->getMin() == std::numeric_limits<short>::min());
101 TEST_ASSERT(shortVali2->getMax() == std::numeric_limits<short>::max());
103 shortList->set(
"Short Parameter", (
short)5,
"short parameter", shortVali);
104 TEST_NOTHROW(shortList->validateParameters(*shortList));
105 TEST_THROW(shortList->set(
"Short Parameter", (
short)11),
107 TEST_THROW(shortList->set(
"Double Parameter", 5.0,
"double parameter", shortVali),
113 TEST_NOTHROW(validList->set(
"Short Parameter", (
short)4,
"short parameter",
115 #ifdef HAVE_TEUCHOSCORE_CXX11
117 TEST_THROW(userList->validateParameters(*validList),
120 TEST_THROW(userList->validateParameters(*validList),
123 TEST_THROW(userList->validateParameters(*validList),
127 TEST_NOTHROW(userList->set(
"Short Parameter", (
short)4));
128 TEST_NOTHROW(userList->validateParametersAndSetDefaults(*validList));
130 TEST_NOTHROW(userList->validateParametersAndSetDefaults(*validList));
131 short readShort = userList->getEntry(
"Short Parameter").getValue<
short>(&readShort);
137 TEST_THROW(userList->validateParameters(*validList),
160 floatList->set(
"Float Parameter", (
float)5.0,
"float parameter", floatVali);
161 TEST_NOTHROW(floatList->validateParameters(*floatList));
162 TEST_THROW(floatList->set(
"Float Parameter", (
float)11.0),
164 TEST_THROW(floatList->set(
"Int Parameter", 5,
"int parameter", floatVali),
170 TEST_NOTHROW(validList->set(
"Float Parameter", (
float)4.0,
"float parameter",
172 #ifdef HAVE_TEUCHOSCORE_CXX11
174 TEST_THROW(userList->validateParameters(*validList),
177 TEST_THROW(userList->validateParameters(*validList),
180 TEST_THROW(userList->validateParameters(*validList),
184 TEST_NOTHROW(userList->set(
"Float Parameter", (
float)8.0));
185 TEST_NOTHROW(userList->validateParametersAndSetDefaults(*validList));
187 TEST_NOTHROW(userList->validateParametersAndSetDefaults(*validList));
188 float readFloat = userList->getEntry(
"Float Parameter").getValue<
float>(&readFloat);
194 TEST_THROW(userList->validateParameters(*validList),
217 doubleList->set(
"Double Parameter", (
double)5.0,
"double parameter", doubleVali);
218 TEST_NOTHROW(doubleList->validateParameters(*doubleList));
219 TEST_THROW(doubleList->set(
"Double Parameter", (
double)11.0),
221 TEST_THROW(doubleList->set(
"Int Parameter", 5,
"int parameter", doubleVali),
227 TEST_NOTHROW(validList->set(
"Double Parameter", 4.0,
"double parameter",
229 #ifdef HAVE_TEUCHOSCORE_CXX11
230 TEST_NOTHROW(userList->set(
"Double Parameter",
"x4.0"));
231 TEST_THROW(userList->validateParameters(*validList),
233 TEST_NOTHROW(userList->set(
"Double Parameter",
"4.0x"));
234 TEST_THROW(userList->validateParameters(*validList),
236 TEST_NOTHROW(userList->set(
"Double Parameter",
"12.0"));
237 TEST_THROW(userList->validateParameters(*validList),
242 TEST_NOTHROW(userList->validateParametersAndSetDefaults(*validList));
244 TEST_NOTHROW(userList->validateParametersAndSetDefaults(*validList));
245 double readDouble = userList->getEntry(
"Double Parameter").getValue<
double>(&readDouble);
250 TEST_NOTHROW(userList->set(
"Double Parameter",
"20.0"));
251 TEST_THROW(userList->validateParameters(*validList),
291 TEST_NOTHROW(validList->
set(
"intDoubleParameter", 1.1,
"documentation",
292 intDoubleValidator));
294 intDoubleValidator));
295 TEST_NOTHROW(validList->
set(
"intStringParameter",
"1",
"documentation",
296 intStringValidator));
298 intStringValidator));
306 TEST_NOTHROW(validList->
set(
"intStringParameter",
"1.1",
"documentation",
307 intStringValidator));
314 TEST_THROW(validList->
set(
"intDoubleParameter",
"1.1",
"documentation",
318 TEST_THROW(validList->
set(
"intStringParameter", 1.1,
"documentation",
322 TEST_THROW(validList->
set(
"intParameter",
"1",
"documentation",
326 TEST_THROW(validList->
set(
"intParameter", 1.1,
"documentation",
334 #ifdef HAVE_TEUCHOSCORE_CXX11
337 TEST_THROW(validList->
set(
"allParameter",
"1.1x",
"documentation",
339 TEST_THROW(validList->
set(
"intDoubleParameter",
"1.1x",
"documentation",
341 TEST_THROW(validList->
set(
"allParameter",
"x1.1",
"documentation",
343 TEST_THROW(validList->
set(
"intDoubleParameter",
"x1.1",
"documentation",
346 TEST_THROW(validList->
set(
"intStringParameter",
"1x",
"documentation",
348 TEST_THROW(validList->
set(
"intStringParameter",
"x1",
"documentation",
350 TEST_THROW(validList->
set(
"intStringParameter",
"1 x",
"documentation",
359 TEST_NOTHROW(validList->
set(
"intStringParameter",
"1.1x",
"documentation",
360 intStringValidator));
370 validList->
set(
"justBool",
false,
"documentation" );
390 validList->
set(
"boolOrString",
false,
"documentation", boolValidator );
411 validList->
set(
"boolOrString",
"false",
"documentation", boolValidator );
424 TEST_THROW(userList->validateParameters(*validList),
431 validList->
set(
"boolOne",
true,
"doc", boolValidator);
432 validList->
set(
"boolTwo",
false,
"doc", boolValidator);
437 userList->set(
"boolOne",
false);
438 userList->set(
"boolTwo",
"true");
439 TEST_NOTHROW(userList->validateParametersAndSetDefaults(*validList));
459 TEST_NOTHROW(stringList->
set(
"String param1",
"str1",
"a string parameter", stringVali));
460 TEST_THROW(stringList->
set(
"String param2",
"not in list",
"a string parameter", stringVali),
462 TEST_THROW(stringList->
set(
"int param", 5,
"a int parameter", stringVali),
474 bool caseSensitive =
true;
477 RCP<ret_type> validator1 =
rcp(
new ret_type(strVals,
"str1", caseSensitive));
478 RCP<ret_type> validator2 =
rcp(
new ret_type(strVals, intVals,
"str1", caseSensitive));
479 RCP<ret_type> validator3 =
rcp(
new ret_type(strVals, strDocs, intVals,
"str1", caseSensitive));
482 valid_pl.set(
"Param1",
"str1",
"Parameter 1", validator1);
483 valid_pl.set(
"Param2",
"str1",
"Parameter 2", validator2);
484 valid_pl.set(
"Param3",
"str1",
"Parameter 3", validator3);
486 user_pl.
set(
"Param1",
"str1");
487 user_pl.
set(
"Param2",
"str2");
488 user_pl.
set(
"Param3",
"str3");
491 TEST_EQUALITY(intVals[0], getIntegralValue<int>(valid_pl,
"Param2"));
492 TEST_EQUALITY(strVals[0], getStringValue<int>(valid_pl,
"Param2"));
496 TEST_EQUALITY(intVals[1], getIntegralValue<int>(user_pl,
"Param2"));
497 TEST_EQUALITY(intVals[2], getIntegralValue<int>(user_pl,
"Param3"));
498 TEST_EQUALITY(strVals[0], getStringValue<int>(user_pl,
"Param1"));
499 TEST_EQUALITY(strVals[1], getStringValue<int>(user_pl,
"Param2"));
500 TEST_EQUALITY(strVals[2], getStringValue<int>(user_pl,
"Param3"));
514 TEST_NOTHROW(fileNameList->
set(
"File name param",
"../path",
"file name parameter",
516 TEST_THROW(fileNameList->
set(
"int param", 5,
"int parameter", fileNameVali),
519 TEST_NOTHROW(fileNameList->
set(
"file name param",
"testFile.txt",
"a file name", fileNameVali));
520 TEST_THROW(fileNameList->
set(
"file name param",
"doesntexist.txt",
"a file name", fileNameVali),
539 Array<std::string> stringArray = tuple<std::string>(
"str2",
"str3",
"str1",
"str3",
"str2");
540 TEST_NOTHROW(stringList->
set(
"String Array Param", stringArray,
"string array parameter", stringArrayVali));
541 Array<std::string> badStringArray = tuple<std::string>(
"not valid",
"str3",
"str1",
"str3",
"str2");
542 TEST_THROW(stringList->
set(
"String Array Param", badStringArray,
"string array parameter", stringArrayVali),
544 TEST_THROW(stringList->
set(
"Int param", 5,
"int parameter", stringArrayVali),
546 Array<long> longArray = tuple<long>((long)5,(
long)5,(long)3);
547 TEST_THROW(stringList->
set(
"Long array param", longArray,
"long array parameter", stringArrayVali),
558 TEST_NOTHROW(intList->set(
"int array param", intArray,
"int array parameter", intArrayVali));
559 Array<int> intBadArray = tuple<int>(11,4,2,5);
560 TEST_THROW(intList->set(
"int bad array param", intBadArray,
"int bad array parameter", intArrayVali),
562 TEST_THROW(stringList->
set(
"Long array param", longArray,
"long array parameter", intArrayVali),
575 TEST_NOTHROW(shortList->set(
"short array param", shortArray,
"short array parameter", shortArrayVali));
577 TEST_THROW(shortList->set(
"short bad array param", shortBadArray,
"short bad array parameter", shortArrayVali),
579 TEST_THROW(stringList->
set(
"Long array param", longArray,
"long array parameter", shortArrayVali),
591 Array<float> floatArray = tuple<float>(1.0,4.0,2.0,5.0);
592 TEST_NOTHROW(floatList->set(
"float array param", floatArray,
"float array parameter", floatArrayVali));
593 Array<float> floatBadArray = tuple<float>(11.0,4.0,2.0,5.0);
594 TEST_THROW(floatList->set(
"float bad array param", floatBadArray,
"float bad array parameter", floatArrayVali),
596 TEST_THROW(stringList->
set(
"Long array param", longArray,
"long array parameter", floatArrayVali),
609 TEST_NOTHROW(doubleList->set(
"double array param", doubleArray,
"double array parameter", doubleArrayVali));
610 Array<double> doubleBadArray = tuple<double>(11.0,4.0,2.0,5.0);
611 TEST_THROW(doubleList->set(
"double bad array param", doubleBadArray,
"double bad array parameter", doubleArrayVali),
613 TEST_THROW(stringList->
set(
"Long array param", longArray,
"long array parameter", doubleArrayVali),
623 Array<std::string> fileNameArray = tuple<std::string>(
"testFile.txt",
"testFile2.txt",
"testFile3.txt");
624 Array<std::string> fileNameBadArray = tuple<std::string>(
"doesnexist.txt",
"testFile2.txt",
"testFile3.txt");
625 TEST_NOTHROW(fileNameList->set(
"File name array", fileNameArray,
"file name array parameter", arrayFileNameVali));
626 TEST_THROW(fileNameList->set(
"Bad File name array", fileNameBadArray,
"bad file name array parameter", arrayFileNameVali),
628 TEST_THROW(stringList->
set(
"Long array param", longArray,
"long array parameter", arrayFileNameVali),
648 stringArray(0,0) =
"str2";
649 stringArray(0,1) =
"str1";
650 stringArray(1,0) =
"str3";
651 stringArray(1,1) =
"str2";
652 TEST_NOTHROW(stringList->
set(
"String Array Param", stringArray,
"string array parameter", stringArrayVali));
654 badStringArray(0,0) =
"str2";
655 badStringArray(0,1) =
"str1";
656 badStringArray(1,0) =
"str3";
657 badStringArray(1,1) =
"not valid";
658 TEST_THROW(stringList->
set(
"String Array Param", badStringArray,
"string array parameter", stringArrayVali),
660 TEST_THROW(stringList->
set(
"Int param", 5,
"int parameter", stringArrayVali),
663 longArray(0,0) = (long)5;
664 longArray(0,1) = (long)4;
665 longArray(1,0) = (long)9;
666 longArray(1,1) = (long)1;
667 TEST_THROW(stringList->
set(
"Long array param", longArray,
"long array parameter", stringArrayVali),
683 TEST_NOTHROW(intList->set(
"int array param", intArray,
"int array parameter", intArrayVali));
685 intBadArray(0,0) = 11;
686 intBadArray(0,1) = 4;
687 intBadArray(1,0) = 2;
688 intBadArray(1,1) = 5;
689 TEST_THROW(intList->set(
"int bad array param", intBadArray,
"int bad array parameter", intArrayVali),
691 TEST_THROW(stringList->
set(
"Long array param", longArray,
"long array parameter", intArrayVali),
708 TEST_NOTHROW(shortList->set(
"short array param", shortArray,
"short array parameter", shortArrayVali));
710 shortBadArray(0,0) = 11;
711 shortBadArray(0,1) = 4;
712 shortBadArray(1,0) = 2;
713 shortBadArray(1,1) = 5;
714 TEST_THROW(shortList->set(
"short bad array param", shortBadArray,
"short bad array parameter", shortArrayVali),
716 TEST_THROW(stringList->
set(
"Long array param", longArray,
"long array parameter", shortArrayVali),
729 floatArray(0,0) = 1.0;
730 floatArray(0,1) = 4.0;
731 floatArray(1,0) = 5.0;
732 floatArray(1,1) = 2.0;
733 TEST_NOTHROW(floatList->set(
"float array param", floatArray,
"float array parameter", floatArrayVali));
735 floatBadArray(0,0) = 11.0;
736 floatBadArray(0,1) = 4.0;
737 floatBadArray(1,0) = 5.0;
738 floatBadArray(1,1) = 2.0;
739 TEST_THROW(floatList->set(
"float bad array param", floatBadArray,
"float bad array parameter", floatArrayVali),
741 TEST_THROW(stringList->
set(
"Long array param", longArray,
"long array parameter", floatArrayVali),
754 doubleArray(0,0) = 1.0;
755 doubleArray(0,1) = 4.0;
756 doubleArray(1,0) = 5.0;
757 doubleArray(1,1) = 2.0;
758 TEST_NOTHROW(doubleList->set(
"double array param", doubleArray,
"double array parameter", doubleArrayVali));
760 doubleBadArray(0,0) = 11.0;
761 doubleBadArray(0,1) = 4.0;
762 doubleBadArray(1,0) = 5.0;
763 doubleBadArray(1,1) = 2.0;
764 TEST_THROW(doubleList->set(
"double bad array param", doubleBadArray,
"double bad array parameter", doubleArrayVali),
766 TEST_THROW(stringList->
set(
"Long array param", longArray,
"long array parameter", doubleArrayVali),
778 fileNameArray(0,0) =
"testFile.txt";
779 fileNameArray(0,1) =
"testFile2.txt";
780 fileNameArray(1,0) =
"testFile3.txt";
781 fileNameArray(1,1) =
"testFile.txt";
783 fileNameBadArray(0,0) =
"doesntexist.txt";
784 fileNameBadArray(0,1) =
"testFile2.txt";
785 fileNameBadArray(1,0) =
"testFile3.txt";
786 fileNameBadArray(1,1) =
"testFile.txt";
787 TEST_NOTHROW(fileNameList->set(
"File name array", fileNameArray,
"file name array parameter", arrayFileNameVali));
788 TEST_THROW(fileNameList->set(
"Bad File name array", fileNameBadArray,
"bad file name array parameter", arrayFileNameVali),
790 TEST_THROW(stringList->
set(
"Long array param", longArray,
"long array parameter", arrayFileNameVali),
#define TEST_ASSERT(v1)
Assert the given statement is true.
Convience class for StringValidators that are to be applied to TwoDArrays.
bool setFileMustExist(bool shouldFileExist)
Sets whether or not the validator requires the file to already exist.
Convience class for EnhancedNumberValidators that are to be applied to arrays.
#define TEST_NOTHROW(code)
Asserr that the statement 'code' does not thrown any excpetions.
#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)...
Standard implementation of a ParameterEntryValidator that maps from a list of strings to an enum or i...
AcceptedTypes & allowString(bool _allowString)
Set allow an std::string value or not.
T * get() const
Get the raw C++ pointer to the underlying object.
ParameterList & set(std::string const &name, T &&value, std::string const &docString="", RCP< const ParameterEntryValidator > const &validator=null)
Templated set method.
T & getValue(T *ptr) const
Templated get method that uses the input pointer type to determine the type of parameter to return...
Determines the types that are accepted.
TEUCHOS_UNIT_TEST(ConstNonconstObjectContainer, create)
A thin wrapper around the Array class which causes it to be interpreted as a 2D Array.
RCP< const ValidatorType > getPrototype() const
Returns the prototype validator for this Array Validator.
Convience class for StringValidators that are to be applied to arrays.
TEUCHOS_DEPRECATED RCP< T > rcp(T *p, Dealloc_T dealloc, bool owns_mem)
Deprecated.
Templated Parameter List class.
static unsigned short defaultPrecision()
Gets the default precision with which the number type should be displayed.
Convience class for EnhancedNumberValidators that are to be applied to TwoDArray. ...
Standard implementation of a BoolParameterEntryValidator that accepts bool values (true/false) or str...
Convience class for FileNameValidators that are to be applied to TwoDArrays.
void validateParametersAndSetDefaults(ParameterList const &validParamList, int const depth=1000)
Validate the parameters in this list given valid selections in the input list and set defaults for th...
Validate a file name entry.
A list of parameters of arbitrary type.
void validateParameters(ParameterList const &validParamList, int const depth=1000, EValidateUsed const validateUsed=VALIDATE_USED_ENABLED, EValidateDefaults const validateDefaults=VALIDATE_DEFAULTS_ENABLED) const
Validate the parameters in this list given valid selections in the input list.
A simple validator that only allows certain string values to be choosen or simply enforces that a par...
static T min()
Gets the minimum possible value the number type can take on.
#define TEST_COMPARE_ARRAYS(a1, a2)
Assert that a1.size()==a2.size() and a[i]==b[i], i=0....
static T defaultStep()
gets default amount a value of the number type should be incremented by when being utilizied in a UI...
static T max()
Gets the maximum possible value the number type can take on.
Class uesd to validate a particular type of number.
Convience class for FileNameValidators that are to be applied to arrays.
AcceptedTypes & allowDouble(bool _allowDouble)
Set allow a double value or not.
Smart reference counting pointer class for automatic garbage collection.
bool fileMustExist() const
Gets the variable describing whether or not this validator wants the file that is specified to alread...
Standard implementation of a ParameterEntryValidator that accepts numbers from a number of different ...
ParameterEntry & getEntry(const std::string &name)
Retrieves an entry with the name name.