pop.pass.cpp 820 B

12345678910111213141516171819202122232425262728293031323334353637
  1. //===----------------------------------------------------------------------===//
  2. //
  3. // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
  4. // See https://llvm.org/LICENSE.txt for license information.
  5. // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
  6. //
  7. //===----------------------------------------------------------------------===//
  8. // <stack>
  9. // void pop();
  10. #include <stack>
  11. #include <cassert>
  12. #include "test_macros.h"
  13. int main(int, char**)
  14. {
  15. std::stack<int> q;
  16. assert(q.size() == 0);
  17. q.push(1);
  18. q.push(2);
  19. q.push(3);
  20. assert(q.size() == 3);
  21. assert(q.top() == 3);
  22. q.pop();
  23. assert(q.size() == 2);
  24. assert(q.top() == 2);
  25. q.pop();
  26. assert(q.size() == 1);
  27. assert(q.top() == 1);
  28. q.pop();
  29. assert(q.size() == 0);
  30. return 0;
  31. }