-
- got_host = (char *) -1;
- got_display = got_screen = -42;
- mark_point();
- success = xcb_parse_display(name, &got_host, &got_display, &got_screen);
- fail_unless(success, "unexpected parse failure for '%s'", name);
- fail_unless(strcmp(host, got_host) == 0, "parse produced unexpected hostname '%s' for '%s': expected '%s'", got_host, name, host);
- fail_unless(display == got_display, "parse produced unexpected display '%d' for '%s': expected '%d'", got_display, name, display);
- fail_unless(screen == got_screen, "parse produced unexpected screen '%d' for '%s': expected '%d'", got_screen, name, screen);
-
- got_host = (char *) -1;
- got_display = got_screen = -42;
- mark_point();
- success = xcb_parse_display(name, &got_host, &got_display, 0);
- fail_unless(success, "unexpected screenless parse failure for '%s'", name);
- fail_unless(strcmp(host, got_host) == 0, "screenless parse produced unexpected hostname '%s' for '%s': expected '%s'", got_host, name, host);
- fail_unless(display == got_display, "screenless parse produced unexpected display '%d' for '%s': expected '%d'", got_display, name, display);
+ const char *argument = 0;
+ test_type_t test_type;
+
+ for(test_type = TEST_ARGUMENT; test_type != TEST_END; test_type++)
+ {
+ if(test_type == TEST_ARGUMENT)
+ {
+ argument = name;
+ putenv("DISPLAY=");
+ }
+ else if(test_type == TEST_ENVIRONMENT)
+ {
+ argument = 0;
+ setenv("DISPLAY", name, 1);
+ }
+
+ got_host = (char *) -1;
+ got_display = got_screen = -42;
+ mark_point();
+ success = xcb_parse_display(argument, &got_host, &got_display, &got_screen);
+ fail_unless(success, "unexpected parse failure %sfor '%s'", test_string[test_type], name);
+ fail_unless(strcmp(host, got_host) == 0, "parse %sproduced unexpected hostname '%s' for '%s': expected '%s'", test_string[test_type], got_host, name, host);
+ fail_unless(display == got_display, "parse %sproduced unexpected display '%d' for '%s': expected '%d'", test_string[test_type], got_display, name, display);
+ fail_unless(screen == got_screen, "parse %sproduced unexpected screen '%d' for '%s': expected '%d'", test_string[test_type], got_screen, name, screen);
+
+ got_host = (char *) -1;
+ got_display = got_screen = -42;
+ mark_point();
+ success = xcb_parse_display(argument, &got_host, &got_display, 0);
+ fail_unless(success, "unexpected screenless parse failure %sfor '%s'", test_string[test_type], name);
+ fail_unless(strcmp(host, got_host) == 0, "screenless parse %sproduced unexpected hostname '%s' for '%s': expected '%s'", test_string[test_type], got_host, name, host);
+ fail_unless(display == got_display, "screenless parse %sproduced unexpected display '%d' for '%s': expected '%d'", test_string[test_type], got_display, name, display);
+ }
+ putenv("DISPLAY=");