brintos

brintos / llvm-project-archived public Read only

0
0
Text · 1.0 KiB · b9211f3 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 9// UNSUPPORTED: c++03, c++1110#include <memory>11#include <string>12#include <cassert>13 14#include "test_macros.h"15 16TEST_CONSTEXPR_CXX23 bool test() {17  {18    std::unique_ptr<int> p1 = std::make_unique<int>(1);19    assert(*p1 == 1);20    p1 = std::make_unique<int>();21    assert(*p1 == 0);22  }23 24  {25    std::unique_ptr<std::string> p2 = std::make_unique<std::string>("Meow!");26    assert(*p2 == "Meow!");27    p2 = std::make_unique<std::string>();28    assert(*p2 == "");29    p2 = std::make_unique<std::string>(6, 'z');30    assert(*p2 == "zzzzzz");31  }32 33  return true;34}35 36int main(int, char**) {37  test();38#if TEST_STD_VER >= 2339  static_assert(test());40#endif41 42  return 0;43}44