Teuchos Package Browser (Single Doxygen Collection) Version of the Day
ParameterList_UnitTest.cpp
Go to the documentation of this file.
00001 // @HEADER
00002 // ***********************************************************************
00003 //
00004 //                    Teuchos: Common Tools Package
00005 //                 Copyright (2004) Sandia Corporation
00006 //
00007 // Under terms of Contract DE-AC04-94AL85000, there is a non-exclusive
00008 // license for use of this work by or on behalf of the U.S. Government.
00009 //
00010 // Redistribution and use in source and binary forms, with or without
00011 // modification, are permitted provided that the following conditions are
00012 // met:
00013 //
00014 // 1. Redistributions of source code must retain the above copyright
00015 // notice, this list of conditions and the following disclaimer.
00016 //
00017 // 2. Redistributions in binary form must reproduce the above copyright
00018 // notice, this list of conditions and the following disclaimer in the
00019 // documentation and/or other materials provided with the distribution.
00020 //
00021 // 3. Neither the name of the Corporation nor the names of the
00022 // contributors may be used to endorse or promote products derived from
00023 // this software without specific prior written permission.
00024 //
00025 // THIS SOFTWARE IS PROVIDED BY SANDIA CORPORATION "AS IS" AND ANY
00026 // EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
00027 // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
00028 // PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL SANDIA CORPORATION OR THE
00029 // CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
00030 // EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
00031 // PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
00032 // PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
00033 // LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
00034 // NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
00035 // SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
00036 //
00037 // Questions? Contact Michael A. Heroux (maherou@sandia.gov)
00038 //
00039 // ***********************************************************************
00040 // @HEADER
00041 
00042 #include "Teuchos_ParameterList.hpp"
00043 #include "Teuchos_UnitTestHarness.hpp"
00044 
00045 namespace Teuchos {
00046 
00047 
00048 /*
00049 TEUCHOS_UNIT_TEST( Teuchos_ParameterList, operatorEqualityDifferentNames ) {
00050   // Lists with different names should not be equal
00051   ParameterList A("Tom");
00052   ParameterList B("Bob");
00053   TEST_ASSERT( A != B );
00054   A.set("Hello","World");
00055   B.set("Hello","World");
00056   TEST_ASSERT( A != B );
00057 }
00058 
00059 TEUCHOS_UNIT_TEST( Teuchos_ParameterList, haveSameValuesDifferentNames ) {
00060   ParameterList A("Julie");
00061   ParameterList B("Shannon");
00062   TEST_ASSERT( !haveSameValues(A,B) );
00063   A.set("Hello","World");
00064   B.set("Hello","World");
00065   TEST_ASSERT( !haveSameValues(A,B) );
00066 }
00067 */
00068 
00069 
00070 TEUCHOS_UNIT_TEST( createParameterList, empty )
00071 {
00072   RCP<ParameterList> pl = createParameterList();
00073   TEST_ASSERT(nonnull(pl));
00074 }
00075 
00076 
00077 TEUCHOS_UNIT_TEST( createParameterList, withName )
00078 {
00079   RCP<ParameterList> pl = createParameterList("dummyName");
00080   TEST_ASSERT(nonnull(pl));
00081   TEST_EQUALITY_CONST(pl->name(), "dummyName");
00082 }
00083 
00084 
00085 TEUCHOS_UNIT_TEST( Teuchos_ParameterList, operatorEqualityWithEmpty )
00086 {
00087   // An empty list should not be equal to a full list
00088   ParameterList A;
00089   ParameterList B;
00090   TEST_ASSERT( A == B );
00091   A.set("Hello","World");
00092   TEST_ASSERT( A != B );
00093   B.set("Hello","World");
00094   TEST_ASSERT( A == B );
00095 }
00096 
00097 
00098 TEUCHOS_UNIT_TEST( Teuchos_ParameterList, operatorEqualityDifferentSublistNames )
00099 {
00100   // Sublists with different names should not be equal
00101   ParameterList A;
00102   ParameterList B;
00103   A.sublist("Bob");
00104   B.sublist("Tom");
00105   TEST_ASSERT( A != B );
00106 }
00107 
00108 
00109 TEUCHOS_UNIT_TEST( Teuchos_ParameterList, operatorEqualityDifferentLengths )
00110 {
00111   ParameterList A;
00112   ParameterList B;
00113   A.set("A","a");
00114   A.set("B","b");
00115   A.set("C","c");
00116   A.print();
00117 
00118   B.set("A","a");
00119   B.set("B","b");
00120   B.print();
00121 
00122   TEST_ASSERT( A != B );
00123 
00124   B.set("C","c");
00125   TEST_ASSERT( A == B );
00126 }
00127 
00128 
00129 TEUCHOS_UNIT_TEST( Teuchos_ParameterList, haveSameValuesWithEmpty )
00130 {
00131   ParameterList A;
00132   ParameterList B;
00133   TEST_ASSERT( haveSameValues(A,B) );
00134   A.set("Hello","World");
00135   TEST_ASSERT( !haveSameValues(A,B) );
00136   B.set("Hello","World");
00137   TEST_ASSERT( haveSameValues(A,B) );
00138 }
00139 
00140 
00141 TEUCHOS_UNIT_TEST( Teuchos_ParameterList, haveSameValuesDifferentSublistNames )
00142 {
00143   ParameterList A;
00144   ParameterList B;
00145   A.sublist("Smith").set("People",4);
00146   B.sublist("Jones").set("People",4);
00147   TEST_ASSERT( !haveSameValues(A,B) ); // sublist names matter
00148 }
00149 
00150 
00151 } // namespace Teuchos
00152 
00153 
00154 
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines