mirror of
https://github.com/yarrick/iodine.git
synced 2024-12-22 21:33:33 +02:00
More dns tests
This commit is contained in:
parent
10a8c6711c
commit
22c66af914
1 changed files with 27 additions and 0 deletions
27
tests/dns.c
27
tests/dns.c
|
@ -30,19 +30,44 @@
|
|||
|
||||
START_TEST(test_encode_hostname)
|
||||
{
|
||||
char out[] = "\x06" "BADGER\x06" "BADGER\x04" "KRYO\x02" "SE\x00";
|
||||
char buf[256];
|
||||
int len;
|
||||
int ret;
|
||||
|
||||
len = 256;
|
||||
|
||||
memset(buf, 0, 256);
|
||||
ret = dns_encode_hostname("BADGER.BADGER.KRYO.SE", buf, len);
|
||||
fail_unless(strncmp(buf, out, ret) == 0, "Happy flow failed");
|
||||
}
|
||||
END_TEST
|
||||
|
||||
START_TEST(test_encode_hostname_nodot)
|
||||
{
|
||||
char buf[256];
|
||||
int len;
|
||||
int ret;
|
||||
|
||||
len = 256;
|
||||
|
||||
memset(buf, 0, 256);
|
||||
ret = dns_encode_hostname( // More than 63 chars between dots
|
||||
"ABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZ"
|
||||
"ABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZ"
|
||||
, buf, len);
|
||||
fail_unless(ret == -1, NULL);
|
||||
}
|
||||
END_TEST
|
||||
|
||||
START_TEST(test_encode_hostname_toolong)
|
||||
{
|
||||
char buf[256];
|
||||
int len;
|
||||
int ret;
|
||||
|
||||
len = 256;
|
||||
|
||||
memset(buf, 0, 256);
|
||||
ret = dns_encode_hostname( // More chars than fits into array
|
||||
"ABCDEFGHIJKLMNOPQRSTUVWXYZ.ABCDEFGHIJKLMNOPQRSTUVWXYZ."
|
||||
|
@ -65,6 +90,8 @@ test_dns_create_tests()
|
|||
|
||||
tc = tcase_create("Dns");
|
||||
tcase_add_test(tc, test_encode_hostname);
|
||||
tcase_add_test(tc, test_encode_hostname_nodot);
|
||||
tcase_add_test(tc, test_encode_hostname_toolong);
|
||||
|
||||
return tc;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue