FEI Version of the Day
test_Tables.cpp
00001 /*--------------------------------------------------------------------*/
00002 /*    Copyright 2005 Sandia Corporation.                              */
00003 /*    Under the terms of Contract DE-AC04-94AL85000, there is a       */
00004 /*    non-exclusive license for use of this work by or on behalf      */
00005 /*    of the U.S. Government.  Export of this program may require     */
00006 /*    a license from the United States Government.                    */
00007 /*--------------------------------------------------------------------*/
00008 
00009 
00010 #include <fei_macros.hpp>
00011 
00012 #include <test_utils/test_Tables.hpp>
00013 
00014 #include <snl_fei_RaggedTable.hpp>
00015 #include <fei_ProcEqns.hpp>
00016 #include <fei_ctg_set.hpp>
00017 #include <map>
00018 #undef fei_file
00019 #define fei_file "test_Tables.cpp"
00020 #include <fei_ErrMacros.hpp>
00021 
00022 test_Tables::test_Tables(MPI_Comm comm)
00023  : tester(comm)
00024 {
00025 }
00026 
00027 test_Tables::~test_Tables()
00028 {
00029 }
00030 
00031 int test_Tables::runtests()
00032 {
00033   //This class doesn't have any parallel tests. The Table objects are
00034   //purely serial objects, so only run tests if numProcs_==1.
00035   if (numProcs_ > 1) {
00036     return(0);
00037   }
00038 
00039   CHK_ERR( test1() );
00040   CHK_ERR( test2() );
00041   CHK_ERR( test3() );
00042   CHK_ERR( test4() );
00043   return(0);
00044 }
00045 
00046 int test_Tables::test1()
00047 {
00048   int len = 100;
00049 
00050   snl_fei::RaggedTable<std::map<int,fei::ctg_set<int>*>,fei::ctg_set<int> > ordTable(0,1);
00051   snl_fei::RaggedTable<std::map<int,fei::ctg_set<int>*>,fei::ctg_set<int> > ordTable2(0,1);
00052 
00053   std::vector<int> keys(len), values(len);
00054   int i;
00055   for(i=0; i<len; ++i) {
00056     keys[i] = i;
00057     values[i] = i;
00058 
00059     ordTable.addIndices(i, 1, &i);
00060   }
00061 
00062   keys.push_back(len);
00063   values.push_back(len);
00064   ++len;
00065 
00066   ordTable.addIndices(len, &keys[0], len, &values[0] );
00067 
00068   bool same = ordTable.equal(ordTable2, true);
00069   if (same) {
00070     return(-1);
00071   }
00072 
00073   for(i=0; i<len; ++i) {
00074     keys[i] = i;
00075     values[i] = i;
00076 
00077     ordTable2.addIndices(i, 1, &i);
00078   }
00079 
00080   same = ordTable.equal(ordTable2, true);
00081 
00082   ordTable2.addIndices(len, &keys[0], len, &values[0] );
00083 
00084   same = ordTable.equal(ordTable2, false);
00085   if (!same) {
00086     return(-2);
00087   }
00088 
00089   return(0);
00090 }
00091 
00092 int test_Tables::test2()
00093 {
00094   return(0);
00095 }
00096 
00097 int test_Tables::test3()
00098 {
00099   int len = 100;
00100 
00101   ProcEqns peqns;
00102 
00103   std::vector<int> keys(len), values(len);
00104   for(int i=0; i<len; ++i) {
00105     keys[i] = i;
00106     values[i] = i;
00107 
00108     peqns.addEqn(i, i);
00109     peqns.addEqn(i, i, len-i);
00110   }
00111 
00112   return(0);
00113 }
00114 
00115 int test_Tables::test4()
00116 {
00117   return(0);
00118 }
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Friends