| 1 |
tim |
91 |
#include <iostream> |
| 2 |
|
|
#include <string> |
| 3 |
|
|
|
| 4 |
tim |
85 |
#include "io/basic_ifstrstream.hpp" |
| 5 |
|
|
#include "IfstrstreamTestCase.hpp" |
| 6 |
tim |
91 |
|
| 7 |
tim |
85 |
// Registers the fixture into the 'registry' |
| 8 |
tim |
91 |
|
| 9 |
|
|
using namespace std; |
| 10 |
gezelter |
1390 |
using namespace OpenMD; |
| 11 |
tim |
85 |
CPPUNIT_TEST_SUITE_REGISTRATION( IfstrstreamTestCase ); |
| 12 |
|
|
|
| 13 |
|
|
#ifndef IS_MPI |
| 14 |
|
|
void IfstrstreamTestCase::setUp() { |
| 15 |
|
|
|
| 16 |
tim |
91 |
|
| 17 |
tim |
85 |
} |
| 18 |
|
|
|
| 19 |
|
|
void IfstrstreamTestCase::tearDown() { |
| 20 |
|
|
|
| 21 |
|
|
} |
| 22 |
|
|
|
| 23 |
|
|
|
| 24 |
|
|
void IfstrstreamTestCase::testConstructor() { |
| 25 |
tim |
91 |
ifstrstream fin1; |
| 26 |
|
|
fin1.open("DUFF.frc"); |
| 27 |
|
|
CPPUNIT_ASSERT(fin1.is_open()); |
| 28 |
tim |
85 |
|
| 29 |
tim |
91 |
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 |
tim |
85 |
} |
| 39 |
|
|
|
| 40 |
|
|
void IfstrstreamTestCase::testOpen() { |
| 41 |
tim |
91 |
const int MAXLEN = 1024; |
| 42 |
|
|
char buffer[MAXLEN]; |
| 43 |
tim |
85 |
|
| 44 |
tim |
91 |
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 |
tim |
85 |
} |
| 53 |
|
|
|
| 54 |
|
|
void IfstrstreamTestCase::testIs_open() { |
| 55 |
|
|
|
| 56 |
|
|
} |
| 57 |
|
|
|
| 58 |
|
|
void IfstrstreamTestCase::testClose() { |
| 59 |
|
|
|
| 60 |
|
|
} |
| 61 |
|
|
|
| 62 |
|
|
#else |
| 63 |
|
|
void IfstrstreamTestCase::setUp() { |
| 64 |
|
|
|
| 65 |
|
|
} |
| 66 |
|
|
|
| 67 |
|
|
void IfstrstreamTestCase::tearDown() { |
| 68 |
|
|
|
| 69 |
|
|
} |
| 70 |
|
|
|
| 71 |
|
|
void IfstrstreamTestCase::testMasterConstructor() { |
| 72 |
tim |
91 |
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 |
tim |
85 |
} |
| 85 |
|
|
|
| 86 |
|
|
void IfstrstreamTestCase::testMasterOpen() { |
| 87 |
|
|
|
| 88 |
|
|
} |
| 89 |
|
|
|
| 90 |
|
|
void IfstrstreamTestCase::testMasterIs_open() { |
| 91 |
|
|
|
| 92 |
|
|
} |
| 93 |
|
|
|
| 94 |
|
|
void IfstrstreamTestCase::testMasterClose() { |
| 95 |
|
|
|
| 96 |
|
|
|
| 97 |
|
|
} |
| 98 |
|
|
|
| 99 |
|
|
void IfstrstreamTestCase::testSlaveConstructor() { |
| 100 |
|
|
|
| 101 |
|
|
} |
| 102 |
|
|
|
| 103 |
|
|
void IfstrstreamTestCase::testSlaveOpen() { |
| 104 |
|
|
|
| 105 |
|
|
} |
| 106 |
|
|
|
| 107 |
|
|
void IfstrstreamTestCase::testSlaveIs_open() { |
| 108 |
|
|
|
| 109 |
|
|
} |
| 110 |
|
|
|
| 111 |
|
|
void IfstrstreamTestCase::testSlaveClose() { |
| 112 |
|
|
|
| 113 |
|
|
|
| 114 |
|
|
} |
| 115 |
|
|
#endif |