Commit 434c6cc2 authored by Ari Trachtenberg's avatar Ari Trachtenberg
Browse files

added debugging

parent a7400ae9
Loading
Loading
Loading
Loading
+37 −43
Original line number Diff line number Diff line
@@ -17,9 +17,7 @@ bool test_labOne_pZero() {
    // simple, but incomplete tests

    // example 1
    Common::redirIO("3 4"); // redirect input
    labOne_pZero();
    string out = Common::restoreIO();
    string out = Common::testFunc(labOne_pZero,"3 4");
    // count occurrences of ****
    size_t pos=0; int count=0;
    while ((pos = out.find("****", pos)) != string::npos) {
@@ -30,37 +28,31 @@ bool test_labOne_pZero() {
        return false;

    // example 2
    Common::redirIO("1 10"); // redirect input
    labOne_pZero();
    out = Common::restoreIO();
    out = Common::testFunc(labOne_pZero,"1 10");
    if (out.find("**********") == string::npos)
        return false;

    cerr << "HERE1" << endl;
    return true;
}

bool test_labOne_pOne() {
    // example 1
    Common::redirIO("2");
    labOne_pOne();
    int out = Common::getInt(Common::restoreIO());
    int out = Common::testFuncInt(labOne_pOne, "2");
    if (out!=5)
        return false;

    // example 2
    Common::redirIO("9");
    labOne_pOne();
    out = stoi(Common::restoreIO());
    out = Common::testFuncInt(labOne_pOne,"9");
    if (out!=48)
        return false;

    cerr << "HERE2" << endl;
    return true;
}

bool test_labOne_pTwo() {
  Common::redirIO("20");
  labOne_pTwo();
  string out = Common::restoreIO();
    string out = Common::testFunc(labOne_pTwo,"rum");

    // sum the length of each line
    istringstream stream(out);
@@ -75,16 +67,17 @@ bool test_labOne_pTwo() {
            sum += line.length();
    }

  if (sum == 10)
    return true;
  else
    if (sum != 10) {
        return false;
    }

    cerr << "HERE3" << endl;
    // All tests passed
    return true;
}

bool test_labOne_pThree() {
    Common::redirIO("20");
    labOne_pThree();
    string out = Common::restoreIO();
    string out = Common::testFunc(labOne_pThree, "20");

    // sum the numbers on each line
    istringstream stream(out);
@@ -98,10 +91,11 @@ bool test_labOne_pThree() {
            sum += Common::getInt(line);
    }

    if (sum==132)
        return true;
    else
    if (sum!=132)
        return false;

    cerr << "HERE4" << endl;
    return true;
}

bool test_labOne_pFour() {