Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- int main()
- {
- // TESTS
- cout << " \n\n ------ CFileLastError ------ \n\n";
- CFileLastError file;
- file.vOpenFile("Text.txt");
- cout << file.bGetLastError() << endl;
- file.vPrintLine("test");
- cout << file.bGetLastError() << endl;
- // we are using 'w+' operator which in case of missing file creates a new one, so no error
- CFileLastError file2;
- file2.vOpenFile("not_existing_file.txt");
- cout << file2.bGetLastError() << endl;
- file2.vPrintLine("test");
- cout << file2.bGetLastError() << endl;
- CFileLastError file3;
- // we are not opening file, should return error
- file3.vPrintLine("test");
- cout << file3.bGetLastError() << endl;
- CFileLastError file4("file4.txt");
- cout << file4.bGetLastError() << endl;
- vector<string> vect;
- vect.push_back("1");
- vect.push_back("2");
- vect.push_back("3");
- file4.vPrintManyLines(vect);
- cout << file4.bGetLastError() << endl;
- cout << " \n\n ------ CFileThrowEx ------ \n\n";
- // this one throws exception 'file not opened'
- // comment out 'vOpenFile()' line to throw exception !!!
- CFileThrowEx file5;
- file5.vOpenFile("Text.txt");
- file5.vPrintLine("test");
- CFileThrowEx file6;
- file6.vOpenFile("Text.txt");
- file6.vPrintLine("test");
- cout << " \n\n ------ CFileErrorCode ------ \n";
- cout << "~0 - NO ERROR \n~1 - ERROR\n\n";
- CFileErrCode file7;
- cout << file7.bOpenFile("Text.txt") << endl;
- cout << file7.bPrintLine("test") << endl;
- // should return error
- CFileErrCode file8;
- // cout << file8.bOpenFile("Text.txt") << endl;
- cout << file8.bPrintLine("test") << endl;
- // actual task
- cout << " \n\n ------ CFileLastError ------ \n\n";
- openWithLastError("hello.txt");
- cout << " \n\n ------ CFileThrowEx ------ \n\n";
- openWithThrowEx("hello.txt");
- cout << " \n\n ------ CFileErrorCode ------ \n\n";
- openWithErrorCode("hello.txt");
- cout << " \n\n ------ The End ------ \n\n";
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement