push_back.pass.cpp 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  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. // <vector>
  9. // vector<bool>
  10. // void push_back(const value_type& x);
  11. #include <vector>
  12. #include <cassert>
  13. #include <cstddef>
  14. #include "test_macros.h"
  15. #include "min_allocator.h"
  16. int main(int, char**)
  17. {
  18. {
  19. bool a[] = {0, 1, 1, 0, 1, 0, 0};
  20. const unsigned N = sizeof(a)/sizeof(a[0]);
  21. std::vector<bool> c;
  22. for (unsigned i = 0; i < N; ++i)
  23. {
  24. c.push_back(a[i]);
  25. assert(c.size() == i+1);
  26. for (std::size_t j = 0; j < c.size(); ++j)
  27. assert(c[j] == a[j]);
  28. }
  29. }
  30. #if TEST_STD_VER >= 11
  31. {
  32. bool a[] = {0, 1, 1, 0, 1, 0, 0};
  33. const unsigned N = sizeof(a)/sizeof(a[0]);
  34. std::vector<bool, min_allocator<bool>> c;
  35. for (unsigned i = 0; i < N; ++i)
  36. {
  37. c.push_back(a[i]);
  38. assert(c.size() == i+1);
  39. for (std::size_t j = 0; j < c.size(); ++j)
  40. assert(c[j] == a[j]);
  41. }
  42. }
  43. #endif
  44. return 0;
  45. }