From 4b1dfaf4e8b6bcbaadc5563f7900f131d305b9d6 Mon Sep 17 00:00:00 2001 From: Jean-Marcel Flach Date: Fri, 10 Jul 2015 14:08:35 +0200 Subject: [PATCH] Add additional tests for urls refs #9470 --- test/base-url.cpp | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/test/base-url.cpp b/test/base-url.cpp index 28d822967..301cb238d 100644 --- a/test/base-url.cpp +++ b/test/base-url.cpp @@ -24,6 +24,9 @@ using namespace icinga; +#define VALID(X) BOOST_CHECK(new Url(X)) +#define INVALID(X) BOOST_CHECK_THROW(new Url(X), std::invalid_argument) + BOOST_AUTO_TEST_SUITE(base_url) BOOST_AUTO_TEST_CASE(id_and_path) @@ -71,13 +74,12 @@ BOOST_AUTO_TEST_CASE(format) BOOST_AUTO_TEST_CASE(illegal_legal_strings) { - BOOST_CHECK_THROW(new Url("/?foo=barr&foo[]=bazz"), std::invalid_argument); - BOOST_CHECK_THROW(new Url("/?]=gar"), std::invalid_argument); - BOOST_CHECK(new Url("/?foo=baz??&\?\?=/?")); //Valid - BOOST_CHECK_THROW(new Url("/?foo=bar&foo=ba"), std::invalid_argument); - BOOST_CHECK(new Url("/")); - BOOST_CHECK_THROW(new Url("/?foo=bar&[]=d"), std::invalid_argument); - BOOST_CHECK_THROW(new Url("/?fo=&bar=garOA"), std::invalid_argument); + INVALID("/?foo=barr&foo[]=bazz"); VALID("/?foo=baz??&\?\?=/?"); + INVALID("/?]=gar"); VALID("/"); + INVALID("/#?[]"); VALID("///////"); + INVALID("/?foo=bar&foo=ba"); VALID("/??[]=?#?=?"); + INVALID("/?foo=bar&[]=d"); VALID("http://foo/#bar"); + INVALID("/?fo=&bar=garOA"); VALID("//foo/"); } BOOST_AUTO_TEST_SUITE_END() -- 2.40.0