<commit_before>/**
 * lei-stream
 * 
 * @author <NAME> <<EMAIL>>
 */

var path = require('path');
var fs = require('fs');
var stream = require('../');
var should = require('should');

describe('ReadLineStream', function () {
  
  it('#1 autoNext=false', function (done) {
    
    var counter = 0;
    var s = stream.readLine(fs.createReadStream(path.resolve(__dirname, 'files/json_small.txt')));
    s.on('data', function (data) {
      counter++;
      s.next();
    });
    s.on('end', function () {
      counter.should.equal(93);
      done();
    });
    
  });
  
  it('#2 autoNext=true', function (done) {
    
    var counter = 0;
    var s = stream.readLine(fs.createReadStream(path.resolve(__dirname, 'files/json_small.txt')), {
      autoNext: true
    });
    s.on('data', function (data) {
      counter++;
    });
    s.on('end', function () {
      counter.should.equal(93);
      done();
    });
    
  });
  
  it('#3 big file, autoNext=false', function (done) {
    
    var counter = 0;
    var s = stream.readLine(fs.createReadStream(path.resolve(__dirname, 'files/json_big.txt')));
    s.on('data', function (data) {
      counter++;
      s.next();
    });
    s.on('end', function () {
      counter.should.equal(7627);
      done();
    });
    
  });
  
});<commit_msg>完善单元测试<commit_after>/**
 * lei-stream
 * 
 * @author <NAME> <<EMAIL>>
 */

var path = require('path');
var fs = require('fs');
var stream = require('../');
var should = require('should');

describe('ReadLineStream', function () {
  
  it('#1 autoNext=false', function (done) {
    
    var counter = 0;
    var s = stream.readLine(fs.createReadStream(path.resolve(__dirname, 'files/json_small.txt')));
    s.on('data', function (data) {
      counter++;
      s.next();
    });
    s.on('end', function () {
      counter.should.equal(93);
      done();
    });
    
  });
  
  it('#2 autoNext=true', function (done) {
    
    var counter = 0;
    var s = stream.readLine(fs.createReadStream(path.resolve(__dirname, 'files/json_small.txt')), {
      autoNext: true
    });
    s.on('data', function (data) {
      counter++;
    });
    s.on('end', function () {
      counter.should.equal(93);
      done();
    });
    
  });
  
  it('#3 big file, autoNext=false', function (done) {
    
    var counter = 0;
    var s = stream.readLine(fs.createReadStream(path.resolve(__dirname, 'files/json_big.txt')));
    s.on('data', function (data) {
      counter++;
      s.next();
    });
    s.on('end', function () {
      counter.should.equal(7627);
      done();
    });
    
  });
  
  it('#4 big file, autoNext=true', function (done) {
    
    var counter = 0;
    var s = stream.readLine(fs.createReadStream(path.resolve(__dirname, 'files/json_big.txt')), {
      autoNext: true
    });
    s.on('data', function (data) {
      counter++;
    });
    s.on('end', function () {
      counter.should.equal(7627);
      done();
    });
    
  });
  
  it('#5 autoNext=true, custom encoding', function (done) {
    
    var counter = 0;
    var counter2 = 0;
    var s = stream.readLine(fs.createReadStream(path.resolve(__dirname, 'files/json_small.txt')), {
      autoNext: true,
      encoding: function (str) {
        counter2++;
        return str;
      }
    });
    s.on('data', function (data) {
      counter++;
    });
    s.on('end', function () {
      counter.should.equal(93);
      counter2.should.equal(93);
      done();
    });
    
  });
  
});
{'fraction_non_alphanumeric': 0.19340849956634865, 'fraction_numerical': 0.012720439433362244, 'mean_word_length': 2.4325396825396823, 'pattern_counts': {'":': 0, '<': 9, '<?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': '6162569', 'n_tokens_mistral': 1196, 'n_tokens_neox': 1171, 'n_words': 220}