diff --git a/tests/unittests/tests-dns_cache/tests-dns_cache.c b/tests/unittests/tests-dns_cache/tests-dns_cache.c index 4aacc0acfa..a9cb326708 100644 --- a/tests/unittests/tests-dns_cache/tests-dns_cache.c +++ b/tests/unittests/tests-dns_cache/tests-dns_cache.c @@ -37,10 +37,25 @@ static void test_dns_cache_add(void) TEST_ASSERT_EQUAL_INT(0, dns_cache_query("example.com", &addr_out, AF_INET6)); } +static void test_dns_cache_add_ttl0(void) +{ + ipv6_addr_t addr_in = IPV6_ADDR_ALL_NODES_IF_LOCAL; + ipv6_addr_t addr_out; + + TEST_ASSERT_EQUAL_INT(0, dns_cache_query("example.com", &addr_out, AF_INET6)); + dns_cache_add("example.com", &addr_in, sizeof(addr_in), 0); + TEST_ASSERT_EQUAL_INT(0, dns_cache_query("example.com", &addr_out, AF_INET6)); + dns_cache_add("example.com", &addr_in, sizeof(addr_in), 1); + TEST_ASSERT_EQUAL_INT(sizeof(addr_out), dns_cache_query("example.com", &addr_out, AF_INET6)); + dns_cache_add("example.com", &addr_in, sizeof(addr_in), 0); + TEST_ASSERT_EQUAL_INT(0, dns_cache_query("example.com", &addr_out, AF_INET6)); +} + Test *tests_dns_cache_tests(void) { EMB_UNIT_TESTFIXTURES(fixtures) { new_TestFixture(test_dns_cache_add), + new_TestFixture(test_dns_cache_add_ttl0), }; EMB_UNIT_TESTCALLER(dns_cache_tests, NULL, NULL, fixtures);