aboutsummaryrefslogtreecommitdiff
path: root/libxcb/tests
diff options
context:
space:
mode:
Diffstat (limited to 'libxcb/tests')
-rw-r--r--libxcb/tests/.gitignore3
-rw-r--r--libxcb/tests/CheckLog.xsl208
-rw-r--r--libxcb/tests/Makefile.am64
-rw-r--r--libxcb/tests/check_all.c40
-rw-r--r--libxcb/tests/check_public.c436
-rw-r--r--libxcb/tests/check_suites.h8
6 files changed, 381 insertions, 378 deletions
diff --git a/libxcb/tests/.gitignore b/libxcb/tests/.gitignore
new file mode 100644
index 000000000..58b019a02
--- /dev/null
+++ b/libxcb/tests/.gitignore
@@ -0,0 +1,3 @@
+CheckLog.html
+CheckLog_xcb.xml
+check_all
diff --git a/libxcb/tests/CheckLog.xsl b/libxcb/tests/CheckLog.xsl
index 3daebaa5d..75b14e694 100644
--- a/libxcb/tests/CheckLog.xsl
+++ b/libxcb/tests/CheckLog.xsl
@@ -1,104 +1,104 @@
-<?xml version="1.0" encoding="UTF-8"?>
-
-<xsl:stylesheet
- version="1.0"
- xmlns:check="http://check.sourceforge.net/ns"
- xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
- xmlns="http://www.w3.org/TR/REC-html40">
-
-<xsl:output method="html"/>
-
-<xsl:template match="/">
-<html>
- <head>
- <title>Test Suite Results</title>
- </head>
-
- <body>
- <xsl:apply-templates/>
- </body>
-</html>
-</xsl:template>
-
-<xsl:template match="datetime">
- <xsl:apply-templates/>
-</xsl:template>
-
-<xsl:template match="duration">
- <xsl:apply-templates/>
-</xsl:template>
-
-<xsl:template match="check:suite">
- <xsl:apply-templates select="check:title"/>
- <center>
- <table width="80%" border="1">
- <thead>
- <tr>
- <td>Test Path</td>
- <td>Test Function Location</td>
- <td>C Identifier</td>
- <td>Test Case</td>
- <td>Result</td>
- </tr>
- </thead>
- <tbody>
- <xsl:apply-templates select="check:test"/>
- </tbody>
- </table>
- </center>
-</xsl:template>
-
-<xsl:template match="check:testsuites">
- <xsl:apply-templates select="check:suite"/>
- <h3>Unit Test Statistics</h3>
- <ul>
- <li>date/time: <xsl:apply-templates select="check:datetime"/></li>
- <li>duration: <xsl:apply-templates select="check:duration"/></li>
- </ul>
- <hr></hr>
-</xsl:template>
-
-<xsl:template match="check:title">
- <h2>Test Suite: <xsl:apply-templates/></h2>
-</xsl:template>
-
-<xsl:template match="check:test[@result='success']">
- <tr bgcolor="lime">
- <xsl:apply-templates/>
- </tr>
-</xsl:template>
-
-<xsl:template match="check:test[@result='failure']">
- <tr bgcolor="red">
- <xsl:apply-templates/>
- </tr>
-</xsl:template>
-
-<xsl:template match="check:test[@result='error']">
- <tr bgcolor="yellow">
- <xsl:apply-templates/>
- </tr>
-</xsl:template>
-
-<xsl:template match="check:path">
- <td><xsl:apply-templates/></td>
-</xsl:template>
-
-<xsl:template match="check:fn">
- <td><xsl:apply-templates/></td>
-</xsl:template>
-
-<xsl:template match="check:id">
- <td><xsl:apply-templates/></td>
-</xsl:template>
-
-<xsl:template match="check:description">
- <td><xsl:apply-templates/></td>
-</xsl:template>
-
-<xsl:template match="check:message">
- <td><xsl:apply-templates/></td>
-</xsl:template>
-
-</xsl:stylesheet>
-
+<?xml version="1.0" encoding="UTF-8"?>
+
+<xsl:stylesheet
+ version="1.0"
+ xmlns:check="http://check.sourceforge.net/ns"
+ xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
+ xmlns="http://www.w3.org/TR/REC-html40">
+
+<xsl:output method="html"/>
+
+<xsl:template match="/">
+<html>
+ <head>
+ <title>Test Suite Results</title>
+ </head>
+
+ <body>
+ <xsl:apply-templates/>
+ </body>
+</html>
+</xsl:template>
+
+<xsl:template match="datetime">
+ <xsl:apply-templates/>
+</xsl:template>
+
+<xsl:template match="duration">
+ <xsl:apply-templates/>
+</xsl:template>
+
+<xsl:template match="check:suite">
+ <xsl:apply-templates select="check:title"/>
+ <center>
+ <table width="80%" border="1">
+ <thead>
+ <tr>
+ <td>Test Path</td>
+ <td>Test Function Location</td>
+ <td>C Identifier</td>
+ <td>Test Case</td>
+ <td>Result</td>
+ </tr>
+ </thead>
+ <tbody>
+ <xsl:apply-templates select="check:test"/>
+ </tbody>
+ </table>
+ </center>
+</xsl:template>
+
+<xsl:template match="check:testsuites">
+ <xsl:apply-templates select="check:suite"/>
+ <h3>Unit Test Statistics</h3>
+ <ul>
+ <li>date/time: <xsl:apply-templates select="check:datetime"/></li>
+ <li>duration: <xsl:apply-templates select="check:duration"/></li>
+ </ul>
+ <hr></hr>
+</xsl:template>
+
+<xsl:template match="check:title">
+ <h2>Test Suite: <xsl:apply-templates/></h2>
+</xsl:template>
+
+<xsl:template match="check:test[@result='success']">
+ <tr bgcolor="lime">
+ <xsl:apply-templates/>
+ </tr>
+</xsl:template>
+
+<xsl:template match="check:test[@result='failure']">
+ <tr bgcolor="red">
+ <xsl:apply-templates/>
+ </tr>
+</xsl:template>
+
+<xsl:template match="check:test[@result='error']">
+ <tr bgcolor="yellow">
+ <xsl:apply-templates/>
+ </tr>
+</xsl:template>
+
+<xsl:template match="check:path">
+ <td><xsl:apply-templates/></td>
+</xsl:template>
+
+<xsl:template match="check:fn">
+ <td><xsl:apply-templates/></td>
+</xsl:template>
+
+<xsl:template match="check:id">
+ <td><xsl:apply-templates/></td>
+</xsl:template>
+
+<xsl:template match="check:description">
+ <td><xsl:apply-templates/></td>
+</xsl:template>
+
+<xsl:template match="check:message">
+ <td><xsl:apply-templates/></td>
+</xsl:template>
+
+</xsl:stylesheet>
+
diff --git a/libxcb/tests/Makefile.am b/libxcb/tests/Makefile.am
index 077681e51..93fd03d9b 100644
--- a/libxcb/tests/Makefile.am
+++ b/libxcb/tests/Makefile.am
@@ -1,32 +1,32 @@
-########################
-## tests/Makefile.am
-########################
-SUBDIRS =
-EXTRA_DIST = CheckLog.xsl
-AM_MAKEFLAGS = -k
-AM_CFLAGS = -Wall -Werror @CHECK_CFLAGS@ -I$(top_srcdir)/src
-LDADD = @CHECK_LIBS@ $(top_builddir)/src/libxcb.la
-
-if HAVE_CHECK
-TESTS = check_all
-check_PROGRAMS = check_all
-check_all_SOURCES = check_all.c check_suites.h check_public.c
-
-all-local::
- $(RM) CheckLog*.xml
-
-check-local: check-TESTS
- $(RM) CheckLog.html
- if test x$(HTML_CHECK_RESULT) = xtrue; then \
- $(XSLTPROC) $(srcdir)/CheckLog.xsl CheckLog*.xml > CheckLog.html; \
- else \
- touch CheckLog.html; \
- fi
-
-CheckLog.html: $(check_PROGRAMS)
- $(MAKE) $(AM_MAKEFLAGS) check;
-
-endif
-
-clean-local::
- $(RM) CheckLog.html CheckLog*.txt CheckLog*.xml
+########################
+## tests/Makefile.am
+########################
+SUBDIRS =
+EXTRA_DIST = CheckLog.xsl
+AM_MAKEFLAGS = -k
+AM_CFLAGS = -Wall -Werror @CHECK_CFLAGS@ -I$(top_srcdir)/src
+LDADD = @CHECK_LIBS@ $(top_builddir)/src/libxcb.la
+
+if HAVE_CHECK
+TESTS = check_all
+check_PROGRAMS = check_all
+check_all_SOURCES = check_all.c check_suites.h check_public.c
+
+all-local::
+ $(RM) CheckLog*.xml
+
+check-local: check-TESTS
+ $(RM) CheckLog.html
+ if test x$(HTML_CHECK_RESULT) = xtrue; then \
+ $(XSLTPROC) $(srcdir)/CheckLog.xsl CheckLog*.xml > CheckLog.html; \
+ else \
+ touch CheckLog.html; \
+ fi
+
+CheckLog.html: $(check_PROGRAMS)
+ $(MAKE) $(AM_MAKEFLAGS) check;
+
+endif
+
+clean-local::
+ $(RM) CheckLog.html CheckLog*.txt CheckLog*.xml
diff --git a/libxcb/tests/check_all.c b/libxcb/tests/check_all.c
index 4393422e3..8c7887dd9 100644
--- a/libxcb/tests/check_all.c
+++ b/libxcb/tests/check_all.c
@@ -1,20 +1,20 @@
-#include <stdlib.h>
-#include "check_suites.h"
-
-void suite_add_test(Suite *s, TFun tf, const char *name)
-{
- TCase *tc = tcase_create(name);
- tcase_add_test(tc, tf);
- suite_add_tcase(s, tc);
-}
-
-int main(void)
-{
- int nf;
- SRunner *sr = srunner_create(public_suite());
- srunner_set_xml(sr, "CheckLog_xcb.xml");
- srunner_run_all(sr, CK_NORMAL);
- nf = srunner_ntests_failed(sr);
- srunner_free(sr);
- return (nf == 0) ? EXIT_SUCCESS : EXIT_FAILURE;
-}
+#include <stdlib.h>
+#include "check_suites.h"
+
+void suite_add_test(Suite *s, TFun tf, const char *name)
+{
+ TCase *tc = tcase_create(name);
+ tcase_add_test(tc, tf);
+ suite_add_tcase(s, tc);
+}
+
+int main(void)
+{
+ int nf;
+ SRunner *sr = srunner_create(public_suite());
+ srunner_set_xml(sr, "CheckLog_xcb.xml");
+ srunner_run_all(sr, CK_NORMAL);
+ nf = srunner_ntests_failed(sr);
+ srunner_free(sr);
+ return (nf == 0) ? EXIT_SUCCESS : EXIT_FAILURE;
+}
diff --git a/libxcb/tests/check_public.c b/libxcb/tests/check_public.c
index 2094bfef1..c77c6917d 100644
--- a/libxcb/tests/check_public.c
+++ b/libxcb/tests/check_public.c
@@ -1,218 +1,218 @@
-#include <check.h>
-#include <string.h>
-#include <stdlib.h>
-#include "check_suites.h"
-#include "xcb.h"
-#include "xcbext.h"
-
-/* xcb_parse_display tests {{{ */
-
-typedef enum test_type_t {
- TEST_ARGUMENT, TEST_ENVIRONMENT, TEST_END
-} test_type_t;
-static const char *const test_string[] = { "", "via $DISPLAY " };
-
-static void parse_display_pass(const char *name, const char *host, const int display, const int screen)
-{
- int success;
- char *got_host;
- int got_display, got_screen;
- 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=");
-}
-
-static void parse_display_fail(const char *name)
-{
- int success;
- char *got_host;
- int got_display, got_screen;
- 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)
- {
- if (!name) break;
- 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 success %sfor '%s'", test_string[test_type], name);
- fail_unless(got_host == (char *) -1, "host changed on parse failure %sfor '%s': got %p", test_string[test_type], name, got_host);
- fail_unless(got_display == -42, "display changed on parse failure %sfor '%s': got %d", test_string[test_type], name, got_display);
- fail_unless(got_screen == -42, "screen changed on parse failure %sfor '%s': got %d", test_string[test_type], name, got_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 success %sfor '%s'", test_string[test_type], name);
- fail_unless(got_host == (char *) -1, "host changed on parse failure %sfor '%s': got %p", test_string[test_type], name, got_host);
- fail_unless(got_display == -42, "display changed on parse failure %sfor '%s': got %d", test_string[test_type], name, got_display);
- }
- putenv("DISPLAY=");
-}
-
-START_TEST(parse_display_unix)
-{
- parse_display_pass(":0", "", 0, 0);
- parse_display_pass(":1", "", 1, 0);
- parse_display_pass(":0.1", "", 0, 1);
-}
-END_TEST
-
-START_TEST(parse_display_ip)
-{
- parse_display_pass("x.org:0", "x.org", 0, 0);
- parse_display_pass("expo:0", "expo", 0, 0);
- parse_display_pass("bigmachine:1", "bigmachine", 1, 0);
- parse_display_pass("hydra:0.1", "hydra", 0, 1);
-}
-END_TEST
-
-START_TEST(parse_display_ipv4)
-{
- parse_display_pass("198.112.45.11:0", "198.112.45.11", 0, 0);
- parse_display_pass("198.112.45.11:0.1", "198.112.45.11", 0, 1);
-}
-END_TEST
-
-START_TEST(parse_display_ipv6)
-{
- parse_display_pass(":::0", "::", 0, 0);
- parse_display_pass("1:::0", "1::", 0, 0);
- parse_display_pass("::1:0", "::1", 0, 0);
- parse_display_pass("::1:0.1", "::1", 0, 1);
- parse_display_pass("::127.0.0.1:0", "::127.0.0.1", 0, 0);
- parse_display_pass("::ffff:127.0.0.1:0", "::ffff:127.0.0.1", 0, 0);
- parse_display_pass("2002:83fc:d052::1:0", "2002:83fc:d052::1", 0, 0);
- parse_display_pass("2002:83fc:d052::1:0.1", "2002:83fc:d052::1", 0, 1);
- parse_display_pass("[::]:0", "[::]", 0, 0);
- parse_display_pass("[1::]:0", "[1::]", 0, 0);
- parse_display_pass("[::1]:0", "[::1]", 0, 0);
- parse_display_pass("[::1]:0.1", "[::1]", 0, 1);
- parse_display_pass("[::127.0.0.1]:0", "[::127.0.0.1]", 0, 0);
- parse_display_pass("[::ffff:127.0.0.1]:0", "[::ffff:127.0.0.1]", 0, 0);
- parse_display_pass("[2002:83fc:d052::1]:0", "[2002:83fc:d052::1]", 0, 0);
- parse_display_pass("[2002:83fc:d052::1]:0.1", "[2002:83fc:d052::1]", 0, 1);
-}
-END_TEST
-
-START_TEST(parse_display_decnet)
-{
- parse_display_pass("myws::0", "myws:", 0, 0);
- parse_display_pass("big::1", "big:", 1, 0);
- parse_display_pass("hydra::0.1", "hydra:", 0, 1);
-}
-END_TEST
-
-START_TEST(parse_display_negative)
-{
- parse_display_fail(0);
- parse_display_fail("");
- parse_display_fail(":");
- parse_display_fail("::");
- parse_display_fail(":::");
- parse_display_fail(":.");
- parse_display_fail(":a");
- parse_display_fail(":a.");
- parse_display_fail(":0.");
- parse_display_fail(":.a");
- parse_display_fail(":.0");
- parse_display_fail(":0.a");
- parse_display_fail(":0.0.");
-
- parse_display_fail("127.0.0.1");
- parse_display_fail("127.0.0.1:");
- parse_display_fail("127.0.0.1::");
- parse_display_fail("::127.0.0.1");
- parse_display_fail("::127.0.0.1:");
- parse_display_fail("::127.0.0.1::");
- parse_display_fail("::ffff:127.0.0.1");
- parse_display_fail("::ffff:127.0.0.1:");
- parse_display_fail("::ffff:127.0.0.1::");
- parse_display_fail("localhost");
- parse_display_fail("localhost:");
- parse_display_fail("localhost::");
-}
-END_TEST
-
-/* }}} */
-
-static void popcount_eq(uint32_t bits, int count)
-{
- fail_unless(xcb_popcount(bits) == count, "unexpected popcount(%08x) != %d", bits, count);
-}
-
-START_TEST(popcount)
-{
- uint32_t mask;
- int count;
-
- for (mask = 0xffffffff, count = 32; count >= 0; mask >>= 1, --count) {
- popcount_eq(mask, count);
- }
- for (mask = 0x80000000; mask; mask >>= 1) {
- popcount_eq(mask, 1);
- }
- for (mask = 0x80000000; mask > 1; mask >>= 1) {
- popcount_eq(mask | 1, 2);
- }
-}
-END_TEST
-
-Suite *public_suite(void)
-{
- Suite *s = suite_create("Public API");
- putenv("DISPLAY=");
- suite_add_test(s, parse_display_unix, "xcb_parse_display unix");
- suite_add_test(s, parse_display_ip, "xcb_parse_display ip");
- suite_add_test(s, parse_display_ipv4, "xcb_parse_display ipv4");
- suite_add_test(s, parse_display_ipv6, "xcb_parse_display ipv6");
- suite_add_test(s, parse_display_decnet, "xcb_parse_display decnet");
- suite_add_test(s, parse_display_negative, "xcb_parse_display negative");
- suite_add_test(s, popcount, "xcb_popcount");
- return s;
-}
+#include <check.h>
+#include <string.h>
+#include <stdlib.h>
+#include "check_suites.h"
+#include "xcb.h"
+#include "xcbext.h"
+
+/* xcb_parse_display tests {{{ */
+
+typedef enum test_type_t {
+ TEST_ARGUMENT, TEST_ENVIRONMENT, TEST_END
+} test_type_t;
+static const char *const test_string[] = { "", "via $DISPLAY " };
+
+static void parse_display_pass(const char *name, const char *host, const int display, const int screen)
+{
+ int success;
+ char *got_host;
+ int got_display, got_screen;
+ 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=");
+}
+
+static void parse_display_fail(const char *name)
+{
+ int success;
+ char *got_host;
+ int got_display, got_screen;
+ 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)
+ {
+ if (!name) break;
+ 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 success %sfor '%s'", test_string[test_type], name);
+ fail_unless(got_host == (char *) -1, "host changed on parse failure %sfor '%s': got %p", test_string[test_type], name, got_host);
+ fail_unless(got_display == -42, "display changed on parse failure %sfor '%s': got %d", test_string[test_type], name, got_display);
+ fail_unless(got_screen == -42, "screen changed on parse failure %sfor '%s': got %d", test_string[test_type], name, got_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 success %sfor '%s'", test_string[test_type], name);
+ fail_unless(got_host == (char *) -1, "host changed on parse failure %sfor '%s': got %p", test_string[test_type], name, got_host);
+ fail_unless(got_display == -42, "display changed on parse failure %sfor '%s': got %d", test_string[test_type], name, got_display);
+ }
+ putenv("DISPLAY=");
+}
+
+START_TEST(parse_display_unix)
+{
+ parse_display_pass(":0", "", 0, 0);
+ parse_display_pass(":1", "", 1, 0);
+ parse_display_pass(":0.1", "", 0, 1);
+}
+END_TEST
+
+START_TEST(parse_display_ip)
+{
+ parse_display_pass("x.org:0", "x.org", 0, 0);
+ parse_display_pass("expo:0", "expo", 0, 0);
+ parse_display_pass("bigmachine:1", "bigmachine", 1, 0);
+ parse_display_pass("hydra:0.1", "hydra", 0, 1);
+}
+END_TEST
+
+START_TEST(parse_display_ipv4)
+{
+ parse_display_pass("198.112.45.11:0", "198.112.45.11", 0, 0);
+ parse_display_pass("198.112.45.11:0.1", "198.112.45.11", 0, 1);
+}
+END_TEST
+
+START_TEST(parse_display_ipv6)
+{
+ parse_display_pass(":::0", "::", 0, 0);
+ parse_display_pass("1:::0", "1::", 0, 0);
+ parse_display_pass("::1:0", "::1", 0, 0);
+ parse_display_pass("::1:0.1", "::1", 0, 1);
+ parse_display_pass("::127.0.0.1:0", "::127.0.0.1", 0, 0);
+ parse_display_pass("::ffff:127.0.0.1:0", "::ffff:127.0.0.1", 0, 0);
+ parse_display_pass("2002:83fc:d052::1:0", "2002:83fc:d052::1", 0, 0);
+ parse_display_pass("2002:83fc:d052::1:0.1", "2002:83fc:d052::1", 0, 1);
+ parse_display_pass("[::]:0", "[::]", 0, 0);
+ parse_display_pass("[1::]:0", "[1::]", 0, 0);
+ parse_display_pass("[::1]:0", "[::1]", 0, 0);
+ parse_display_pass("[::1]:0.1", "[::1]", 0, 1);
+ parse_display_pass("[::127.0.0.1]:0", "[::127.0.0.1]", 0, 0);
+ parse_display_pass("[::ffff:127.0.0.1]:0", "[::ffff:127.0.0.1]", 0, 0);
+ parse_display_pass("[2002:83fc:d052::1]:0", "[2002:83fc:d052::1]", 0, 0);
+ parse_display_pass("[2002:83fc:d052::1]:0.1", "[2002:83fc:d052::1]", 0, 1);
+}
+END_TEST
+
+START_TEST(parse_display_decnet)
+{
+ parse_display_pass("myws::0", "myws:", 0, 0);
+ parse_display_pass("big::1", "big:", 1, 0);
+ parse_display_pass("hydra::0.1", "hydra:", 0, 1);
+}
+END_TEST
+
+START_TEST(parse_display_negative)
+{
+ parse_display_fail(0);
+ parse_display_fail("");
+ parse_display_fail(":");
+ parse_display_fail("::");
+ parse_display_fail(":::");
+ parse_display_fail(":.");
+ parse_display_fail(":a");
+ parse_display_fail(":a.");
+ parse_display_fail(":0.");
+ parse_display_fail(":.a");
+ parse_display_fail(":.0");
+ parse_display_fail(":0.a");
+ parse_display_fail(":0.0.");
+
+ parse_display_fail("127.0.0.1");
+ parse_display_fail("127.0.0.1:");
+ parse_display_fail("127.0.0.1::");
+ parse_display_fail("::127.0.0.1");
+ parse_display_fail("::127.0.0.1:");
+ parse_display_fail("::127.0.0.1::");
+ parse_display_fail("::ffff:127.0.0.1");
+ parse_display_fail("::ffff:127.0.0.1:");
+ parse_display_fail("::ffff:127.0.0.1::");
+ parse_display_fail("localhost");
+ parse_display_fail("localhost:");
+ parse_display_fail("localhost::");
+}
+END_TEST
+
+/* }}} */
+
+static void popcount_eq(uint32_t bits, int count)
+{
+ fail_unless(xcb_popcount(bits) == count, "unexpected popcount(%08x) != %d", bits, count);
+}
+
+START_TEST(popcount)
+{
+ uint32_t mask;
+ int count;
+
+ for (mask = 0xffffffff, count = 32; count >= 0; mask >>= 1, --count) {
+ popcount_eq(mask, count);
+ }
+ for (mask = 0x80000000; mask; mask >>= 1) {
+ popcount_eq(mask, 1);
+ }
+ for (mask = 0x80000000; mask > 1; mask >>= 1) {
+ popcount_eq(mask | 1, 2);
+ }
+}
+END_TEST
+
+Suite *public_suite(void)
+{
+ Suite *s = suite_create("Public API");
+ putenv("DISPLAY=");
+ suite_add_test(s, parse_display_unix, "xcb_parse_display unix");
+ suite_add_test(s, parse_display_ip, "xcb_parse_display ip");
+ suite_add_test(s, parse_display_ipv4, "xcb_parse_display ipv4");
+ suite_add_test(s, parse_display_ipv6, "xcb_parse_display ipv6");
+ suite_add_test(s, parse_display_decnet, "xcb_parse_display decnet");
+ suite_add_test(s, parse_display_negative, "xcb_parse_display negative");
+ suite_add_test(s, popcount, "xcb_popcount");
+ return s;
+}
diff --git a/libxcb/tests/check_suites.h b/libxcb/tests/check_suites.h
index 499f1afaf..9eaf04293 100644
--- a/libxcb/tests/check_suites.h
+++ b/libxcb/tests/check_suites.h
@@ -1,4 +1,4 @@
-#include <check.h>
-
-void suite_add_test(Suite *s, TFun tf, const char *name);
-Suite *public_suite(void);
+#include <check.h>
+
+void suite_add_test(Suite *s, TFun tf, const char *name);
+Suite *public_suite(void);