--- trunk/test/io/IfstrstreamTestCase.cpp 2004/10/15 18:28:46 85 +++ trunk/test/io/IfstrstreamTestCase.cpp 2004/10/15 21:11:35 91 @@ -1,11 +1,19 @@ +#include +#include + #include "io/basic_ifstrstream.hpp" #include "IfstrstreamTestCase.hpp" + // Registers the fixture into the 'registry' + +using namespace std; +using namespace oopse; CPPUNIT_TEST_SUITE_REGISTRATION( IfstrstreamTestCase ); #ifndef IS_MPI void IfstrstreamTestCase::setUp() { + } void IfstrstreamTestCase::tearDown() { @@ -14,11 +22,33 @@ void IfstrstreamTestCase::testConstructor() { void IfstrstreamTestCase::testConstructor() { + ifstrstream fin1; + fin1.open("DUFF.frc"); + CPPUNIT_ASSERT(fin1.is_open()); + ifstrstream fin2; + fin2.open("NonExistFile"); + CPPUNIT_ASSERT(!fin2.is_open()); + + ifstrstream fin3("DUFF.frc"); + CPPUNIT_ASSERT(fin3.is_open()); + + ifstrstream fin4("NonExistFile"); + CPPUNIT_ASSERT(!fin4.is_open()); } void IfstrstreamTestCase::testOpen() { + const int MAXLEN = 1024; + char buffer[MAXLEN]; + string firstLine = "! This is the forcefield file for the Dipolar Unified-atom Force Field (DUFF)."; + + ifstrstream fin1; + fin1.open("DUFF.frc"); + + fin1.getline(buffer, MAXLEN); + CPPUNIT_ASSERT(buffer == firstLine); + cout << buffer; } void IfstrstreamTestCase::testIs_open() { @@ -39,7 +69,18 @@ void IfstrstreamTestCase::testMasterConstructor() { } void IfstrstreamTestCase::testMasterConstructor() { - CPPUNIT_ASSERT(1 == 0); + const int MAXLEN = 1024; + char buffer[MAXLEN]; + + string firstLine = "! This is the forcefield file for the Dipolar Unified-atom Force Field (DUFF)."; + + ifstrstream fin1; + fin1.open("DUFF.frc"); + + fin1.getline(buffer, MAXLEN); + CPPUNIT_ASSERT(buffer == firstLine); + cout << buffer; + } void IfstrstreamTestCase::testMasterOpen() {