summaryrefslogtreecommitdiffstats
path: root/libavahi-core/dns-test.c
diff options
context:
space:
mode:
Diffstat (limited to 'libavahi-core/dns-test.c')
-rw-r--r--libavahi-core/dns-test.c35
1 files changed, 35 insertions, 0 deletions
diff --git a/libavahi-core/dns-test.c b/libavahi-core/dns-test.c
new file mode 100644
index 0000000..d8c7b53
--- /dev/null
+++ b/libavahi-core/dns-test.c
@@ -0,0 +1,35 @@
+#include "dns.h"
+#include "util.h"
+
+int main(int argc, char *argv[]) {
+ gchar t[256], *a, *b, *c, *d;
+ AvahiDnsPacket *p;
+
+ p = avahi_dns_packet_new(8000);
+
+ avahi_dns_packet_append_name(p, a = "hello.hello.hello.de.");
+ avahi_dns_packet_append_name(p, b = "this is a test.hello.de.");
+ avahi_dns_packet_append_name(p, c = "this\\.is\\.a\\.test\\.with\\.dots.hello.de.");
+ avahi_dns_packet_append_name(p, d = "this\\\\is another\\ \\test.hello.de.");
+
+ avahi_hexdump(AVAHI_DNS_PACKET_DATA(p), p->size);
+
+ avahi_dns_packet_consume_name(p, t, sizeof(t));
+ g_message(">%s<", t);
+ g_assert(avahi_domain_equal(a, t));
+
+ avahi_dns_packet_consume_name(p, t, sizeof(t));
+ g_message(">%s<", t);
+ g_assert(avahi_domain_equal(b, t));
+
+ avahi_dns_packet_consume_name(p, t, sizeof(t));
+ g_message(">%s<", t);
+ g_assert(avahi_domain_equal(c, t));
+
+ avahi_dns_packet_consume_name(p, t, sizeof(t));
+ g_message(">%s<", t);
+ g_assert(avahi_domain_equal(d, t));
+
+ avahi_dns_packet_free(p);
+ return 0;
+}