75 TEST_ASSERT(intVali2->getMin() == std::numeric_limits<int>::min());
76 TEST_ASSERT(intVali2->getMax() == std::numeric_limits<int>::max());
78 intList->
set(
"Int Parameter", 5,
"int parameter", intVali);
82 TEST_THROW(intList->
set(
"Double Parameter", 5.0,
"double parameter", intVali),
88 TEST_NOTHROW(validList->set(
"Int Parameter", 4,
"int parameter",
90 #ifdef HAVE_TEUCHOSCORE_CXX11
103 TEST_NOTHROW(userList->validateParametersAndSetDefaults(*validList));
105 TEST_NOTHROW(userList->validateParametersAndSetDefaults(*validList));
106 int readInt = userList->getEntry(
"Int Parameter").getValue<
int>(&readInt);
112 TEST_THROW(userList->validateParameters(*validList),
131 TEST_ASSERT(shortVali2->getMin() == std::numeric_limits<short>::min());
132 TEST_ASSERT(shortVali2->getMax() == std::numeric_limits<short>::max());
134 shortList->set(
"Short Parameter", (
short)5,
"short parameter", shortVali);
135 TEST_NOTHROW(shortList->validateParameters(*shortList));
136 TEST_THROW(shortList->set(
"Short Parameter", (
short)11),
138 TEST_THROW(shortList->set(
"Double Parameter", 5.0,
"double parameter", shortVali),
144 TEST_NOTHROW(validList->set(
"Short Parameter", (
short)4,
"short parameter",
146 #ifdef HAVE_TEUCHOSCORE_CXX11
148 TEST_THROW(userList->validateParameters(*validList),
151 TEST_THROW(userList->validateParameters(*validList),
154 TEST_THROW(userList->validateParameters(*validList),
158 TEST_NOTHROW(userList->set(
"Short Parameter", (
short)4));
159 TEST_NOTHROW(userList->validateParametersAndSetDefaults(*validList));
161 TEST_NOTHROW(userList->validateParametersAndSetDefaults(*validList));
162 short readShort = userList->getEntry(
"Short Parameter").getValue<
short>(&readShort);
168 TEST_THROW(userList->validateParameters(*validList),
191 floatList->set(
"Float Parameter", (
float)5.0,
"float parameter", floatVali);
192 TEST_NOTHROW(floatList->validateParameters(*floatList));
193 TEST_THROW(floatList->set(
"Float Parameter", (
float)11.0),
195 TEST_THROW(floatList->set(
"Int Parameter", 5,
"int parameter", floatVali),
201 TEST_NOTHROW(validList->set(
"Float Parameter", (
float)4.0,
"float parameter",
203 #ifdef HAVE_TEUCHOSCORE_CXX11
205 TEST_THROW(userList->validateParameters(*validList),
208 TEST_THROW(userList->validateParameters(*validList),
211 TEST_THROW(userList->validateParameters(*validList),
215 TEST_NOTHROW(userList->set(
"Float Parameter", (
float)8.0));
216 TEST_NOTHROW(userList->validateParametersAndSetDefaults(*validList));
218 TEST_NOTHROW(userList->validateParametersAndSetDefaults(*validList));
219 float readFloat = userList->getEntry(
"Float Parameter").getValue<
float>(&readFloat);
225 TEST_THROW(userList->validateParameters(*validList),
248 doubleList->set(
"Double Parameter", (
double)5.0,
"double parameter", doubleVali);
249 TEST_NOTHROW(doubleList->validateParameters(*doubleList));
250 TEST_THROW(doubleList->set(
"Double Parameter", (
double)11.0),
252 TEST_THROW(doubleList->set(
"Int Parameter", 5,
"int parameter", doubleVali),
258 TEST_NOTHROW(validList->set(
"Double Parameter", 4.0,
"double parameter",
260 #ifdef HAVE_TEUCHOSCORE_CXX11
261 TEST_NOTHROW(userList->set(
"Double Parameter",
"x4.0"));
262 TEST_THROW(userList->validateParameters(*validList),
264 TEST_NOTHROW(userList->set(
"Double Parameter",
"4.0x"));
265 TEST_THROW(userList->validateParameters(*validList),
267 TEST_NOTHROW(userList->set(
"Double Parameter",
"12.0"));
268 TEST_THROW(userList->validateParameters(*validList),
273 TEST_NOTHROW(userList->validateParametersAndSetDefaults(*validList));
275 TEST_NOTHROW(userList->validateParametersAndSetDefaults(*validList));
276 double readDouble = userList->getEntry(
"Double Parameter").getValue<
double>(&readDouble);
281 TEST_NOTHROW(userList->set(
"Double Parameter",
"20.0"));
282 TEST_THROW(userList->validateParameters(*validList),
322 TEST_NOTHROW(validList->
set(
"intDoubleParameter", 1.1,
"documentation",
323 intDoubleValidator));
325 intDoubleValidator));
326 TEST_NOTHROW(validList->
set(
"intStringParameter",
"1",
"documentation",
327 intStringValidator));
329 intStringValidator));
337 TEST_NOTHROW(validList->
set(
"intStringParameter",
"1.1",
"documentation",
338 intStringValidator));
345 TEST_THROW(validList->
set(
"intDoubleParameter",
"1.1",
"documentation",
349 TEST_THROW(validList->
set(
"intStringParameter", 1.1,
"documentation",
353 TEST_THROW(validList->
set(
"intParameter",
"1",
"documentation",
357 TEST_THROW(validList->
set(
"intParameter", 1.1,
"documentation",
365 #ifdef HAVE_TEUCHOSCORE_CXX11
368 TEST_THROW(validList->
set(
"allParameter",
"1.1x",
"documentation",
370 TEST_THROW(validList->
set(
"intDoubleParameter",
"1.1x",
"documentation",
372 TEST_THROW(validList->
set(
"allParameter",
"x1.1",
"documentation",
374 TEST_THROW(validList->
set(
"intDoubleParameter",
"x1.1",
"documentation",
377 TEST_THROW(validList->
set(
"intStringParameter",
"1x",
"documentation",
379 TEST_THROW(validList->
set(
"intStringParameter",
"x1",
"documentation",
381 TEST_THROW(validList->
set(
"intStringParameter",
"1 x",
"documentation",
390 TEST_NOTHROW(validList->
set(
"intStringParameter",
"1.1x",
"documentation",
391 intStringValidator));
401 validList->
set(
"justBool",
false,
"documentation" );
421 validList->
set(
"boolOrString",
false,
"documentation", boolValidator );
442 validList->
set(
"boolOrString",
"false",
"documentation", boolValidator );
455 TEST_THROW(userList->validateParameters(*validList),
462 validList->
set(
"boolOne",
true,
"doc", boolValidator);
463 validList->
set(
"boolTwo",
false,
"doc", boolValidator);
468 userList->set(
"boolOne",
false);
469 userList->set(
"boolTwo",
"true");
470 TEST_NOTHROW(userList->validateParametersAndSetDefaults(*validList));
490 TEST_NOTHROW(stringList->
set(
"String param1",
"str1",
"a string parameter", stringVali));
491 TEST_THROW(stringList->
set(
"String param2",
"not in list",
"a string parameter", stringVali),
493 TEST_THROW(stringList->
set(
"int param", 5,
"a int parameter", stringVali),
508 TEST_NOTHROW(fileNameList->
set(
"File name param",
"../path",
"file name parameter",
510 TEST_THROW(fileNameList->
set(
"int param", 5,
"int parameter", fileNameVali),
513 TEST_NOTHROW(fileNameList->
set(
"file name param",
"testFile.txt",
"a file name", fileNameVali));
514 TEST_THROW(fileNameList->
set(
"file name param",
"doesntexist.txt",
"a file name", fileNameVali),
533 Array<std::string> stringArray = tuple<std::string>(
"str2",
"str3",
"str1",
"str3",
"str2");
534 TEST_NOTHROW(stringList->
set(
"String Array Param", stringArray,
"string array parameter", stringArrayVali));
535 Array<std::string> badStringArray = tuple<std::string>(
"not valid",
"str3",
"str1",
"str3",
"str2");
536 TEST_THROW(stringList->
set(
"String Array Param", badStringArray,
"string array parameter", stringArrayVali),
538 TEST_THROW(stringList->
set(
"Int param", 5,
"int parameter", stringArrayVali),
540 Array<long> longArray = tuple<long>((long)5,(
long)5,(long)3);
541 TEST_THROW(stringList->
set(
"Long array param", longArray,
"long array parameter", stringArrayVali),
552 TEST_NOTHROW(intList->set(
"int array param", intArray,
"int array parameter", intArrayVali));
553 Array<int> intBadArray = tuple<int>(11,4,2,5);
554 TEST_THROW(intList->set(
"int bad array param", intBadArray,
"int bad array parameter", intArrayVali),
556 TEST_THROW(stringList->
set(
"Long array param", longArray,
"long array parameter", intArrayVali),
569 TEST_NOTHROW(shortList->set(
"short array param", shortArray,
"short array parameter", shortArrayVali));
571 TEST_THROW(shortList->set(
"short bad array param", shortBadArray,
"short bad array parameter", shortArrayVali),
573 TEST_THROW(stringList->
set(
"Long array param", longArray,
"long array parameter", shortArrayVali),
585 Array<float> floatArray = tuple<float>(1.0,4.0,2.0,5.0);
586 TEST_NOTHROW(floatList->set(
"float array param", floatArray,
"float array parameter", floatArrayVali));
587 Array<float> floatBadArray = tuple<float>(11.0,4.0,2.0,5.0);
588 TEST_THROW(floatList->set(
"float bad array param", floatBadArray,
"float bad array parameter", floatArrayVali),
590 TEST_THROW(stringList->
set(
"Long array param", longArray,
"long array parameter", floatArrayVali),
603 TEST_NOTHROW(doubleList->set(
"double array param", doubleArray,
"double array parameter", doubleArrayVali));
604 Array<double> doubleBadArray = tuple<double>(11.0,4.0,2.0,5.0);
605 TEST_THROW(doubleList->set(
"double bad array param", doubleBadArray,
"double bad array parameter", doubleArrayVali),
607 TEST_THROW(stringList->
set(
"Long array param", longArray,
"long array parameter", doubleArrayVali),
617 Array<std::string> fileNameArray = tuple<std::string>(
"testFile.txt",
"testFile2.txt",
"testFile3.txt");
618 Array<std::string> fileNameBadArray = tuple<std::string>(
"doesnexist.txt",
"testFile2.txt",
"testFile3.txt");
619 TEST_NOTHROW(fileNameList->set(
"File name array", fileNameArray,
"file name array parameter", arrayFileNameVali));
620 TEST_THROW(fileNameList->set(
"Bad File name array", fileNameBadArray,
"bad file name array parameter", arrayFileNameVali),
622 TEST_THROW(stringList->
set(
"Long array param", longArray,
"long array parameter", arrayFileNameVali),
642 stringArray(0,0) =
"str2";
643 stringArray(0,1) =
"str1";
644 stringArray(1,0) =
"str3";
645 stringArray(1,1) =
"str2";
646 TEST_NOTHROW(stringList->
set(
"String Array Param", stringArray,
"string array parameter", stringArrayVali));
648 badStringArray(0,0) =
"str2";
649 badStringArray(0,1) =
"str1";
650 badStringArray(1,0) =
"str3";
651 badStringArray(1,1) =
"not valid";
652 TEST_THROW(stringList->
set(
"String Array Param", badStringArray,
"string array parameter", stringArrayVali),
654 TEST_THROW(stringList->
set(
"Int param", 5,
"int parameter", stringArrayVali),
657 longArray(0,0) = (long)5;
658 longArray(0,1) = (long)4;
659 longArray(1,0) = (long)9;
660 longArray(1,1) = (long)1;
661 TEST_THROW(stringList->
set(
"Long array param", longArray,
"long array parameter", stringArrayVali),
677 TEST_NOTHROW(intList->set(
"int array param", intArray,
"int array parameter", intArrayVali));
679 intBadArray(0,0) = 11;
680 intBadArray(0,1) = 4;
681 intBadArray(1,0) = 2;
682 intBadArray(1,1) = 5;
683 TEST_THROW(intList->set(
"int bad array param", intBadArray,
"int bad array parameter", intArrayVali),
685 TEST_THROW(stringList->
set(
"Long array param", longArray,
"long array parameter", intArrayVali),
702 TEST_NOTHROW(shortList->set(
"short array param", shortArray,
"short array parameter", shortArrayVali));
704 shortBadArray(0,0) = 11;
705 shortBadArray(0,1) = 4;
706 shortBadArray(1,0) = 2;
707 shortBadArray(1,1) = 5;
708 TEST_THROW(shortList->set(
"short bad array param", shortBadArray,
"short bad array parameter", shortArrayVali),
710 TEST_THROW(stringList->
set(
"Long array param", longArray,
"long array parameter", shortArrayVali),
723 floatArray(0,0) = 1.0;
724 floatArray(0,1) = 4.0;
725 floatArray(1,0) = 5.0;
726 floatArray(1,1) = 2.0;
727 TEST_NOTHROW(floatList->set(
"float array param", floatArray,
"float array parameter", floatArrayVali));
729 floatBadArray(0,0) = 11.0;
730 floatBadArray(0,1) = 4.0;
731 floatBadArray(1,0) = 5.0;
732 floatBadArray(1,1) = 2.0;
733 TEST_THROW(floatList->set(
"float bad array param", floatBadArray,
"float bad array parameter", floatArrayVali),
735 TEST_THROW(stringList->
set(
"Long array param", longArray,
"long array parameter", floatArrayVali),
748 doubleArray(0,0) = 1.0;
749 doubleArray(0,1) = 4.0;
750 doubleArray(1,0) = 5.0;
751 doubleArray(1,1) = 2.0;
752 TEST_NOTHROW(doubleList->set(
"double array param", doubleArray,
"double array parameter", doubleArrayVali));
754 doubleBadArray(0,0) = 11.0;
755 doubleBadArray(0,1) = 4.0;
756 doubleBadArray(1,0) = 5.0;
757 doubleBadArray(1,1) = 2.0;
758 TEST_THROW(doubleList->set(
"double bad array param", doubleBadArray,
"double bad array parameter", doubleArrayVali),
760 TEST_THROW(stringList->
set(
"Long array param", longArray,
"long array parameter", doubleArrayVali),
772 fileNameArray(0,0) =
"testFile.txt";
773 fileNameArray(0,1) =
"testFile2.txt";
774 fileNameArray(1,0) =
"testFile3.txt";
775 fileNameArray(1,1) =
"testFile.txt";
777 fileNameBadArray(0,0) =
"doesntexist.txt";
778 fileNameBadArray(0,1) =
"testFile2.txt";
779 fileNameBadArray(1,0) =
"testFile3.txt";
780 fileNameBadArray(1,1) =
"testFile.txt";
781 TEST_NOTHROW(fileNameList->set(
"File name array", fileNameArray,
"file name array parameter", arrayFileNameVali));
782 TEST_THROW(fileNameList->set(
"Bad File name array", fileNameBadArray,
"bad file name array parameter", arrayFileNameVali),
784 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.
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.
#define TEST_THROW(code, ExceptType)
Assert that the statement 'code' throws the exception 'ExceptType' (otherwise the test fails)...
AcceptedTypes & allowString(bool _allowString)
Set allow an std::string value or not.
T * get() const
Get the raw C++ pointer to the underlying object.
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.
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.