test/Object/cxx_main.cpp

Go to the documentation of this file.
00001 //@HEADER
00002 // ************************************************************************
00003 // 
00004 //               Epetra: Linear Algebra Services Package 
00005 //                 Copyright (2001) 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 // This library is free software; you can redistribute it and/or modify
00011 // it under the terms of the GNU Lesser General Public License as
00012 // published by the Free Software Foundation; either version 2.1 of the
00013 // License, or (at your option) any later version.
00014 //  
00015 // This library is distributed in the hope that it will be useful, but
00016 // WITHOUT ANY WARRANTY; without even the implied warranty of
00017 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00018 // Lesser General Public License for more details.
00019 //  
00020 // You should have received a copy of the GNU Lesser General Public
00021 // License along with this library; if not, write to the Free Software
00022 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
00023 // USA
00024 // Questions? Contact Michael A. Heroux (maherou@sandia.gov) 
00025 // 
00026 // ************************************************************************
00027 //@HEADER
00028 
00029 // Epetra_Object Test routine
00030 
00031 #include "Epetra_Object.h"
00032 #ifdef EPETRA_MPI
00033 #include "Epetra_MpiComm.h"
00034 #include <mpi.h>
00035 #else
00036 #include "Epetra_SerialComm.h"
00037 #endif
00038 
00039 #include "../epetra_test_err.h"
00040 #include "Epetra_Version.h"
00041                                             
00042 int main(int argc, char *argv[]) {
00043 
00044   int ierr = 0;
00045 #ifdef EPETRA_MPI
00046   MPI_Init(&argc,&argv);
00047   Epetra_MpiComm comm( MPI_COMM_WORLD );
00048 
00049 #else
00050   Epetra_SerialComm comm;
00051 #endif
00052 
00053   bool verbose = false;
00054 
00055   // Check if we should print results to standard out
00056   if (argc>1) if (argv[1][0]=='-' && argv[1][1]=='v') verbose = true;
00057 
00058   if (verbose && comm.MyPID()==0)
00059     cout << Epetra_Version() << endl << endl;
00060 
00061   // I'm alive !!!
00062   if (verbose) cout << comm <<endl;
00063 
00064   Epetra_Object obj;
00065 
00066   // Test Epetra_Object label and the method to get the label attribute
00067   const char* ObjLabel = obj.Label();
00068   const char* ObjLabel1 = "Epetra::Object";
00069   if (verbose) cout << endl << endl << "This should say " << ObjLabel1 << ": " << ObjLabel << endl << endl << endl;
00070   EPETRA_TEST_ERR(strcmp(ObjLabel1,ObjLabel),ierr);
00071 
00072   // Test Epetra_Object SetLabel attribute set method
00073   const char* NewObjLabel = "New name for Epetra_Object";
00074   obj.SetLabel(NewObjLabel);
00075   const char* NewObjLabel1 = obj.Label(); 
00076   if (verbose) cout << endl << "This should say " << NewObjLabel << ": " << NewObjLabel1 << endl << endl << endl;
00077   EPETRA_TEST_ERR(strcmp(NewObjLabel1,NewObjLabel),ierr);
00078 
00079   // Test GetRacebackMode and SetTracebackMode methods
00080   EPETRA_TEST_ERR(!(obj.GetTracebackMode()==DefaultTracebackMode),ierr);
00081   if (verbose) cout << endl <<"Default Traceback Mode value = " << obj.GetTracebackMode() << endl;
00082 
00083   obj.SetTracebackMode(DefaultTracebackMode-1);
00084   if (verbose) cout << "Set Traceback Mode value to one less than default = " << obj.GetTracebackMode() << endl << endl;
00085   Epetra_Object obj0;
00086   EPETRA_TEST_ERR(!(obj0.GetTracebackMode()==DefaultTracebackMode-1),ierr);
00087 
00088   // Test constructors other than the default
00089   Epetra_Object obj1(1); // pass only TracebackMode
00090   int TbM = obj1.GetTracebackMode();
00091   if (verbose) cout << endl << endl << "This should say 1: " << TbM << endl << endl;
00092   EPETRA_TEST_ERR(!(1==TbM),ierr);
00093 
00094   Epetra_Object obj2(NewObjLabel); // pass only a label
00095   const char* NewObjLabel2 = obj2.Label();
00096   if (verbose) cout << endl << endl << "This should say " << NewObjLabel << ": " << NewObjLabel2 << endl << endl << endl;
00097   EPETRA_TEST_ERR(strcmp(NewObjLabel2,NewObjLabel),ierr);
00098 
00099   Epetra_Object obj3(NewObjLabel,1); // pass a label and a TracebackMode
00100   const char* NewObjLabel3 = obj3.Label();
00101   int TbM1 = obj3.GetTracebackMode();
00102   if (verbose) cout << endl << "This should say " << NewObjLabel << "," << "1: " << NewObjLabel3 << "," << TbM1 << endl << endl << endl;
00103   EPETRA_TEST_ERR(strcmp(NewObjLabel3,NewObjLabel),ierr);
00104   EPETRA_TEST_ERR(!(1==TbM1),ierr);
00105   
00106   Epetra_Object obj4(obj3); // copy constructor
00107   const char* NewObjLabel4 = obj4.Label();
00108   int TbM2 = obj4.GetTracebackMode();
00109   if (verbose) cout << endl << "This should say " << NewObjLabel << "," << "1: " << NewObjLabel4 << "," << TbM2 << endl << endl << endl;
00110   EPETRA_TEST_ERR(strcmp(NewObjLabel4,NewObjLabel),ierr);
00111   EPETRA_TEST_ERR(!(1==TbM2),ierr);
00112   
00113 
00114 #ifdef EPETRA_MPI
00115   MPI_Finalize();
00116 #endif
00117   return ierr;
00118 }
00119 
00120 /*
00121   end of file main.cc
00122 */

Generated on Wed May 12 21:41:04 2010 for Epetra Package Browser (Single Doxygen Collection) by  doxygen 1.4.7