mirror of
https://github.com/CorentinTh/it-tools.git
synced 2025-04-29 10:59:12 -04:00
fix(ipv4-range-expander): calculate correct for ip addresses where the first octet is lower than 128 (#405)
This commit is contained in:
parent
7aed9c56fd
commit
8c92d56318
3 changed files with 27 additions and 2 deletions
|
@ -14,6 +14,17 @@ describe('ipv4RangeExpander', () => {
|
|||
expect(result?.newCidr).toEqual('192.168.0.0/21');
|
||||
});
|
||||
|
||||
it('should calculate valid cidr for given addresses, where first octet is lower than 128', () => {
|
||||
const result = calculateCidr({ startIp: '10.0.0.1', endIp: '10.0.0.17' });
|
||||
|
||||
expect(result).toBeDefined();
|
||||
expect(result?.oldSize).toEqual(17);
|
||||
expect(result?.newSize).toEqual(32);
|
||||
expect(result?.newStart).toEqual('10.0.0.0');
|
||||
expect(result?.newEnd).toEqual('10.0.0.31');
|
||||
expect(result?.newCidr).toEqual('10.0.0.0/27');
|
||||
});
|
||||
|
||||
it('should return empty result for invalid input', () => {
|
||||
expect(calculateCidr({ startIp: '192.168.7.1', endIp: '192.168.6.255' })).not.toBeDefined();
|
||||
});
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue