<commit_before>// Copyright (c) 2016, <NAME>. All rights reserved. Use of this source
// code is governed by a BSD-style license that can be found in the LICENSE
// file.

import 'package:test/test.dart';

import 'package:html_unescape/html_unescape.dart' as lib_full;
import 'package:html_unescape/html_unescape_small.dart' as lib_small;
import 'package:html_unescape/src/base.dart' show HtmlUnescapeBase;

void main() {
  group("Full", () {
    runTests(() => new lib_full.HtmlUnescape());
  });
  group("Small", () {
    runTests(() => new lib_small.HtmlUnescape());
  });

  // TODO: add async tests for chunked conversion
}

void runTests(ConverterFactory converterFactory) {
  test('leaves empty string alone', () {
    final unescape = converterFactory();

    expect(unescape.convert(""), "");
  });
<commit_msg>Add test for chunked conversion<commit_after>// Copyright (c) 2016, <NAME>. All rights reserved. Use of this source
// code is governed by a BSD-style license that can be found in the LICENSE
// file.

import 'dart:async';
import 'dart:convert';

import 'package:html_unescape/html_unescape.dart' as lib_full;
import 'package:html_unescape/html_unescape_small.dart' as lib_small;
import 'package:html_unescape/src/base.dart' show HtmlUnescapeBase;
import 'package:test/test.dart';

void main() {
  group("Full", () {
    runTests(() => new lib_full.HtmlUnescape());
  });
  group("Small", () {
    runTests(() => new lib_small.HtmlUnescape());
  });

  test("converts in chunks", () async {
    var unescape = new lib_full.HtmlUnescape();

    var stream = new Stream.fromIterable(
        ['This is &quot;awesome&qu'.codeUnits, 'ot;.'.codeUnits]);
    expect(stream.transform(UTF8.decoder).transform(unescape).first,
        completion('This is "awesome".'));
  });
}

void runTests(ConverterFactory converterFactory) {
  test('leaves empty string alone', () {
    final unescape = converterFactory();

    expect(unescape.convert(""), "");
  });

{'fraction_non_alphanumeric': 0.14939024390243902, 'fraction_numerical': 0.004573170731707317, 'mean_word_length': 4.454293628808864, 'pattern_counts': {'":': 0, '<': 5, '<?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': '873924', 'n_tokens_mistral': 634, 'n_tokens_neox': 632, 'n_words': 159}