mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-12-08 06:09:58 +00:00
AK: Add IPv4Address::netmask_from_cidr
This commit is contained in:
parent
b85666b3d2
commit
36676a1604
Notes:
sideshowbarker
2024-07-17 10:10:18 +09:00
Author: https://github.com/sppmacd
Commit: 36676a1604
Pull-request: https://github.com/SerenityOS/serenity/pull/13259
Reviewed-by: https://github.com/AtkinsSJ ✅
Reviewed-by: https://github.com/IdanHo
2 changed files with 21 additions and 1 deletions
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright (c) 2020, the SerenityOS developers.
|
||||
* Copyright (c) 2020-2022, the SerenityOS developers.
|
||||
*
|
||||
* SPDX-License-Identifier: BSD-2-Clause
|
||||
*/
|
||||
|
|
@ -151,3 +151,16 @@ TEST_CASE(should_compare)
|
|||
EXPECT(addr_a != addr_b);
|
||||
EXPECT(addr_a == addr_a);
|
||||
}
|
||||
|
||||
TEST_CASE(netmask_from_cidr)
|
||||
{
|
||||
EXPECT(IPv4Address::netmask_from_cidr(24) == IPv4Address(255, 255, 255, 0));
|
||||
|
||||
EXPECT(IPv4Address::netmask_from_cidr(0) == IPv4Address(0, 0, 0, 0));
|
||||
EXPECT(IPv4Address::netmask_from_cidr(32) == IPv4Address(255, 255, 255, 255));
|
||||
|
||||
EXPECT(IPv4Address::netmask_from_cidr(28) == IPv4Address(255, 255, 255, 240));
|
||||
EXPECT(IPv4Address::netmask_from_cidr(22) == IPv4Address(255, 255, 252, 0));
|
||||
EXPECT(IPv4Address::netmask_from_cidr(14) == IPv4Address(255, 252, 0, 0));
|
||||
EXPECT(IPv4Address::netmask_from_cidr(6) == IPv4Address(252, 0, 0, 0));
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue