Loading tests/LabZero.cpp +6 −3 Original line number Diff line number Diff line Loading @@ -15,6 +15,7 @@ using namespace std; // global variables streambuf* orig_cin_buf; // records the standard input buffer streambuf* orig_cout_buf; // records the standard output buffer istringstream inStream; // input stream to produce from a given string ostringstream outStream; // captured output stream Loading @@ -39,7 +40,9 @@ void redirIO(const string iStr) { orig_cin_buf = cin.rdbuf(); orig_cout_buf = cout.rdbuf(); istringstream inStream(iStr); // set up streams inStream.str(iStr); outStream.str(""); outStream.clear(); cin.rdbuf(inStream.rdbuf()); cout.rdbuf(outStream.rdbuf()); } Loading @@ -59,7 +62,7 @@ string restoreIO() { // TESTS bool test_labZero_pZero() { redirIO("1\n2\n90\n"); // redirect input redirIO("1 2 90"); // redirect input labZero_pZero(); float out = stof(restoreIO()); if (out*out>1.99 && out*out<2.01) { Loading Loading
tests/LabZero.cpp +6 −3 Original line number Diff line number Diff line Loading @@ -15,6 +15,7 @@ using namespace std; // global variables streambuf* orig_cin_buf; // records the standard input buffer streambuf* orig_cout_buf; // records the standard output buffer istringstream inStream; // input stream to produce from a given string ostringstream outStream; // captured output stream Loading @@ -39,7 +40,9 @@ void redirIO(const string iStr) { orig_cin_buf = cin.rdbuf(); orig_cout_buf = cout.rdbuf(); istringstream inStream(iStr); // set up streams inStream.str(iStr); outStream.str(""); outStream.clear(); cin.rdbuf(inStream.rdbuf()); cout.rdbuf(outStream.rdbuf()); } Loading @@ -59,7 +62,7 @@ string restoreIO() { // TESTS bool test_labZero_pZero() { redirIO("1\n2\n90\n"); // redirect input redirIO("1 2 90"); // redirect input labZero_pZero(); float out = stof(restoreIO()); if (out*out>1.99 && out*out<2.01) { Loading