@@ -237,7 +237,7 @@ LT_BEGIN_AUTO_TEST(http_utils_suite, ip_representation6_str_mask)
237237 LT_CHECK_EQ (test_ip.pieces[14 ], 0 );
238238 LT_CHECK_EQ (test_ip.pieces[15 ], 0 );
239239
240- LT_CHECK_EQ (test_ip.mask, 0xFCFF );
240+ LT_CHECK_EQ (test_ip.mask, 0xF0FF );
241241LT_END_AUTO_TEST (ip_representation6_str_mask)
242242
243243LT_BEGIN_AUTO_TEST(http_utils_suite, ip_representation6_str_nested)
@@ -366,6 +366,17 @@ LT_BEGIN_AUTO_TEST(http_utils_suite, ip_representation6_str_loopback)
366366 LT_CHECK_EQ (test_ip.mask, 0xFFFF );
367367LT_END_AUTO_TEST (ip_representation6_str_loopback)
368368
369+ LT_BEGIN_AUTO_TEST(http_utils_suite, ip_representation_weight)
370+ LT_CHECK_EQ(http::ip_representation(" ::1" ).weight(), 16);
371+ LT_CHECK_EQ (http::ip_representation(" 192.168.0.1" ).weight(), 16);
372+ LT_CHECK_EQ (http::ip_representation(" 192.168.*.*" ).weight(), 14);
373+ LT_CHECK_EQ (http::ip_representation(" ::ffff:192.0.*.*" ).weight(), 14);
374+ LT_CHECK_EQ (http::ip_representation(" 2001:db8:8714:3a90:*:*" ).weight(), 12);
375+ LT_CHECK_EQ (http::ip_representation(" 2001:db8:8714:3a90:8714:2001:db8:3a90" ).weight(), 16);
376+ LT_CHECK_EQ (http::ip_representation(" 2001:db8:8714:3a90:8714:2001:*:*" ).weight(), 12);
377+ LT_CHECK_EQ (http::ip_representation(" *:*:*:*:*:*:*:*" ).weight(), 0);
378+ LT_END_AUTO_TEST (ip_representation_weight)
379+
369380LT_BEGIN_AUTO_TEST(http_utils_suite, ip_representation6_str_invalid)
370381 LT_CHECK_THROW(http::ip_representation(" 2001:db8:8714:3a90::12:4:4:4" ));
371382LT_END_AUTO_TEST (ip_representation6_str_invalid)
0 commit comments