// Oldham, Jeffrey D. // 2000Mar17 // CS1321 // Test Dynamic Array Implementations // Stress-test the code. #include #include // has EXIT_SUCCESS #include // helps detect memory leaks #include "dynamicArray.h" int main(int argc, char *argv[]) { mtrace(); // turn on memory leak detection if (argc != 2) { cerr << argv[0] << ": number-of-pushes\n"; throw "missing command-line argument"; } dynamicArray::length_pos nuPushes = strtoul(argv[1], static_cast(0), 0); // Do not check for errors. Bad! dynamicArray d; for (dynamicArray::length_pos i = 0; i < nuPushes; ++i) d.push_back(2*i+1); d.show_op_counts(cerr, "after pushes"); for (dynamicArray::length_pos i = 0; i < nuPushes; ++i) { if (i % 100 == 0) cout << d.pop_back() << endl; else (void) d.pop_back(); } d.show_op_counts(cerr, "after pops"); return EXIT_SUCCESS; }