<commit_before>var Packet = require('../src/packet').Packet,
    toArray = require('../src/buffer-util').toArray;

exports.PacketFromBuffer = function(test){
  var type = 0x12,
      packet = new Packet(new Buffer([type, 0x01, 0x00, 0x0a, 0x00, 0x00, 0x00, 0x00, 0x55, 0xff])),
      buffer = packet.buffer;

  test.equal(buffer.length, 10, 'length');
  
  test.done();
};

exports.BuildPacketLast = function(test){
  var data = [0x55, 0xff],
      type = 0x12,
      packet = new Packet(type, data, {last: true}),
      buffer = packet.buffer;

  test.equal(buffer.length, 10, 'length');

  test.deepEqual(toArray(buffer.slice(0, 8)), [type, 0x01, 0x00, 0x0a, 0x00, 0x00, 0x00, 0x00], 'header');
  test.deepEqual(toArray(buffer.slice(8)), data, 'data');
  
  test.done();
};

exports.BuildPacketNonLast = function(test){
  var data = [0x55, 0xff],
      type = 0x12,
      packet = new Packet(type, data),
      buffer = packet.buffer;

  test.equal(buffer.length, 10, 'length');

  test.deepEqual(toArray(buffer.slice(0, 8)), [type, 0x00, 0x00, 0x0a, 0x00, 0x00, 0x00, 0x00], 'header');
  test.deepEqual(toArray(buffer.slice(8)), data, 'data');
  
  test.done();
};

exports.DecodePacket = function(test){
  var data = [0x55, 0xff],
      type = 0x12,
      packet = new Packet(type, data, {last: true}),
      decoded = packet.decode();
  
  test.equal(decoded.header.type, 0x12, 'type');
  test.equal(decoded.header.status, 0x01, 'status');
  test.equal(decoded.header.length, 0x000a, 'length');
  test.equal(decoded.header.spid, 0x0000, 'spid');
  test.equal(decoded.header.packetId, 0x00, 'packetId');
  test.equal(decoded.header.window, 0x00, 'window');
  
  test.deepEqual(toArray(decoded.data), data, 'data');
  test.done();
};

exports.ToString = function(test) {
  var data = [0x55, 0xff],
      type = 0x12,
      packet = new Packet(type, data, {last: true}),
      packetString = packet.toString();

  console.log(packetString);
  
  test.ok(packetString.indexOf('PRELOGIN') !== -1);
  test.ok(packetString.indexOf('0000  55FF') !== -1);
  
  test.done();
};
<commit_msg>Comment console log.<commit_after>var Packet = require('../src/packet').Packet,
    toArray = require('../src/buffer-util').toArray;

exports.PacketFromBuffer = function(test){
  var type = 0x12,
      packet = new Packet(new Buffer([type, 0x01, 0x00, 0x0a, 0x00, 0x00, 0x00, 0x00, 0x55, 0xff])),
      buffer = packet.buffer;

  test.equal(buffer.length, 10, 'length');
  
  test.done();
};

exports.BuildPacketLast = function(test){
  var data = [0x55, 0xff],
      type = 0x12,
      packet = new Packet(type, data, {last: true}),
      buffer = packet.buffer;

  test.equal(buffer.length, 10, 'length');

  test.deepEqual(toArray(buffer.slice(0, 8)), [type, 0x01, 0x00, 0x0a, 0x00, 0x00, 0x00, 0x00], 'header');
  test.deepEqual(toArray(buffer.slice(8)), data, 'data');
  
  test.done();
};

exports.BuildPacketNonLast = function(test){
  var data = [0x55, 0xff],
      type = 0x12,
      packet = new Packet(type, data),
      buffer = packet.buffer;

  test.equal(buffer.length, 10, 'length');

  test.deepEqual(toArray(buffer.slice(0, 8)), [type, 0x00, 0x00, 0x0a, 0x00, 0x00, 0x00, 0x00], 'header');
  test.deepEqual(toArray(buffer.slice(8)), data, 'data');
  
  test.done();
};

exports.DecodePacket = function(test){
  var data = [0x55, 0xff],
      type = 0x12,
      packet = new Packet(type, data, {last: true}),
      decoded = packet.decode();
  
  test.equal(decoded.header.type, 0x12, 'type');
  test.equal(decoded.header.status, 0x01, 'status');
  test.equal(decoded.header.length, 0x000a, 'length');
  test.equal(decoded.header.spid, 0x0000, 'spid');
  test.equal(decoded.header.packetId, 0x00, 'packetId');
  test.equal(decoded.header.window, 0x00, 'window');
  
  test.deepEqual(toArray(decoded.data), data, 'data');
  test.done();
};

exports.ToString = function(test) {
  var data = [0x55, 0xff],
      type = 0x12,
      packet = new Packet(type, data, {last: true}),
      packetString = packet.toString();

  //console.log(packetString);
  
  test.ok(packetString.indexOf('PRELOGIN') !== -1);
  test.ok(packetString.indexOf('0000  55FF') !== -1);
  
  test.done();
};

{'fraction_non_alphanumeric': 0.18210098109595596, 'fraction_numerical': 0.06508734146925102, 'mean_word_length': 3.8045977011494254, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, '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': '3264124', 'n_tokens_mistral': 1762, 'n_tokens_neox': 1563, 'n_words': 314}