All pastes #925542 Raw Edit

testPolynomial.C

public text v1 · immutable
·published 2008-03-03 02:46 UTC
rendered paste body
// testPolynomial.C

#include "Polynomial.h"

#include <iostream>
using std::cout;
using std::endl;

int main()
{
  // test degree 0
  int c[] = {-7};
  Polynomial p(0, c);
  cout << p << endl;

  // test degree 1
  int d[] = {-3, 4};
  Polynomial q(1, d);
  cout << q << endl;

  int e[] = {6, -7};
  Polynomial r(1, e);
  cout << r << endl;

  // test degree 2
  int f[] = {3, -4, 5};
  Polynomial s(2, f);
  cout << s << endl;

  // test degree 3
  int g[] = {7, -2, 4, -8};
  Polynomial t(3, g);
  cout << t << endl;

  // test degree 4
  int h[] = { -4, 9, -2, 5, -8};
  Polynomial u(4, h);
  cout << u << endl;

  // test copy constructor
  Polynomial v(u);
  cout << v << endl;

  // test assignment--equal degree
  int k[] = {10, 20, 30, 40};
  Polynomial w(3, k);
  cout << w << endl;
  w = t;
  cout << w << endl;

  // test assignment--target degree > source degree
  w = r;
  cout << w << endl;

  // test assignment--target degree < source degree
  w = u;
  cout << w << endl;
  
}