Example #1
0
  it('toString()', function () {
    let mask = new CidrMask('.../1');
    expect(mask.toString()).to.be('0.0.0.0/1');

    mask = new CidrMask('128.0.0.1/31');
    expect(mask.toString()).to.be('128.0.0.1/31');
  });
Example #2
0
  it('should calculate a range of IP addresses', function () {
    let mask = new CidrMask('0.0.0.0/1');
    let range = mask.getRange();
    expect(range.from.toString()).to.be('0.0.0.0');
    expect(range.to.toString()).to.be('127.255.255.255');

    mask = new CidrMask('1.2.3.4/2');
    range = mask.getRange();
    expect(range.from.toString()).to.be('0.0.0.0');
    expect(range.to.toString()).to.be('63.255.255.255');

    mask = new CidrMask('67.129.65.201/27');
    range = mask.getRange();
    expect(range.from.toString()).to.be('67.129.65.192');
    expect(range.to.toString()).to.be('67.129.65.223');
  });