/////////////////////////////////////////////////////////////// // vec.cpp - tests vec class // // Exam1:Q2 // // Jim Fawcett, CSE687 - Object Oriented Design, Spring 05 // /////////////////////////////////////////////////////////////// #include #include #include "vec.h" using namespace std; using namespace Exam1; #ifdef TEST_VEC #include //----< helper functions >------------------------------------- string title(const string& s) { string temp(s.length()+2,'='); return (string("\n ") + s + string("\n ") + temp + "\n"); } string subtitle(const string& s) { string temp(s.length()+2,'-'); return (string("\n ") + s + string("\n ") + temp + "\n"); } //----< test stub >-------------------------------------------- int main() { cout << title("Testing Vector Class"); cout << subtitle("vec operations:"); vec v1(3,1.0); show(v1,"v1"); vec v2(3,2.0); show(v2,"v2"); vec v3 = v1 + v2; show(v3,"v3 = v1 + v2"); cout << "\n size of v3 = " << v3.size(); v1 = v3; show(v1,"v1 = v3"); vec v4(3); v4 = 0.33333 * v1; show(v4,"v4 = 0.33333 * v1"); cout << subtitle("vec operations"); vec v5(4,1); show(v5,"v5"); vec v6(4,-2); show(v6,"v6"); vec v7 = v5 - v6; show(v7,"v7 = v5 - v6"); cout << "\n size of v7 = " << v7.size(); cout << "\n\n"; return 0; } #endif