brintos

brintos / llvm-project-archived public Read only

0
0
Text · 933 B · a9547ec Raw
44 lines · cpp
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-exception6//7//===----------------------------------------------------------------------===//8// UNSUPPORTED: c++03, c++11, c++14, c++179 10// <string>11 12// constexpr bool ends_with(charT x) const noexcept;13 14#include <string>15#include <cassert>16 17#include "test_macros.h"18 19template <class S>20constexpr void test_string() {21  S s1{};22  S s2{"abcde", 5};23 24  ASSERT_NOEXCEPT(s1.ends_with('e'));25 26  assert(!s1.ends_with('e'));27  assert(!s1.ends_with('x'));28  assert(s2.ends_with('e'));29  assert(!s2.ends_with('x'));30}31 32constexpr bool test() {33  test_string<std::string>();34 35  return true;36}37 38int main(int, char**) {39  test();40  static_assert(test());41 42  return 0;43}44