tests: Extend rygel-http-item-uri-test.vala
authorMarcin Kazmierczak <marcin.kazmierczak@comarch.com>
Thu, 22 Dec 2011 09:52:34 +0000 (10:52 +0100)
committerJens Georg <mail@jensge.org>
Thu, 22 Dec 2011 11:24:28 +0000 (12:24 +0100)
New test case with incorrect url.

tests/rygel-http-item-uri-test.vala

index 6c86ddb..f79295a 100644 (file)
@@ -88,6 +88,7 @@ private class Rygel.HTTPItemURITest : GLib.Object {
             var str = this.test_to_string (uri);
             this.test_construction_from_string (str);
         }
+        this.test_error_construction ("/Ttt", Soup.KnownStatusCode.BAD_REQUEST);
     }
 
     private HTTPItemURITest () throws TestError {
@@ -140,6 +141,16 @@ private class Rygel.HTTPItemURITest : GLib.Object {
         return uri;
     }
 
+    private void test_error_construction (string str,
+                                          Soup.KnownStatusCode error_code) {
+        try {
+            var uri = new HTTPItemURI.from_string (str, this.server);
+            assert (uri == null);
+        } catch (HTTPRequestError error) {
+            assert (error.code == error_code);
+        }
+    }
+
     private string test_to_string (HTTPItemURI uri) {
         var str = uri.to_string ();
         assert (str != null);