<commit_before>'use strict';

var assert = require('assert')
  , Addr = require('../lib/addrv4').Addr
  ;

describe('addrv4', function(){
  describe('#octets', function(){
    describe('with a string', function(){
      it('returns the parsed octets', function(){
        assert.deepEqual([10, 0, 52, 138], new Addr('10.0.52.138').octets);
      });
    });

    describe('with a number', function(){
      it('returns the computed octets', function(){<commit_msg>Add tests for validation.<commit_after>'use strict';

var assert = require('assert')
  , Addr = require('../lib/addrv4').Addr
  ;

describe('addrv4', function(){
  describe('constructor', function(){
    describe('with a valid dotted IP', function(){
      it('succeeds', function(){
        assert(new Addr('1.1.1.1'));
      });
    });

    describe('with a valid CIDR', function(){
      it('succeeds', function(){
        assert(new Addr('1.1.1.1/8'));
      });
    });

    describe('with a valid integer', function(){
      it('succeeds', function(){
        assert(new Addr(128));
      });
    });

    describe('with an invalid byte', function(){
      it('throws an error', function(){
        assert.throws(function(){ new Addr('1.256.1.1'); });
      });
    });

    describe('with a cidr prefix out of range', function(){
      it('throws an error', function(){
        assert.throws(function(){ new Addr('1.1.1.1/35'); });
      });
    });

    describe('with a negative integer', function(){
      it('throws an error', function(){
        assert.throws(function(){ new Addr(-128); });
      });
    });

    describe('with a 64 bit integer', function(){
      it('throws an error', function(){
        assert.throws(function(){ new Addr(0xFFFFFFFF + 1); });
      });
    });

    describe('with a negative prefix', function(){
      it('throws an error', function(){
        assert.throws(function(){ new Addr(256, -24); });
      });
    });

    describe('with a prefix more than 32 bits', function(){
      it('throws an error', function(){
        assert.throws(function(){ new Addr(256, 35); });
      });
    });
  });

  describe('#octets', function(){
    describe('with a string', function(){
      it('returns the parsed octets', function(){
        assert.deepEqual([10, 0, 52, 138], new Addr('10.0.52.138').octets);
      });
    });

    describe('with a number', function(){
      it('returns the computed octets', function(){
{'fraction_non_alphanumeric': 0.19752577319587628, 'fraction_numerical': 0.03257731958762886, 'mean_word_length': 2.8878205128205128, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 5, 'substrings_counts': 1, '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': '4850885', 'n_tokens_mistral': 762, 'n_tokens_neox': 702, 'n_words': 184}