Jambo_Test.cpp

Go to the documentation of this file.
00001 // ***********************************************************************
00002 // 
00003 //                     New_Package Example Package
00004 //                 Copyright (2004) Sandia Corporation
00005 // 
00006 // Under terms of Contract DE-AC04-94AL85000, there is a non-exclusive
00007 // license for use of this work by or on behalf of the U.S. Government.
00008 // 
00009 // This library is free software; you can redistribute it and/or modify
00010 // it under the terms of the GNU Lesser General Public License as
00011 // published by the Free Software Foundation; either version 2.1 of the
00012 // License, or (at your option) any later version.
00013 //  
00014 // This library is distributed in the hope that it will be useful, but
00015 // WITHOUT ANY WARRANTY; without even the implied warranty of
00016 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00017 // Lesser General Public License for more details.
00018 //  
00019 // You should have received a copy of the GNU Lesser General Public
00020 // License along with this library; if not, write to the Free Software
00021 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
00022 // USA
00023 // Questions? Contact Michael A. Heroux (maherou@sandia.gov) 
00024 // 
00025 // ***********************************************************************
00026 //@HEADER
00027 
00028 #include "Epetra_SerialComm.h"
00029 #include "Newp_Jambo.h"
00030 #include <sstream>
00031 
00032 #ifdef HAVE_MPI
00033 #include "mpi.h"
00034 #endif
00035 
00036 int main(int argc, char *argv[]){
00037 
00038 #ifdef HAVE_MPI
00039   MPI_Init(&argc, &argv);
00040 #endif
00041 
00042   using namespace std;
00043 
00044   // Get an Epetra_Comm
00045   Epetra_SerialComm epetra_serial_comm;
00046   Epetra_Comm * epetra_comm;
00047   epetra_comm = dynamic_cast<Epetra_Comm*>(&epetra_serial_comm);
00048 
00049   //Create an ostream that Newp_Hello can write to and that we can read from
00050   stringbuf string_buf;
00051   streambuf * stream_buf;
00052   stream_buf = dynamic_cast<streambuf*>(&string_buf);
00053   iostream io_stream(stream_buf);
00054   ostream * o_stream;
00055   o_stream = dynamic_cast<ostream*>(&io_stream);
00056   
00057   //Create a Newp_Jambo to test
00058   Newp_Jambo new_package_jambo(*epetra_comm);
00059   new_package_jambo.Print(*o_stream);
00060 
00061   //Read from the io_stream
00062   char temp[83];
00063   io_stream.getline(temp, 83, 0);
00064     
00065   char * expected = "This will print out one line for each of the 1 processes \n\nJambo.  I am process 0\n";
00066 
00067   if(strcmp(temp, expected) != 0){
00068     cout << "Test Failed!" << endl << "     Got::" << strlen(temp) << "::" << temp << "::" << endl << "Expected::" << strlen(expected) << "::" << expected << "::" << endl;
00069     return 1;
00070   }
00071   cout << "Test passed!" << endl;
00072   #ifdef EPETRA_MPI
00073   MPI_Finalize();
00074   #endif
00075   return 0;
00076 }

Generated on Thu Sep 18 12:37:03 2008 for New_Package Package Browser (Single Doxygen Collection) by doxygen 1.3.9.1