<commit_before>import test from 'ava'
import singleTrailingNewline from './'

const strings = [
  'foo\nbar',
  'foo\nbar\n',
  'foo\nbar\n\n',
  'foo\nbar\n\r\n',
  'foo\nbar\n\n\n\r\n\r\n'
]

const carriageReturnStrings = [
  'foo\r\nbar',
  'foo\r\nbar\r\n',
  'foo\r\nbar\r\n\r\n',
  'foo\r\nbar\n\r\n',
  'foo\nbar\r\n\r\n'
]

test('single-trailing-newline detects \\n strings and ensures only one trailing newline', t => {
  t.plan(strings.length)

  strings.forEach(str => {
    t.same(singleTrailingNewline(str), 'foo\nbar\n')
  })
})<commit_msg>Add \r\n tests<commit_after>import test from 'ava'
import singleTrailingNewline from './'

const strings = [
  'foo\nbar',
  'foo\nbar\n',
  'foo\nbar\n\n',
  'foo\nbar\n\r\n',
  'foo\nbar\n\n\n\r\n\r\n'
]

const carriageReturnStrings = [
  'foo\r\nbar',
  'foo\r\nbar\r\n',
  'foo\r\nbar\r\n\r\n',
  'foo\r\nbar\n\r\n',
  'foo\r\nbar\r\n\r\n'
]

test('single-trailing-newline detects \\n strings and ensures only one trailing newline', t => {
  t.plan(strings.length)

  strings.forEach(str => {
    t.same(singleTrailingNewline(str), 'foo\nbar\n')
  })
})

test('single-trailing-newline detects \\r\\n strings and ensures only one trailing newline', t => {
  t.plan(carriageReturnStrings.length)

  carriageReturnStrings.forEach(str => {
    t.same(singleTrailingNewline(str), 'foo\r\nbar\r\n')
  })
})
{'fraction_non_alphanumeric': 0.2025036818851252, 'fraction_numerical': 0.0, 'mean_word_length': 3.2336448598130842, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 9, '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': '1381937', 'n_tokens_mistral': 605, 'n_tokens_neox': 599, 'n_words': 89}