Przeglądaj źródła

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 lat temu
rodzic
commit
277520771c
1 zmienionych plików z 13 dodań i 7 usunięć
  1. 13
    7
      TestChild/childProgram.cpp

+ 13
- 7
TestChild/childProgram.cpp Wyświetl plik

@@ -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;

Ładowanie…
Anuluj
Zapisz