containers.cpp 622 B

1234567891011121314151617181920212223242526272829303132333435363738
  1. #include "Crown.h"
  2. #include <cstdio>
  3. #include <cassert>
  4. using namespace crown;
  5. int main()
  6. {
  7. MallocAllocator allocator;
  8. List<int> int_list(allocator);
  9. assert(int_list.size() == 0);
  10. int_list.push_back(10);
  11. int_list.push_back(20);
  12. int_list.push_back(30);
  13. int_list.push_back(40);
  14. int_list.push_back(50);
  15. int_list.push_back(60);
  16. assert(int_list.size() == 6);
  17. assert(int_list.front() == 10);
  18. assert(int_list.back() == 60);
  19. int_list.pop_back();
  20. assert(int_list.size() == 5);
  21. assert(int_list.front() == 10);
  22. assert(int_list.back() == 50);
  23. int_list.clear();
  24. assert(int_list.size() == 0);
  25. return 0;
  26. }