bool TestStreams() { const char * rgszTestFile[3] = { "test1-input.ini", "test1-output.ini", "test1-expected.ini" }; Test oTest("TestStreams"); CSimpleIniW ini; ini.SetUnicode(true); ini.SetMultiKey(true); ini.SetMultiLine(true); // load the file try { std::ifstream instream; instream.open(rgszTestFile[0], std::ifstream::in | std::ifstream::binary); if (ini.LoadData(instream) < 0) throw false; instream.close(); } catch (...) { return oTest.Failure("Failed to load file"); } // standard contents test //if (!StandardContentsTest(ini, oTest)) { // return false; //} // save the file try { std::ofstream outfile; outfile.open(rgszTestFile[1], std::ofstream::out | std::ofstream::binary); if (ini.Save(outfile, true) < 0) throw false; outfile.close(); } catch (...) { return oTest.Failure("Failed to save file"); } // file comparison test if (!FileComparisonTest(rgszTestFile[1], rgszTestFile[2])) { return oTest.Failure("Failed file comparison"); } if (!FileLoadTest(rgszTestFile[1], rgszTestFile[2])) { return oTest.Failure("Failed file load comparison"); } return oTest.Success(); }
bool UnitTestGroup::operator()( std::ostream& a_roOut ) const { a_roOut << std::endl << "Running " << m_oName << "..." << std::endl; unsigned int uiRan = 0; unsigned int uiFailed = 0; for each( UnitTest oTest in m_oTests ) { if( !oTest( a_roOut ) ) { ++uiFailed; } ++uiRan; } if( uiFailed ) { a_roOut << "FAILED " << uiFailed << " of " << uiRan << " tests"; } else { a_roOut << "PASSED all " << uiRan << " tests"; } a_roOut << std::endl; return ( 0 == uiFailed ); }