From 154ae08781aaba9ea30c2ec8f396c7898332ffca Mon Sep 17 00:00:00 2001 From: Dmitry Rozhkov Date: Tue, 10 Oct 2017 15:58:45 +0300 Subject: shared: introduce dnssd_srv_type_is_valid() function --- src/test/test-dns-domain.c | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) (limited to 'src/test/test-dns-domain.c') diff --git a/src/test/test-dns-domain.c b/src/test/test-dns-domain.c index 5f669df051..3105c14ee6 100644 --- a/src/test/test-dns-domain.c +++ b/src/test/test-dns-domain.c @@ -427,6 +427,30 @@ static void test_dns_srv_type_is_valid(void) { assert_se(!dns_srv_type_is_valid("_piep._foo._udp")); } +static void test_dnssd_srv_type_is_valid(void) { + + assert_se(dnssd_srv_type_is_valid("_http._tcp")); + assert_se(dnssd_srv_type_is_valid("_foo-bar._tcp")); + assert_se(dnssd_srv_type_is_valid("_w._udp")); + assert_se(dnssd_srv_type_is_valid("_a800._tcp")); + assert_se(dnssd_srv_type_is_valid("_a-800._tcp")); + + assert_se(!dnssd_srv_type_is_valid(NULL)); + assert_se(!dnssd_srv_type_is_valid("")); + assert_se(!dnssd_srv_type_is_valid("x")); + assert_se(!dnssd_srv_type_is_valid("_foo")); + assert_se(!dnssd_srv_type_is_valid("_tcp")); + assert_se(!dnssd_srv_type_is_valid("_")); + assert_se(!dnssd_srv_type_is_valid("_foo.")); + assert_se(!dnssd_srv_type_is_valid("_föo._tcp")); + assert_se(!dnssd_srv_type_is_valid("_f\no._tcp")); + assert_se(!dnssd_srv_type_is_valid("_800._tcp")); + assert_se(!dnssd_srv_type_is_valid("_-800._tcp")); + assert_se(!dnssd_srv_type_is_valid("_-foo._tcp")); + assert_se(!dnssd_srv_type_is_valid("_piep._foo._udp")); + assert_se(!dnssd_srv_type_is_valid("_foo._unknown")); +} + static void test_dns_service_join_one(const char *a, const char *b, const char *c, int r, const char *d) { _cleanup_free_ char *x = NULL, *y = NULL, *z = NULL, *t = NULL; @@ -699,6 +723,7 @@ int main(int argc, char *argv[]) { test_dns_name_to_wire_format(); test_dns_service_name_is_valid(); test_dns_srv_type_is_valid(); + test_dnssd_srv_type_is_valid(); test_dns_service_join(); test_dns_service_split(); test_dns_name_change_suffix(); -- cgit v1.2.3