brintos

brintos / llvm-project-archived public Read only

0
0
Text · 1.0 KiB · 309c84b Raw
38 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 9// <string>10 11// basic_string(const basic_string<charT,traits,Allocator>& str);12 13#include <string>14#include <cassert>15 16#include "test_macros.h"17#include "test_allocator.h"18 19template <class S>20TEST_CONSTEXPR_CXX20 bool test() {21  // Tests that a long string holding a SSO size string results in22  // an SSO copy constructed value.23  S s1("1234567890123456789012345678901234567890123456789012345678901234567890");24  s1.resize(7);25  S s2(s1);26  LIBCPP_ASSERT(s2.__invariants());27  assert(s2 == s1);28  assert(s2.capacity() < sizeof(S));29 30  return true;31}32 33int main(int, char**) {34  test<std::basic_string<char, std::char_traits<char>, test_allocator<char> > >();35 36  return 0;37}38