[Spice-devel] [PATCH spice-gtk 5/5] test-session: Test invalid URIs
Pavel Grunt
pgrunt at redhat.com
Fri May 20 12:51:00 UTC 2016
---
tests/session.c | 30 ++++++++++++++++++++++++++++--
1 file changed, 28 insertions(+), 2 deletions(-)
diff --git a/tests/session.c b/tests/session.c
index 00a5a1e..eace40a 100644
--- a/tests/session.c
+++ b/tests/session.c
@@ -1,6 +1,31 @@
#include <spice-client.h>
-static void test_session_uri(void)
+static void test_session_uri_bad(void)
+{
+ SpiceSession *s;
+ guint i;
+ const gchar *invalid_uris[] = {
+ "scheme://host?port", /* invalid scheme */
+ "spice://[ipv6-host:42", /* missing closing ']' */
+ "spice://host??", /* invalid key in URI */
+ "spice://host:5900?unknown=value", /* unknown key */
+ "spice://hostname", /* missing port */
+ };
+
+ s = spice_session_new();
+
+ for (i = 0; i < G_N_ELEMENTS(invalid_uris); i++) {
+ gchar *uri = NULL;
+ g_object_set(s, "uri", invalid_uris[i], NULL);
+ g_object_get(s, "uri", &uri, NULL);
+ g_assert_null(uri);
+ g_free(uri);
+ }
+
+ g_object_unref(s);
+}
+
+static void test_session_uri_good(void)
{
SpiceSession *s;
guint i;
@@ -123,7 +148,8 @@ int main(int argc, char* argv[])
* test cases are going to test */
g_log_set_always_fatal(fatal_mask & G_LOG_LEVEL_MASK);
- g_test_add_func("/session/uri", test_session_uri);
+ g_test_add_func("/session/bad-uri", test_session_uri_bad);
+ g_test_add_func("/session/good-uri", test_session_uri_good);
return g_test_run();
}
--
2.8.2
More information about the Spice-devel
mailing list