Commit a45758f5 authored by Ari Trachtenberg's avatar Ari Trachtenberg
Browse files

fixed up testing

parent e307ecda
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
// CHAPTER 2

/**
 * @input  read in three values, one per line, from the user relating to a triangle:
 * @input  read in three integers, one per line, from the user relating to a triangle:
 *   a - the length of one side
 *   b - the length of a neighboring side
 *   gamma - the angle between the sides corresponding to a and b.
+23 −20
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) {