@@ -148,3 +148,59 @@ def test_returns_failed_validation_on_invalid_ipv6_cidr_address(
148148):
149149 """Test returns failed validation on invalid ipv6 CIDR address."""
150150 assert isinstance (ipv6 (address , cidr = cidr , strict = strict , host_bit = host_bit ), ValidationError )
151+
152+
153+ @pytest .mark .parametrize (
154+ ("address" , "private" ),
155+ [
156+ ("10.1.1.1" , True ),
157+ ("192.168.1.1" , True ),
158+ ("169.254.1.1" , True ),
159+ ("127.0.0.1" , True ),
160+ ("0.0.0.0" , True ),
161+ ],
162+ )
163+ def test_returns_true_on_valid_private_ipv4_address (address : str , private : bool ):
164+ """Test returns true on private ipv4 address."""
165+ assert ipv4 (address , private = private )
166+
167+
168+ @pytest .mark .parametrize (
169+ ("address" , "private" ),
170+ [
171+ ("1.1.1.1" , True ),
172+ ("192.169.1.1" , True ),
173+ ("7.53.12.1" , True ),
174+ ],
175+ )
176+ def test_returns_failed_validation_on_invalid_private_ipv4_address (address : str , private : bool ):
177+ """Test returns failed validation on invalid private ipv4 address."""
178+ assert isinstance (ipv4 (address , private = private ), ValidationError )
179+
180+
181+ @pytest .mark .parametrize (
182+ ("address" , "private" ),
183+ [
184+ ("1.1.1.1" , False ),
185+ ("192.169.1.1" , False ),
186+ ("7.53.12.1" , False ),
187+ ],
188+ )
189+ def test_returns_true_on_valid_public_ipv4_address (address : str , private : bool ):
190+ """Test returns true on valid public ipv4 address."""
191+ assert ipv4 (address , private = private )
192+
193+
194+ @pytest .mark .parametrize (
195+ ("address" , "private" ),
196+ [
197+ ("10.1.1.1" , False ),
198+ ("192.168.1.1" , False ),
199+ ("169.254.1.1" , False ),
200+ ("127.0.0.1" , False ),
201+ ("0.0.0.0" , False ),
202+ ],
203+ )
204+ def test_returns_failed_validation_on_invalid_public_ipv4_address (address : str , private : bool ):
205+ """Test returns failed validation on private ipv4 address."""
206+ assert isinstance (ipv4 (address , private = private ), ValidationError )
0 commit comments