@@ -476,6 +476,46 @@ LT_BEGIN_AUTO_TEST(http_utils_suite, load_file_invalid)
476476 LT_CHECK_THROW(http::load_file(" test_content_invalid" ));
477477LT_END_AUTO_TEST (load_file_invalid)
478478
479+ LT_BEGIN_AUTO_TEST(http_utils_suite, ip_representation_less_than)
480+ LT_CHECK_EQ(http::ip_representation(" 127.0.0.1" ) < http::ip_representation(" 127.0.0.2" ), true);
481+ LT_CHECK_EQ (http::ip_representation(" 128.0.0.1" ) < http::ip_representation(" 127.0.0.2" ), false);
482+ LT_CHECK_EQ (http::ip_representation(" 127.0.0.2" ) < http::ip_representation(" 127.0.0.1" ), false);
483+ LT_CHECK_EQ (http::ip_representation(" 127.0.0.1" ) < http::ip_representation(" 127.0.0.1" ), false);
484+ LT_CHECK_EQ (http::ip_representation(" 127.0.0.1" ) < http::ip_representation(" 127.0.0.1" ), false);
485+
486+ LT_CHECK_EQ (http::ip_representation(" 2001:db8::ff00:42:8329" ) < http::ip_representation(" 2001:db8::ff00:42:8329" ), false);
487+ LT_CHECK_EQ (http::ip_representation(" 2001:db8::ff00:42:8330" ) < http::ip_representation(" 2001:db8::ff00:42:8329" ), false);
488+ LT_CHECK_EQ (http::ip_representation(" 2001:db8::ff00:42:8329" ) < http::ip_representation(" 2001:db8::ff00:42:8330" ), true);
489+ LT_CHECK_EQ (http::ip_representation(" 2002:db8::ff00:42:8329" ) < http::ip_representation(" 2001:db8::ff00:42:8330" ), false);
490+
491+ LT_CHECK_EQ (http::ip_representation(" ::192.0.2.128" ) < http::ip_representation(" ::192.0.2.128" ), false);
492+ LT_CHECK_EQ (http::ip_representation(" ::192.0.2.129" ) < http::ip_representation(" ::192.0.2.128" ), false);
493+ LT_CHECK_EQ (http::ip_representation(" ::192.0.2.128" ) < http::ip_representation(" ::192.0.2.129" ), true);
494+
495+ LT_CHECK_EQ (http::ip_representation(" ::ffff:192.0.2.128" ) < http::ip_representation(" ::ffff:192.0.2.128" ), false);
496+ LT_CHECK_EQ (http::ip_representation(" ::ffff:192.0.2.129" ) < http::ip_representation(" ::ffff:192.0.2.128" ), false);
497+ LT_CHECK_EQ (http::ip_representation(" ::ffff:192.0.2.128" ) < http::ip_representation(" ::ffff:192.0.2.129" ), true);
498+
499+ LT_CHECK_EQ (http::ip_representation(" ::ffff:192.0.2.128" ) < http::ip_representation(" ::192.0.2.128" ), false);
500+ LT_CHECK_EQ (http::ip_representation(" ::ffff:192.0.2.128" ) < http::ip_representation(" ::192.0.2.128" ), false);
501+ LT_CHECK_EQ (http::ip_representation(" ::192.0.2.128" ) < http::ip_representation(" ::ffff:192.0.2.129" ), true);
502+ LT_END_AUTO_TEST (ip_representation_less_than)
503+
504+ LT_BEGIN_AUTO_TEST(http_utils_suite, ip_representation_less_than_with_masks)
505+ LT_CHECK_EQ(http::ip_representation(" 127.0.*.*" ) < http::ip_representation(" 127.0.0.1" ), false);
506+ LT_CHECK_EQ (http::ip_representation(" 127.0.0.1" ) < http::ip_representation(" 127.0.*.*" ), false);
507+ LT_CHECK_EQ (http::ip_representation(" 127.0.0.*" ) < http::ip_representation(" 127.0.*.*" ), false);
508+ LT_CHECK_EQ (http::ip_representation(" 127.0.*.1" ) < http::ip_representation(" 127.0.0.1" ), false);
509+ LT_CHECK_EQ (http::ip_representation(" 127.0.0.1" ) < http::ip_representation(" 127.0.*.1" ), false);
510+ LT_CHECK_EQ (http::ip_representation(" 127.1.0.1" ) < http::ip_representation(" 127.0.*.1" ), false);
511+ LT_CHECK_EQ (http::ip_representation(" 127.0.*.1" ) < http::ip_representation(" 127.1.0.1" ), true);
512+ LT_CHECK_EQ (http::ip_representation(" 127.1.*.1" ) < http::ip_representation(" 127.0.*.1" ), false);
513+ LT_CHECK_EQ (http::ip_representation(" 127.0.*.1" ) < http::ip_representation(" 127.1.*.1" ), true);
514+
515+ LT_CHECK_EQ (http::ip_representation(" 2001:db8::ff00:42:*" ) < http::ip_representation(" 2001:db8::ff00:42:8329" ), false);
516+ LT_CHECK_EQ (http::ip_representation(" 2001:db8::ff00:42:8329" ) < http::ip_representation(" 2001:db8::ff00:42:*" ), false);
517+ LT_END_AUTO_TEST (ip_representation_less_than_with_masks)
518+
479519LT_BEGIN_AUTO_TEST_ENV()
480520 AUTORUN_TESTS()
481521LT_END_AUTO_TEST_ENV()
0 commit comments