Teuchos Package Browser (Single Doxygen Collection)  Version of the Day
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Validator_SerializationTest.cpp
Go to the documentation of this file.
1 // @HEADER
2 // ***********************************************************************
3 //
4 // Teuchos: Common Tools Package
5 // Copyright (2004) Sandia Corporation
6 //
7 // Under terms of Contract DE-AC04-94AL85000, there is a non-exclusive
8 // license for use of this work by or on behalf of the U.S. Government.
9 //
10 // Redistribution and use in source and binary forms, with or without
11 // modification, are permitted provided that the following conditions are
12 // met:
13 //
14 // 1. Redistributions of source code must retain the above copyright
15 // notice, this list of conditions and the following disclaimer.
16 //
17 // 2. Redistributions in binary form must reproduce the above copyright
18 // notice, this list of conditions and the following disclaimer in the
19 // documentation and/or other materials provided with the distribution.
20 //
21 // 3. Neither the name of the Corporation nor the names of the
22 // contributors may be used to endorse or promote products derived from
23 // this software without specific prior written permission.
24 //
25 // THIS SOFTWARE IS PROVIDED BY SANDIA CORPORATION "AS IS" AND ANY
26 // EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
27 // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
28 // PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL SANDIA CORPORATION OR THE
29 // CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
30 // EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
31 // PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
32 // PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
33 // LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
34 // NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
35 // SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
36 //
37 // Questions? Contact Michael A. Heroux (maherou@sandia.gov)
38 //
39 // ***********************************************************************
40 // @HEADER
50 
52 
54 
55 
56 namespace Teuchos {
57 
59 {
60 
61  public:
62 
63  void printDoc(const std::string& docString, std::ostream& out) const {}
64 
66  return rcp(new Array<std::string>(1,""));
67  }
68 
69  void validate(
70  ParameterEntry const& entry,
71  std::string const& paramName,
72  std::string const& sublistName
73  ) const {}
74 
75  const std::string getXMLTypeName() const{
76  return "UNDEFINEDTYPE";
77  }
78 
79 };
80 
81 TEUCHOS_UNIT_TEST(Teuchos_Validator, exceptionTests)
82 {
84  out << std::endl;
85 
88 
90  missingValidatorList = getParametersFromXmlFile("MissingValidator.xml"),
92 
94  missingPrototypeList = getParametersFromXmlFile("MissingPrototypeValidator.xml"),
96 
98  conflicitingValiIdsList = getParametersFromXmlFile("ConflictingValidatorIDs.xml"),
100 
102  stringValidatorBadTagList = getParametersFromXmlFile("StringValidatorBadTag.xml"),
104 
106  stringValidatorBadTagList = getParametersFromXmlFile("StringToIntegralValidatorBadTag.xml"),
108 
109  #ifdef HAVE_TEUCHOS_DEBUG
110 
111  StringValidatorXMLConverter stringConverter;
112  AnyNumberValidatorXMLConverter anyNumberConverter;
113  ValidatortoIDMap writerDummyMap;
114  IDtoValidatorMap readerDummyMap;
115  RCP<AnyNumberParameterEntryValidator> anyNumberValidator =
116  anyNumberParameterEntryValidator();
117  writerDummyMap.insert(anyNumberValidator);
118  TEST_THROW(
119  stringConverter.fromValidatortoXML(anyNumberValidator, writerDummyMap),
121  XMLObject anyNumberXML =
122  anyNumberConverter.fromValidatortoXML(anyNumberValidator, writerDummyMap);
123  TEST_THROW(
124  stringConverter.fromXMLtoValidator(anyNumberXML, readerDummyMap),
126 
127  #endif
128 
129 }
130 
131 TEUCHOS_UNIT_TEST(Teuchos_Validator, fileNameValidatorConverter)
132 {
133  std::string defaultParameterName = "default";
134  std::string nonDefaultParameterName = "non default";
135 
136  RCP<FileNameValidator> defaultValidator =
137  rcp(new FileNameValidator);
138  RCP<FileNameValidator> nonDefaultValidator =
139  rcp(new FileNameValidator(true));
140  ParameterList myList("FileName Validator List");
141  myList.set("default", "", "parameter for default validator",
142  defaultValidator);
143  myList.set("non default", "blah.txt", "parameter for non default validator",
144  nonDefaultValidator);
145 
146  RCP<ParameterList> readInPL = writeThenReadPL(myList);
147 
148  RCP<const FileNameValidator> readinDefault =
149  rcp_dynamic_cast<const FileNameValidator>(
150  readInPL->getEntry(defaultParameterName).validator(), true);
151  TEST_EQUALITY(readinDefault->fileMustExist(), defaultValidator->fileMustExist());
152 
153  RCP<const FileNameValidator> readinNonDefault =
154  rcp_dynamic_cast<const FileNameValidator>(
155  readInPL->getEntry(nonDefaultParameterName).validator(), true);
156  TEST_EQUALITY(readinNonDefault->fileMustExist(), nonDefaultValidator->fileMustExist());
157 }
158 
159 
160 TEUCHOS_UNIT_TEST(Teuchos_Validator, stringValidatorConverter)
161 {
162  std::string defaultParameterName = "default";
163  std::string nonDefaultParameterName = "non default";
164 
165  RCP<StringValidator> nonDefaultValidator = rcp(
166  new StringValidator(tuple<std::string>("value1", "cheese", "kurtis", "is", "awesome")));
167  ParameterList myList("String Validator List");
168  myList.set("non default", "kurtis", "parameter for non default validator",
169  nonDefaultValidator);
170 
171  RCP<ParameterList> readInPL = writeThenReadPL(myList);
172 
173  RCP<const StringValidator> readinNonDefault =
174  rcp_dynamic_cast<const StringValidator>(
175  readInPL->getEntry(nonDefaultParameterName).validator(), true);
176  TEST_COMPARE_ARRAYS(*(readinNonDefault->validStringValues()),
177  *(nonDefaultValidator->validStringValues()));
178 }
179 
180 
181 TEUCHOS_UNIT_TEST(Teuchos_Validator, boolValidatorConverter)
182 {
183  std::string xmlFileName = "BoolValidatorList.xml";
184  std::string boolParameterName = "boolParameterName";
185  RCP<BoolParameterEntryValidator> boolValidator =
187 
188  ParameterList myList("BoolValidatorList");
189  myList.set(boolParameterName, false,
190  "A parameter with a BoolParameterEntryValidator validator.",
191  boolValidator);
192 
193  RCP<ParameterList> readInPL = writeThenReadPL(myList);
194 
195  RCP<const BoolParameterEntryValidator> readInBoolValidator =
196  rcp_dynamic_cast<const BoolParameterEntryValidator>(
197  readInPL->getEntry(boolParameterName).validator(), true);
198 
199  // to do - check any stuff we want to check
200  // right now it doesn't have any settings
201 }
202 
203 TEUCHOS_UNIT_TEST(Teuchos_Validator, anynumberValidatorConverter)
204 {
205  std::string xmlFileName = "AnyNumberValidatorList.xml";
206  std::string defaultParameterName = "default";
207  std::string nonDefaultParameterName = "preferred and accepted";
208  RCP<AnyNumberParameterEntryValidator> defaultValidator =
211  acceptedTypes.allowDouble(false);
212  RCP<AnyNumberParameterEntryValidator> nonDefaultValidator =
213  rcp(
216  acceptedTypes
217  )
218  );
219 
220  ParameterList myList("AnyNumberValidatorList");
221  myList.set(defaultParameterName, 10.0,
222  "A parameter with the default AnyNumberValidator on it", defaultValidator);
223  myList.set(nonDefaultParameterName, 1,
224  "A prameter with an AnyNumberValidator on it that has the preferred and accepted types differnet from the default",
225  nonDefaultValidator);
226 
227  RCP<ParameterList> readInPL = writeThenReadPL(myList);
228 
229  RCP<const AnyNumberParameterEntryValidator> readinDefaultValidator =
230  rcp_dynamic_cast<const AnyNumberParameterEntryValidator>(
231  readInPL->getEntry(defaultParameterName).validator(), true);
232  TEST_EQUALITY(readinDefaultValidator->isDoubleAllowed(),
233  defaultValidator->isDoubleAllowed());
234  TEST_EQUALITY(readinDefaultValidator->isIntAllowed(),
235  defaultValidator->isIntAllowed());
236  TEST_EQUALITY(readinDefaultValidator->isStringAllowed(),
237  defaultValidator->isStringAllowed());
238  TEST_EQUALITY(readinDefaultValidator->getPreferredType(),
239  defaultValidator->getPreferredType());
240 
241  RCP<const AnyNumberParameterEntryValidator> readinNonDefaultValidator =
242  rcp_dynamic_cast<const AnyNumberParameterEntryValidator>(
243  readInPL->getEntry(nonDefaultParameterName).validator(), true);
244  TEST_EQUALITY(readinNonDefaultValidator->isDoubleAllowed(),
245  nonDefaultValidator->isDoubleAllowed());
246  TEST_EQUALITY(readinNonDefaultValidator->isIntAllowed(),
247  nonDefaultValidator->isIntAllowed());
248  TEST_EQUALITY(readinNonDefaultValidator->isStringAllowed(),
249  nonDefaultValidator->isStringAllowed());
250  TEST_EQUALITY(readinNonDefaultValidator->getPreferredType(),
251  nonDefaultValidator->getPreferredType());
252 }
253 
254 TEUCHOS_UNIT_TEST_TEMPLATE_1_DECL(Teuchos_Validator, EnhancedNumberValidatorConverter, T)
255 {
256  std::string xmlFileName = TypeNameTraits<T>::name() + "EnhancedValidatorList.xml";
257  std::string defaultParameterName = "default";
258  std::string minmaxParameterName = "min max";
259  std::string stepPrecParameterName = "step and prec";
260  ParameterList myList;
261  RCP<EnhancedNumberValidator< T > > defaultValidator =
263  RCP<EnhancedNumberValidator< T > > minMaxValidator =
264  rcp( new EnhancedNumberValidator< T >(0,10));
265  RCP<EnhancedNumberValidator< T > > stepAndPrecValidator =
266  rcp( new EnhancedNumberValidator< T >(0,10,4,4));
267  myList.set(defaultParameterName, ( T )6, "parameter with default validator",
268  defaultValidator);
269  myList.set(minmaxParameterName, ( T )10, "parameter with min and max validator",
270  minMaxValidator);
271  myList.set(stepPrecParameterName, ( T )10, "parameter with min, max, "
272  "step, and prec validator",
273  stepAndPrecValidator);
274 
275  RCP<ParameterList> readInPL = writeThenReadPL(myList);
276 
278  rcp_dynamic_cast<const EnhancedNumberValidator< T > >(
279  readInPL->getEntry(defaultParameterName).validator(), true)->getMin(),
280  rcp_dynamic_cast<const EnhancedNumberValidator< T > >(
281  myList.getEntry(defaultParameterName).validator(), true)->getMin()
282  );
284  rcp_dynamic_cast<const EnhancedNumberValidator< T > >(
285  readInPL->getEntry(defaultParameterName).validator(), true)->getMax(),
286  rcp_dynamic_cast<const EnhancedNumberValidator< T > >(
287  myList.getEntry(defaultParameterName).validator(), true)->getMax()
288  );
290  rcp_dynamic_cast<const EnhancedNumberValidator< T > >(
291  readInPL->getEntry(defaultParameterName).validator(), true)->getStep()
292  ,
293  rcp_dynamic_cast<const EnhancedNumberValidator< T > >(
294  myList.getEntry(defaultParameterName).validator(), true)->getStep()
295  );
297  rcp_dynamic_cast<const EnhancedNumberValidator< T > >(
298  readInPL->getEntry(
299  defaultParameterName).validator(), true)->getPrecision(),
300  rcp_dynamic_cast<const EnhancedNumberValidator< T > >(
301  myList.getEntry(
302  defaultParameterName).validator(), true)->getPrecision()
303  );
305  rcp_dynamic_cast<const EnhancedNumberValidator< T > >(
306  readInPL->getEntry(defaultParameterName).validator(), true)->hasMin(),
307  rcp_dynamic_cast<const EnhancedNumberValidator< T > >(
308  myList.getEntry(defaultParameterName).validator(), true)->hasMin()
309  );
311  rcp_dynamic_cast<const EnhancedNumberValidator< T > >(
312  readInPL->getEntry(defaultParameterName).validator(), true)->hasMax(),
313  rcp_dynamic_cast<const EnhancedNumberValidator< T > >(
314  myList.getEntry(defaultParameterName).validator(), true)->hasMax()
315  );
316 
318  rcp_dynamic_cast<const EnhancedNumberValidator< T > >(
319  readInPL->getEntry(minmaxParameterName).validator(), true)->getMin(),
320  rcp_dynamic_cast<const EnhancedNumberValidator< T > >(
321  myList.getEntry(minmaxParameterName).validator(), true)->getMin()
322  );
324  rcp_dynamic_cast<const EnhancedNumberValidator< T > >(
325  readInPL->getEntry(minmaxParameterName).validator(), true)->getMax(),
326  rcp_dynamic_cast<const EnhancedNumberValidator< T > >(
327  myList.getEntry(minmaxParameterName).validator(), true)->getMax()
328  );
330  rcp_dynamic_cast<const EnhancedNumberValidator< T > >(
331  readInPL->getEntry(minmaxParameterName).validator(), true)->getStep(),
332  rcp_dynamic_cast<const EnhancedNumberValidator< T > >(
333  myList.getEntry(minmaxParameterName).validator(), true)->getStep()
334  );
336  rcp_dynamic_cast<const EnhancedNumberValidator< T > >(
337  readInPL->getEntry(
338  minmaxParameterName).validator(), true)->getPrecision(),
339  rcp_dynamic_cast<const EnhancedNumberValidator< T > >(
340  myList.getEntry(
341  minmaxParameterName).validator(), true)->getPrecision()
342  );
344  rcp_dynamic_cast<const EnhancedNumberValidator< T > >(
345  readInPL->getEntry(minmaxParameterName).validator(), true)->hasMin(),
346  rcp_dynamic_cast<const EnhancedNumberValidator< T > >(
347  myList.getEntry(minmaxParameterName).validator(), true)->hasMin()
348  );
350  rcp_dynamic_cast<const EnhancedNumberValidator< T > >(
351  readInPL->getEntry(minmaxParameterName).validator(), true)->hasMax(),
352  rcp_dynamic_cast<const EnhancedNumberValidator< T > >(
353  myList.getEntry(minmaxParameterName).validator(), true)->hasMax()
354  );
355 
357  rcp_dynamic_cast<const EnhancedNumberValidator< T > >(
358  readInPL->getEntry(stepPrecParameterName).validator(), true)->getMin(),
359  rcp_dynamic_cast<const EnhancedNumberValidator< T > >(
360  myList.getEntry(stepPrecParameterName).validator(), true)->getMin()
361  );
363  rcp_dynamic_cast<const EnhancedNumberValidator< T > >(
364  readInPL->getEntry(stepPrecParameterName).validator(), true)->getMax(),
365  rcp_dynamic_cast<const EnhancedNumberValidator< T > >(
366  myList.getEntry(stepPrecParameterName).validator(), true)->getMax()
367  );
369  rcp_dynamic_cast<const EnhancedNumberValidator< T > >(
370  readInPL->getEntry(stepPrecParameterName).validator(), true)->getStep()
371  ,
372  rcp_dynamic_cast<const EnhancedNumberValidator< T > >(
373  myList.getEntry(stepPrecParameterName).validator(), true)->getStep()
374  );
376  rcp_dynamic_cast<const EnhancedNumberValidator< T > >(
377  readInPL->getEntry(
378  stepPrecParameterName).validator(), true)->getPrecision(),
379  rcp_dynamic_cast<const EnhancedNumberValidator< T > >(
380  myList.getEntry(
381  stepPrecParameterName).validator(), true)->getPrecision());
382 
383 }
384 
385 
386 TEUCHOS_UNIT_TEST_TEMPLATE_1_DECL(Teuchos_Validator, NumberArrayValidatorConverterTest, T)
387 {
388  std::string arrayParameterName = "array";
389  ParameterList myList;
390 
391  const T arrayValidatorLen = as<T>(11);
392  RCP<ArrayNumberValidator< T > > arrayValidator =
394  rcp(new EnhancedNumberValidator<T>(as<T>(0), arrayValidatorLen))));
395  myList.set(arrayParameterName,
396  Array< T >(4, 10), "array parameter", arrayValidator);
397 
398  RCP<ParameterList> readInPL = writeThenReadPL(myList);
399 
400  RCP<const EnhancedNumberValidator< T > > readInPrototypeValidator =
401  rcp_dynamic_cast<const ArrayValidator<EnhancedNumberValidator<T>, T > >(
402  readInPL->getEntry(
403  arrayParameterName).validator(), true)->getPrototype();
404  RCP<const EnhancedNumberValidator< T > > actualPrototypeValidator =
405  arrayValidator->getPrototype();
406 
408  readInPrototypeValidator->getMin(),
409  actualPrototypeValidator->getMin()
410  );
412  readInPrototypeValidator->getMax(),
413  actualPrototypeValidator->getMax()
414  );
416  readInPrototypeValidator->getStep(),
417  actualPrototypeValidator->getStep()
418  );
420  readInPrototypeValidator->getPrecision(),
421  actualPrototypeValidator->getPrecision()
422  );
424  readInPrototypeValidator->hasMin(),
425  actualPrototypeValidator->hasMin()
426  );
428  readInPrototypeValidator->hasMax(),
429  actualPrototypeValidator->hasMax()
430  );
431 }
432 
433 TEUCHOS_UNIT_TEST_TEMPLATE_1_DECL(Teuchos_Validator, TwoDArrayNumberValidatorConverterTest, T)
434 {
435  std::string arrayParameterName = "array";
436  ParameterList myList;
437 
438  const T arrayValidatorLen = as<T>(11);
439  RCP<TwoDArrayNumberValidator< T > > arrayValidator =
441  rcp(new EnhancedNumberValidator<T>(as<T>(0), arrayValidatorLen))));
442  myList.set(arrayParameterName,
443  TwoDArray< T >(4,4, 10), "array parameter", arrayValidator);
444 
445  RCP<ParameterList> readInPL = writeThenReadPL(myList);
446 
447  RCP<const EnhancedNumberValidator< T > > readInPrototypeValidator =
448  rcp_dynamic_cast<const TwoDArrayValidator<EnhancedNumberValidator<T>, T > >(
449  readInPL->getEntry(
450  arrayParameterName).validator(), true)->getPrototype();
451  RCP<const EnhancedNumberValidator< T > > actualPrototypeValidator =
452  arrayValidator->getPrototype();
453 
455  readInPrototypeValidator->getMin(),
456  actualPrototypeValidator->getMin()
457  );
459  readInPrototypeValidator->getMax(),
460  actualPrototypeValidator->getMax()
461  );
463  readInPrototypeValidator->getStep(),
464  actualPrototypeValidator->getStep()
465  );
467  readInPrototypeValidator->getPrecision(),
468  actualPrototypeValidator->getPrecision()
469  );
471  readInPrototypeValidator->hasMin(),
472  actualPrototypeValidator->hasMin()
473  );
475  readInPrototypeValidator->hasMax(),
476  actualPrototypeValidator->hasMax()
477  );
478 }
479 
480 
481 TEUCHOS_UNIT_TEST_TEMPLATE_1_DECL(Teuchos_Validator, StringToIntegralConverterTest, T)
482 {
483  std::string defaultStringToIntegralParameterName = "defaultsti";
484  std::string stringToIntegralParameterName = "sti";
485  ParameterList myList;
488  tuple<std::string>("value1", "value2", "value3"), stringToIntegralParameterName));
491  tuple<std::string>("value3", "value4", "value5"),
492  tuple<std::string>("the third value", "the fourth value", "the fifth value"),
493  tuple< T >(3,4,5),
494  stringToIntegralParameterName));
495  myList.set(defaultStringToIntegralParameterName,
496  "value1", "parameter with default sti validator", defaultStiValidator);
497  myList.set(stringToIntegralParameterName, "value3", "parameter with sti validator",
498  stiValidator);
499 
500  RCP<ParameterList> readInPL = writeThenReadPL(myList);
501 
502 
504  readInDefaultStiValidator =
505  rcp_dynamic_cast<const StringToIntegralParameterEntryValidator< T > >(
506  readInPL->getEntry(
507  defaultStringToIntegralParameterName).validator(), true);
509  readInStiValidator =
510  rcp_dynamic_cast<const StringToIntegralParameterEntryValidator< T > >(
511  readInPL->getEntry(
512  stringToIntegralParameterName).validator(), true);
513 
514  Array<std::string> readInDefaultValidStrings =
515  *(readInDefaultStiValidator->validStringValues());
516  Array<std::string> defaultValidStrings =
517  *(defaultStiValidator->validStringValues());
518  TEST_COMPARE_ARRAYS(readInDefaultValidStrings, defaultValidStrings);
519 
520  TEST_ASSERT(readInDefaultStiValidator->getStringDocs().is_null());
521  TEST_EQUALITY( readInDefaultStiValidator->getDefaultParameterName(),
522  defaultStiValidator->getDefaultParameterName());
523  for(int i=0; i<defaultValidStrings.size(); ++i){
524  TEST_EQUALITY(defaultStiValidator->getIntegralValue(defaultValidStrings[i]),
525  readInDefaultStiValidator->getIntegralValue(defaultValidStrings[i]));
526  }
527 
528  Array<std::string> readInValidStrings = *(readInStiValidator->validStringValues());
529  Array<std::string> validStrings = *(stiValidator->validStringValues());
530  TEST_COMPARE_ARRAYS(readInValidStrings, validStrings);
531 
532  TEST_COMPARE_ARRAYS(*(readInStiValidator->getStringDocs()),
533  *(stiValidator->getStringDocs()));
534  TEST_EQUALITY( readInStiValidator->getDefaultParameterName(),
535  stiValidator->getDefaultParameterName());
536  for(int i=0; i<validStrings.size(); ++i){
537  TEST_EQUALITY(stiValidator->getIntegralValue(validStrings[i]),
538  readInStiValidator->getIntegralValue(validStrings[i]));
539  }
540 
541 }
542 
543 TEUCHOS_UNIT_TEST(Teuchos_Validator, existingPrototypeTest){
544  ParameterList pl("ExsitingPrototypeList");
545  RCP<StringValidator> stringVali = rcp(new StringValidator());
548  Array<std::string> strArray = tuple<std::string>("blah", "blah", "blah");
549  pl.set("string param", "hi", "a string param", stringVali);
550  pl.set("string array param", strArray,
551  "a string array parameter", arrayStringVali);
552  RCP<ParameterList> readInPL = writeThenReadPL(pl);
554  inArrayValidator =
555  rcp_dynamic_cast<const ArrayValidator<StringValidator, std::string> >(
556  readInPL->getEntry("string array param").validator(), true);
557  TEST_ASSERT(readInPL->getEntry("string param").validator()
558  == inArrayValidator->getPrototype());
559 }
560 
561 
562 #define FULL_NUMBER_TYPE_TEST( T ) \
563 TEUCHOS_UNIT_TEST_TEMPLATE_1_INSTANT(Teuchos_Validator, EnhancedNumberValidatorConverter, T ) \
564 TEUCHOS_UNIT_TEST_TEMPLATE_1_INSTANT(Teuchos_Validator, NumberArrayValidatorConverterTest, T ) \
565 TEUCHOS_UNIT_TEST_TEMPLATE_1_INSTANT(Teuchos_Validator, StringToIntegralConverterTest, T )
566 
567 #define NONINTEGRAL_NUMBER_TYPE_TEST( T ) \
568 TEUCHOS_UNIT_TEST_TEMPLATE_1_INSTANT(Teuchos_Validator, EnhancedNumberValidatorConverter, T ) \
569 TEUCHOS_UNIT_TEST_TEMPLATE_1_INSTANT(Teuchos_Validator, NumberArrayValidatorConverterTest, T )
570 
571 typedef unsigned int uint;
572 typedef unsigned short ushort;
573 typedef unsigned long ulong;
574 
575 
579 typedef long long int llint;
581 
582 } // namespace Teuchos
583 
#define FULL_NUMBER_TYPE_TEST(T)
A collection of standard ValidatorXMLConverters.
#define TEST_ASSERT(v1)
Assert the given statement is true.
Maps Validators to integers.
#define NONINTEGRAL_NUMBER_TYPE_TEST(T)
Converts StringValidators to and from XML.
Convience class for EnhancedNumberValidators that are to be applied to arrays.
RCP< const ParameterEntryValidator > validator() const
Return the (optional) validator object.
ValidStringsList validStringValues() const
Return an array of strings of valid values if applicable.
Converts AnyNumberParameterEntryValidators to and from XML.
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.
This object is held as the &quot;value&quot; in the Teuchos::ParameterList std::map.
#define TEST_EQUALITY(v1, v2)
Assert the equality of v1 and v2.
XMLObject fromValidatortoXML(const RCP< const ParameterEntryValidator > validator, const ValidatortoIDMap &validatorIDsMap, bool assignedID=true) const
Converters a given ParameterEntryValidator to XML.
#define TEST_THROW(code, ExceptType)
Assert that the statement &#39;code&#39; throws the exception &#39;ExceptType&#39; (otherwise the test fails)...
Standard implementation of a ParameterEntryValidator that maps from a list of strings to an enum or i...
static RCP< const ValidatorXMLConverter > getConverter(const ParameterEntryValidator &validator)
Get an appropriate ValidatorXMLConverter given a Validator.
Simple helper functions that make it easy to read and write XML to and from a parameterlist.
Takes a validator, wraps it, and applies it to a TwoDArray.
TEUCHOS_UNIT_TEST_TEMPLATE_1_DECL(RCPNodeHandle, basicConstruct_owns_mem, T)
TEUCHOS_UNIT_TEST(ConstNonconstObjectContainer, create)
EPreferredType getPreferredType() const
Lookup the preferred type.
A thin wrapper around the Array class which causes it to be interpreted as a 2D Array.
Thrown when the ValidatorXMLConverterDB can&#39;t find an appropriate converter.
TEUCHOS_DEPRECATED RCP< T > rcp(T *p, Dealloc_T dealloc, bool owns_mem)
Deprecated.
Templated Parameter List class.
void printDoc(const std::string &docString, std::ostream &out) const
Print documentation for this parameter.
Representation of an XML data tree. XMLObject is a ref-counted handle to a XMLObjectImplem object...
A database for ValidatorXMLConverters.
Writes a ParameterList to an XML object.
Convience class for EnhancedNumberValidators that are to be applied to TwoDArray. ...
Unit testing support.
Standard implementation of a BoolParameterEntryValidator that accepts bool values (true/false) or str...
A class for mapping validators to integers.
const std::string getXMLTypeName() const
Get a string that should be used as a value of the type attribute when serializing it to XML...
void insert(RCP< const ParameterEntryValidator > toInsert)
inserts an IDValidatorPair into the map.
Takes a validator, wraps it, and applies it to an array.
A list of parameters of arbitrary type.
A simple validator that only allows certain string values to be choosen or simply enforces that a par...
Abstract interface for an object that can validate a ParameterEntry&#39;s value.
#define TEST_COMPARE_ARRAYS(a1, a2)
Assert that a1.size()==a2.size() and a[i]==b[i], i=0....
bool isDoubleAllowed() const
Lookup whether or not doubles are allowed.
A collection of Exceptions that can be potentially thrown when converting a ParameterList to and from...
Class uesd to validate a particular type of number.
size_type size() const
void validate(ParameterEntry const &entry, std::string const &paramName, std::string const &sublistName) const
Validate a parameter entry value and throw std::exception (with a great error message) if validation ...
static void printKnownConverters(std::ostream &out)
prints the xml tags associated with all known converters
Constructs a CantFindParameterEntryConverterException.
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...
Thrown when xml tag is encountered that is either unrecognized or inappropriate for a given context...
bool isStringAllowed() const
Lookup whether or not strings are allowed.
RCP< ParameterEntryValidator > fromXMLtoValidator(const XMLObject &xmlObj, const IDtoValidatorMap &validatorIDsMap) const
Converts a given XMLObject to a ParameterEntryValidator.
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.
bool isIntAllowed() const
Lookup whether or not ints are allowed.
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...
Thrown when a bad validator xml converter is used.
Thrown when a referenced validator can&#39;t be found.
bool is_null() const
Returns true if the underlying pointer is null.