New_Package Package Browser (Single Doxygen Collection)
Version of the Day
Main Page
Related Pages
Namespaces
Classes
Files
File List
File Members
All
Classes
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Friends
Macros
Groups
Pages
test
Hello_Test
Hello_Test.cpp
Go to the documentation of this file.
1
//@HEADER
2
// ***********************************************************************
3
//
4
// New_Package Example 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
// This library is free software; you can redistribute it and/or modify
11
// it under the terms of the GNU Lesser General Public License as
12
// published by the Free Software Foundation; either version 2.1 of the
13
// License, or (at your option) any later version.
14
//
15
// This library is distributed in the hope that it will be useful, but
16
// WITHOUT ANY WARRANTY; without even the implied warranty of
17
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
18
// Lesser General Public License for more details.
19
//
20
// You should have received a copy of the GNU Lesser General Public
21
// License along with this library; if not, write to the Free Software
22
// Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301
23
// USA
24
// Questions? Contact Michael A. Heroux (maherou@sandia.gov)
25
//
26
// ***********************************************************************
27
//@HEADER
28
29
#include "
Epetra_SerialComm.h
"
30
#include "
Newp_Hello.h
"
31
#include <sstream>
32
33
#ifdef HAVE_MPI
34
#include "mpi.h"
35
#endif
36
37
int
main
(
int
argc,
char
*argv[]){
38
39
#ifdef HAVE_MPI
40
MPI_Init(&argc, &argv);
41
#endif
42
43
using namespace
std;
44
45
// Get an Epetra_Comm
46
Epetra_SerialComm
epetra_serial_comm;
47
Epetra_Comm
* epetra_comm;
48
epetra_comm =
dynamic_cast<
Epetra_Comm
*
>
(&epetra_serial_comm);
49
50
//Create an ostream that Newp_Hello can write to and that we can read from
51
stringbuf string_buf;
52
streambuf * stream_buf;
53
stream_buf =
dynamic_cast<
streambuf*
>
(&string_buf);
54
iostream io_stream(stream_buf);
55
ostream * o_stream;
56
o_stream =
dynamic_cast<
ostream*
>
(&io_stream);
57
58
//Create a Newp_Hello to test
59
Newp_Hello
new_package_hello(*epetra_comm);
60
new_package_hello.
Print
(*o_stream);
61
62
//Read from the io_stream
63
char
temp[83];
64
io_stream.getline(temp, 83, 0);
65
66
char
* expected =
"This will print out one line for each of the 1 processes \n\nHello. I am process 0\n"
;
67
68
if
(strcmp(temp, expected) != 0){
69
cout <<
"Test Failed!"
<< endl <<
" Got::"
<< strlen(temp) <<
"::"
<< temp <<
"::"
<< endl <<
"Expected::"
<< strlen(expected) <<
"::"
<< expected <<
"::"
<< endl;
70
return
1;
71
}
72
cout <<
"Test passed!"
<< endl;
73
#ifdef EPETRA_MPI
74
MPI_Finalize();
75
#endif
76
return
0;
77
}
main
int main(int argc, char **argv)
Definition:
cxx_main.cpp:46
Epetra_SerialComm.h
Epetra_Comm
Newp_Hello
A sample class.
Definition:
Newp_Hello.h:59
Newp_Hello::Print
virtual void Print(ostream &os) const
Definition:
Newp_Hello.cpp:43
Newp_Hello.h
Epetra_SerialComm
Generated on Mon Dec 23 2024 09:19:37 for New_Package Package Browser (Single Doxygen Collection) by
1.8.5