diff --git a/libcxx/test/libcxx/strings/basic.string/string.modifiers/assert.append.pass.cpp b/libcxx/test/libcxx/strings/basic.string/string.modifiers/assert.append.pass.cpp new file mode 100644 index 0000000000000..c3745ca0a762d --- /dev/null +++ b/libcxx/test/libcxx/strings/basic.string/string.modifiers/assert.append.pass.cpp @@ -0,0 +1,40 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +// + +// basic_string& append(const value_type* s, size_type n); +// basic_string& append(const value_type* s); +// basic_string& append(const value_type* s, size_type pos, size_type n); + +// REQUIRES: has-unix-headers +// UNSUPPORTED: c++03 +// UNSUPPORTED: libcpp-hardening-mode={{none|fast}} +// UNSUPPORTED: libcpp-assertion-semantic={{ignore|observe}} +// XFAIL: libcpp-hardening-mode=debug && availability-verbose_abort-missing + +#include + +#include "check_assertion.h" +#include "min_allocator.h" + +template +void test() { + S l1("123"); + const char* np = nullptr; + TEST_LIBCPP_ASSERT_FAILURE(l1.append(np, 1), "string::append received nullptr"); + TEST_LIBCPP_ASSERT_FAILURE(l1.append(np), "string::append received nullptr"); + TEST_LIBCPP_ASSERT_FAILURE(l1.append(np, 0, 1), "string::append received nullptr"); +} + +int main(int, char**) { + test(); + test, min_allocator > >(); + + return 0; +} diff --git a/libcxx/test/libcxx/strings/basic.string/string.modifiers/assert.assign.pass.cpp b/libcxx/test/libcxx/strings/basic.string/string.modifiers/assert.assign.pass.cpp new file mode 100644 index 0000000000000..80abd15929735 --- /dev/null +++ b/libcxx/test/libcxx/strings/basic.string/string.modifiers/assert.assign.pass.cpp @@ -0,0 +1,40 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +// + +// basic_string& assign(const value_type* s, size_type n); +// basic_string& assign(const value_type* s); +// basic_string& assign(const value_type* s, size_type pos, size_type n); + +// REQUIRES: has-unix-headers +// UNSUPPORTED: c++03 +// UNSUPPORTED: libcpp-hardening-mode={{none|fast}} +// UNSUPPORTED: libcpp-assertion-semantic={{ignore|observe}} +// XFAIL: libcpp-hardening-mode=debug && availability-verbose_abort-missing + +#include + +#include "check_assertion.h" +#include "min_allocator.h" + +template +void test() { + S l1("123"); + const char* np = nullptr; + TEST_LIBCPP_ASSERT_FAILURE(l1.assign(np, 1), "string::assign received nullptr"); + TEST_LIBCPP_ASSERT_FAILURE(l1.assign(np), "string::assign received nullptr"); + TEST_LIBCPP_ASSERT_FAILURE(l1.assign(np, 0, 1), "string::assign received nullptr"); +} + +int main(int, char**) { + test(); + test, min_allocator > >(); + + return 0; +}