starts_with.char.pass.cpp 847 B

1234567891011121314151617181920212223242526272829303132333435
  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, c++11, c++14, c++17
  9. // <string>
  10. // bool starts_with(charT x) const noexcept;
  11. #include <string>
  12. #include <cassert>
  13. #include "test_macros.h"
  14. int main(int, char**)
  15. {
  16. {
  17. typedef std::string S;
  18. S s1 {};
  19. S s2 { "abcde", 5 };
  20. ASSERT_NOEXCEPT(s1.starts_with('e'));
  21. assert (!s1.starts_with('a'));
  22. assert (!s1.starts_with('x'));
  23. assert ( s2.starts_with('a'));
  24. assert (!s2.starts_with('x'));
  25. }
  26. return 0;
  27. }