<commit_before>//===----------------------------------------------------------------------===//
//
//                     The LLVM Compiler Infrastructure
//
// This file is dual licensed under the MIT and the University of Illinois Open
// Source Licenses. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//

// <string_view>

// size_type copy(charT* s, size_type n, size_type pos = 0) const;

// Throws: out_of_range if pos > size().
// Remarks: Let rlen be the smaller of n and size() - pos.
// Requires: [s, s+rlen) is a valid range.
// Effects: Equivalent to std::copy_n(begin() + pos, rlen, s).
// Returns: rlen.


#include <string_view>
#include <cassert>

#include "test_macros.h"

template<typename CharT>
void test1 ( std::basic_string_view<CharT> sv, size_t n, size_t pos ) {
    const size_t rlen = std::min ( n, sv.size() - pos );

    CharT *dest1 = new CharT [rlen + 1];    dest1[rlen] = 0;
    CharT *dest2 = new CharT [rlen + 1];    dest2[rlen] = 0;

    if (pos > sv.size()) {
#ifndef TEST_HAS_NO_EXCEPTIONS
        try {
            sv.copy(dest1, n, pos);<commit_msg>Add missing include in string_view tests. Patch from <NAME> @ microsoft<commit_after>//===----------------------------------------------------------------------===//
//
//                     The LLVM Compiler Infrastructure
//
// This file is dual licensed under the MIT and the University of Illinois Open
// Source Licenses. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//

// <string_view>

// size_type copy(charT* s, size_type n, size_type pos = 0) const;

// Throws: out_of_range if pos > size().
// Remarks: Let rlen be the smaller of n and size() - pos.
// Requires: [s, s+rlen) is a valid range.
// Effects: Equivalent to std::copy_n(begin() + pos, rlen, s).
// Returns: rlen.


#include <string_view>
#include <algorithm>
#include <cassert>

#include "test_macros.h"

template<typename CharT>
void test1 ( std::basic_string_view<CharT> sv, size_t n, size_t pos ) {
    const size_t rlen = std::min ( n, sv.size() - pos );

    CharT *dest1 = new CharT [rlen + 1];    dest1[rlen] = 0;
    CharT *dest2 = new CharT [rlen + 1];    dest2[rlen] = 0;

    if (pos > sv.size()) {
#ifndef TEST_HAS_NO_EXCEPTIONS
        try {
            sv.copy(dest1, n, pos);
{'fraction_non_alphanumeric': 0.2526271542664985, 'fraction_numerical': 0.009247583018074821, 'mean_word_length': 1.8743961352657006, 'pattern_counts': {'":': 0, '<': 15, '<?xml version=': 0, '>': 19, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '978479', 'n_tokens_mistral': 774, 'n_tokens_neox': 746, 'n_words': 240}