1 |
+ |
#include <iostream> |
2 |
+ |
#include <string> |
3 |
+ |
|
4 |
|
#include "io/basic_ifstrstream.hpp" |
5 |
|
#include "IfstrstreamTestCase.hpp" |
6 |
+ |
|
7 |
|
// Registers the fixture into the 'registry' |
8 |
+ |
|
9 |
+ |
using namespace std; |
10 |
+ |
using namespace OpenMD; |
11 |
|
CPPUNIT_TEST_SUITE_REGISTRATION( IfstrstreamTestCase ); |
12 |
|
|
13 |
|
#ifndef IS_MPI |
14 |
|
void IfstrstreamTestCase::setUp() { |
15 |
|
|
16 |
+ |
|
17 |
|
} |
18 |
|
|
19 |
|
void IfstrstreamTestCase::tearDown() { |
22 |
|
|
23 |
|
|
24 |
|
void IfstrstreamTestCase::testConstructor() { |
25 |
+ |
ifstrstream fin1; |
26 |
+ |
fin1.open("DUFF.frc"); |
27 |
+ |
CPPUNIT_ASSERT(fin1.is_open()); |
28 |
|
|
29 |
+ |
ifstrstream fin2; |
30 |
+ |
fin2.open("NonExistFile"); |
31 |
+ |
CPPUNIT_ASSERT(!fin2.is_open()); |
32 |
+ |
|
33 |
+ |
ifstrstream fin3("DUFF.frc"); |
34 |
+ |
CPPUNIT_ASSERT(fin3.is_open()); |
35 |
+ |
|
36 |
+ |
ifstrstream fin4("NonExistFile"); |
37 |
+ |
CPPUNIT_ASSERT(!fin4.is_open()); |
38 |
|
} |
39 |
|
|
40 |
|
void IfstrstreamTestCase::testOpen() { |
41 |
+ |
const int MAXLEN = 1024; |
42 |
+ |
char buffer[MAXLEN]; |
43 |
|
|
44 |
+ |
string firstLine = "! This is the forcefield file for the Dipolar Unified-atom Force Field (DUFF)."; |
45 |
+ |
|
46 |
+ |
ifstrstream fin1; |
47 |
+ |
fin1.open("DUFF.frc"); |
48 |
+ |
|
49 |
+ |
fin1.getline(buffer, MAXLEN); |
50 |
+ |
CPPUNIT_ASSERT(buffer == firstLine); |
51 |
+ |
cout << buffer; |
52 |
|
} |
53 |
|
|
54 |
|
void IfstrstreamTestCase::testIs_open() { |
69 |
|
} |
70 |
|
|
71 |
|
void IfstrstreamTestCase::testMasterConstructor() { |
72 |
< |
CPPUNIT_ASSERT(1 == 0); |
72 |
> |
const int MAXLEN = 1024; |
73 |
> |
char buffer[MAXLEN]; |
74 |
> |
|
75 |
> |
string firstLine = "! This is the forcefield file for the Dipolar Unified-atom Force Field (DUFF)."; |
76 |
> |
|
77 |
> |
ifstrstream fin1; |
78 |
> |
fin1.open("DUFF.frc"); |
79 |
> |
|
80 |
> |
fin1.getline(buffer, MAXLEN); |
81 |
> |
CPPUNIT_ASSERT(buffer == firstLine); |
82 |
> |
cout << buffer; |
83 |
> |
|
84 |
|
} |
85 |
|
|
86 |
|
void IfstrstreamTestCase::testMasterOpen() { |