Use substitition variables in xcb-xinerama.pc.in, not instances of their values
[free-sw/xcb/libxcb] / tests / check_public.c
index 295f118..e222221 100644 (file)
@@ -3,6 +3,7 @@
 #include <stdlib.h>
 #include "check_suites.h"
 #include "xcb.h"
+#include "xcbext.h"
 
 /* xcb_parse_display tests {{{ */
 
@@ -119,10 +120,22 @@ 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
 
@@ -140,20 +153,55 @@ START_TEST(parse_display_negative)
        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");
@@ -164,5 +212,6 @@ Suite *public_suite(void)
        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;
 }