initializer_list.pass.cpp 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  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. // UNSUPPORTED: c++98, c++03
  9. // <string>
  10. // basic_string(initializer_list<charT> il, const Allocator& a = Allocator());
  11. #include <string>
  12. #include <cassert>
  13. #include "test_macros.h"
  14. #include "test_allocator.h"
  15. #include "min_allocator.h"
  16. int main(int, char**)
  17. {
  18. {
  19. std::string s = {'a', 'b', 'c'};
  20. assert(s == "abc");
  21. }
  22. {
  23. std::wstring s;
  24. s = {L'a', L'b', L'c'};
  25. assert(s == L"abc");
  26. }
  27. {
  28. typedef std::basic_string<char, std::char_traits<char>, min_allocator<char>> S;
  29. S s = {'a', 'b', 'c'};
  30. assert(s == "abc");
  31. }
  32. {
  33. typedef std::basic_string<wchar_t, std::char_traits<wchar_t>, min_allocator<wchar_t>> S;
  34. S s;
  35. s = {L'a', L'b', L'c'};
  36. assert(s == L"abc");
  37. }
  38. return 0;
  39. }