<commit_before>'use strict';
var test = require('tape');
var dnsQuery = require('../../../app/scripts/dnssd/dns-query');

test('create a query', function(t) {
  var name = 'www.example.com';
  var queryType = 3;
  var queryClass = 4;
  // // Corresponds to 172.16.31.10
  // var ipAddress = 0x9b211144;

  var result = new dnsQuery.DnsQuery(name, queryType, queryClass);

  t.equal(result.domainName, name);
  t.equal(result.queryType, queryType);
  t.equal(result.queryClass, queryClass);

  t.end();
});

test('serializes and deserializes correctly', function(t) {
  var domainName = '_semcache._http.local';
  var queryType = 1;
  var queryClass = 2;

  var expected = new dnsQuery.DnsQuery(domainName, queryType, queryClass);

  var serialized = expected.serialize();

  var actual = dnsQuery.createQueryFromByteArray(serialized);

  t.deepEqual(actual, expected);
  t.end(); 
});<commit_msg>Remove dead code and add test for startbyte != 0<commit_after>'use strict';
var test = require('tape');
var dnsQuery = require('../../../app/scripts/dnssd/dns-query');
var byteArray = require('../../../app/scripts/dnssd/byte-array');

test('create a query', function(t) {
  var name = 'www.example.com';
  var queryType = 3;
  var queryClass = 4;

  var result = new dnsQuery.DnsQuery(name, queryType, queryClass);

  t.equal(result.domainName, name);
  t.equal(result.queryType, queryType);
  t.equal(result.queryClass, queryClass);

  t.end();
});

test('serializes and deserializes correctly', function(t) {
  var domainName = '_semcache._http.local';
  var queryType = 1;
  var queryClass = 2;

  var expected = new dnsQuery.DnsQuery(domainName, queryType, queryClass);

  var serialized = expected.serialize();

  var actual = dnsQuery.createQueryFromByteArray(serialized);

  t.deepEqual(actual, expected);
  t.end(); 
});

test('createQueryFromByteArray succeeds when startByte != 0', function(t) {
  var expected = new dnsQuery.DnsQuery('mydomain.local', 1, 2);
  var serialized = expected.serialize();

  var byteArr = new byteArray.ByteArray();

  // Add 5 meaningless bytes.
  var offset = 5;
  for (var i = 0; i < offset; i++) {
    byteArr.push(i, 1);
  }

  byteArr.append(serialized);

  var actual = dnsQuery.createQueryFromByteArray(byteArr, offset);
  t.deepEqual(actual, expected);
  t.end();
});
{'fraction_non_alphanumeric': 0.1536131544785807, 'fraction_numerical': 0.014279532669839896, 'mean_word_length': 4.149220489977728, 'pattern_counts': {'":': 0, '<': 4, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 1, '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': '4660926', 'n_tokens_mistral': 812, 'n_tokens_neox': 763, 'n_words': 186}