Browse Source

Updated clostStdin test to use cin.eof() and cin.read().


git-svn-id: https://svn.microneil.com/svn/CodeDweller-Tests/trunk@60 b3372362-9eaa-4a85-aa2b-6faa1ab7c995
master
adeniz 8 years ago
parent
commit
277520771c
1 changed files with 13 additions and 7 deletions
  1. 13
    7
      TestChild/childProgram.cpp

+ 13
- 7
TestChild/childProgram.cpp View File

@@ -3,6 +3,7 @@
#include <fstream> // debug
#endif
#include <string>
#include <vector>
#include <thread>
#include <chrono>
@@ -57,20 +58,25 @@ main(int argc, char *argv[]) {
<< std::endl;
#endif
std::string temp;
int const BufferSize = 512;
std::cin >> temp;
std::vector<char> readBuffer;
readBuffer.resize(BufferSize, 0);
std::cin.read(&(readBuffer[0]), BufferSize);
if (!std::cin.eof()) {
if (std::cin.eof()) {
#ifdef DEBUG_MESSAGES
log << "stdin was closed." << std::endl;
log << "stdin was not closed." << std::endl;
#endif
returnStatus = 15; // Successful return.
returnStatus = 10; // Unsuccessful return.
} else {
#ifdef DEBUG_MESSAGES
log << "stdin was not closed." << std::endl;
log << "stdin was closed." << std::endl;
#endif
returnStatus = 10; // Unsuccessful return.
returnStatus = 15; // Successful return.
}
goto exit;

Loading…
Cancel
Save