Commit 37fa3461 authored by Ari Trachtenberg's avatar Ari Trachtenberg
Browse files

Updated solutions

parent e307ecda
Loading
Loading
Loading
Loading
+6 −3
Original line number Diff line number Diff line
@@ -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


@@ -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());
}
@@ -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) {