4 #include "check_suites.h"
7 /* XCBParseDisplay tests {{{ */
9 static void parse_display_pass(const char *name, const char *host, const int display, const int screen)
13 int got_display, got_screen;
15 got_host = (char *) -1;
16 got_display = got_screen = -42;
18 success = XCBParseDisplay(name, &got_host, &got_display, &got_screen);
19 fail_unless(success, "unexpected parse failure for '%s'", name);
20 fail_unless(strcmp(host, got_host) == 0, "parse produced unexpected hostname '%s' for '%s': expected '%s'", got_host, name, host);
21 fail_unless(display == got_display, "parse produced unexpected display '%d' for '%s': expected '%d'", got_display, name, display);
22 fail_unless(screen == got_screen, "parse produced unexpected screen '%d' for '%s': expected '%d'", got_screen, name, screen);
24 got_host = (char *) -1;
25 got_display = got_screen = -42;
27 success = XCBParseDisplay(name, &got_host, &got_display, 0);
28 fail_unless(success, "unexpected screenless parse failure for '%s'", name);
29 fail_unless(strcmp(host, got_host) == 0, "screenless parse produced unexpected hostname '%s' for '%s': expected '%s'", got_host, name, host);
30 fail_unless(display == got_display, "screenless parse produced unexpected display '%d' for '%s': expected '%d'", got_display, name, display);
33 static void parse_display_fail(const char *name)
37 int got_display, got_screen;
39 got_host = (char *) -1;
40 got_display = got_screen = -42;
42 success = XCBParseDisplay(name, &got_host, &got_display, &got_screen);
43 fail_unless(!success, "unexpected parse success for '%s'", name);
44 fail_unless(got_host == (char *) -1, "host changed on failure for '%s': got %p", got_host);
45 fail_unless(got_display == -42, "display changed on failure for '%s': got %d", got_display);
46 fail_unless(got_screen == -42, "screen changed on failure for '%s': got %d", got_screen);
48 got_host = (char *) -1;
49 got_display = got_screen = -42;
51 success = XCBParseDisplay(name, &got_host, &got_display, 0);
52 fail_unless(!success, "unexpected screenless parse success for '%s'", name);
53 fail_unless(got_host == (char *) -1, "host changed on failure for '%s': got %p", got_host);
54 fail_unless(got_display == -42, "display changed on failure for '%s': got %d", got_display);
57 START_TEST(parse_display_unix)
59 parse_display_pass(":0", "", 0, 0);
60 parse_display_pass(":1", "", 1, 0);
61 parse_display_pass(":0.1", "", 0, 1);
65 START_TEST(parse_display_ip)
67 parse_display_pass("x.org:0", "x.org", 0, 0);
68 parse_display_pass("expo:0", "expo", 0, 0);
69 parse_display_pass("bigmachine:1", "bigmachine", 1, 0);
70 parse_display_pass("hydra:0.1", "hydra", 0, 1);
74 START_TEST(parse_display_ipv4)
76 parse_display_pass("198.112.45.11:0", "198.112.45.11", 0, 0);
77 parse_display_pass("198.112.45.11:0.1", "198.112.45.11", 0, 1);
81 START_TEST(parse_display_ipv6)
83 parse_display_pass("::1:0", "::1", 0, 0);
84 parse_display_pass("::1:0.1", "::1", 0, 1);
85 parse_display_pass("2002:83fc:d052::1:0", "2002:83fc:d052::1", 0, 0);
86 parse_display_pass("2002:83fc:d052::1:0.1", "2002:83fc:d052::1", 0, 1);
90 START_TEST(parse_display_decnet)
92 parse_display_pass("myws::0", "myws:", 0, 0);
93 parse_display_pass("big::1", "big:", 1, 0);
94 parse_display_pass("hydra::0.1", "hydra:", 0, 1);
98 START_TEST(parse_display_negative)
100 parse_display_fail(0);
101 parse_display_fail("");
102 parse_display_fail(":");
103 parse_display_fail("::");
104 parse_display_fail(":.");
105 parse_display_fail(":a");
106 parse_display_fail(":a.");
107 parse_display_fail(":0.");
108 parse_display_fail(":0.a");
109 parse_display_fail(":0.0.");
111 parse_display_fail("localhost");
112 parse_display_fail("localhost:");
118 Suite *public_suite(void)
120 Suite *s = suite_create("Public API");
122 suite_add_test(s, parse_display_unix, "XCBParseDisplay unix");
123 suite_add_test(s, parse_display_ip, "XCBParseDisplay ip");
124 suite_add_test(s, parse_display_ipv4, "XCBParseDisplay ipv4");
125 suite_add_test(s, parse_display_ipv6, "XCBParseDisplay ipv6");
126 suite_add_test(s, parse_display_decnet, "XCBParseDisplay decnet");
127 suite_add_test(s, parse_display_negative, "XCBParseDisplay negative");