int main() { //test creation of multiple types Bag<int> IntBag; Bag<double> DoubleBag; Bag<string> StringBag; bool passed; for (int j = 0; j < 50000; j++) { IntBag.AddItem(j); passed = true; } for (int j = 0; j < 50000; j++){ if (!IntBag.IsPresent(j)){ cout << "Error: Lost item " << j << endl; passed = false; } } if (passed) { cout << "Retained all items \n"; } else cout << "Failed test\n"; passed = true; for (int j = 50000; j < 50050; j++){ if (IntBag.IsPresent(j) || IntBag.IsPresent(j*-1)){ passed = false; cout << "Found extra item: " << j << '\n'; } } if (passed) { cout << "No extra items \n"; } else cout << "Failed extra-item test\n"; passed = false; try{ IntBag.Discard(-1); } catch (BagException){ passed = true; cout << "Raised expected exception on discarding nonexistent item\n"; } if (passed) { cout << "Handled discard of non-existent item \n"; } else cout << "Failed discard test\n"; IntBag.Discard(12); if (IntBag.IsPresent(12)) { cout << "Failed to discard item\n"; } else cout << "Discard-item test passed.\n"; IntBag.Clear(); if (!IntBag.IsEmpty()) { cout << "Failed to clear Bag\n"; } else cout << "Cleared Bag OK. \n"; if (IntBag.IsEmpty() && IntBag.Size() != 0) { cout << "Error: Reports empty but nonzero count.\n"; } system("pause"); return 0; }