////////////////////////
// Assign 7 test code //
// Geoff Holden //
// holden@engr.mun.ca //
////////////////////////
#include "assign7.h"
#include <iostream>
#include <string>
using namespace std;
errors problem = NOMEM;
const string OK = "OK\n";
const string FAILED = "** FAILED **\n";
void vError(errors e) {
problem = e;
}
int main() {
Vector t,x(2),y,z(2);
cout << "Checking count...";
cout << ((x.howMany() == 4) ? OK : FAILED);
x[0] = 1, x[1] = 2, y[0] = 5, z[0] = 18, z[1] = 4;
cout << "Adding 2 vectors (same size)...";
t = x + z;
cout << ((t[0] == 19 && t[1] == 6) ? OK : FAILED);
cout << "Adding 2 different vectors (left side larger)...";
t = x + y;
cout << ((t[0] == 6 && t[1] == 2) ? OK : FAILED);
cout << "Adding 2 different vectors (right side larger)...";
t = y + x;
cout << ((t[0] == 6 && t[1] == 2) ? OK : FAILED);
cout << "Testing the ub() function...";
cout << ((x.ub() == 1 && y.ub() == 0 && z.ub() ==
1) ? OK : FAILED);
cout << "Rechecking count...";
cout << ((x.howMany() == 4) ? OK : FAILED);
cout << "Testing for Non-Positive error...";
Vector w(-2);
cout << ((problem == NONPOS) ? OK : FAILED);
cout << "Testing for Out-of-Range error...";
z[5];
cout << ((problem == OUTRANGE) ? OK : FAILED);
return 0;
}