summaryrefslogtreecommitdiff
path: root/src/test/test-dns-domain.c
diff options
context:
space:
mode:
authorTom Gundersen <teg@jklm.no>2016-01-14 17:02:57 +0100
committerTom Gundersen <teg@jklm.no>2016-01-14 17:02:57 +0100
commitbecc96b7264a7f56dc2024bb3000cd179526c43e (patch)
tree7ceafc37af826fb969b0f706778978446a60c0a1 /src/test/test-dns-domain.c
parentdeebd4d26f42e837ed57f6e9ccbe99dfe0e7f6d6 (diff)
parent81ec9e0887ef12bebd36d48f10372cf003df5d38 (diff)
Merge pull request #2316 from poettering/dnssec14
Fourteenth DNSSEC PR
Diffstat (limited to 'src/test/test-dns-domain.c')
-rw-r--r--src/test/test-dns-domain.c20
1 files changed, 20 insertions, 0 deletions
diff --git a/src/test/test-dns-domain.c b/src/test/test-dns-domain.c
index 6c3c49908f..fe3ae45349 100644
--- a/src/test/test-dns-domain.c
+++ b/src/test/test-dns-domain.c
@@ -276,6 +276,25 @@ static void test_dns_name_endswith(void) {
test_dns_name_endswith_one("x.y\001.z", "waldo", -EINVAL);
}
+static void test_dns_name_startswith_one(const char *a, const char *b, int ret) {
+ assert_se(dns_name_startswith(a, b) == ret);
+}
+
+static void test_dns_name_startswith(void) {
+ test_dns_name_startswith_one("", "", true);
+ test_dns_name_startswith_one("", "xxx", false);
+ test_dns_name_startswith_one("xxx", "", true);
+ test_dns_name_startswith_one("x", "x", true);
+ test_dns_name_startswith_one("x", "y", false);
+ test_dns_name_startswith_one("x.y", "x.y", true);
+ test_dns_name_startswith_one("x.y", "y.x", false);
+ test_dns_name_startswith_one("x.y", "x", true);
+ test_dns_name_startswith_one("x.y", "X", true);
+ test_dns_name_startswith_one("x.y", "y", false);
+ test_dns_name_startswith_one("x.y", "", true);
+ test_dns_name_startswith_one("x.y", "X", true);
+}
+
static void test_dns_name_is_root(void) {
assert_se(dns_name_is_root(""));
assert_se(dns_name_is_root("."));
@@ -567,6 +586,7 @@ int main(int argc, char *argv[]) {
test_dns_name_normalize();
test_dns_name_equal();
test_dns_name_endswith();
+ test_dns_name_startswith();
test_dns_name_between();
test_dns_name_is_root();
test_dns_name_is_single_label();