]> git.saurik.com Git - apple/mdnsresponder.git/blob - unittests/DNSMessageTest.c
mDNSResponder-878.270.2.tar.gz
[apple/mdnsresponder.git] / unittests / DNSMessageTest.c
1 #include "mDNSEmbeddedAPI.h"
2 #include "DNSMessageTest.h"
3 #include "../mDNSCore/DNSCommon.h"
4
5 int SizeTest(void);
6 int InitializeTest(void);
7 int PutDomainNameAsLabels(void);
8 int PutRData(void);
9 int Finalize(void);
10
11
12 DNSMessage *msg;
13
14
15 UNITTEST_HEADER(DNSMessageTest)
16 UNITTEST_TEST(SizeTest)
17 UNITTEST_TEST(InitializeTest)
18 UNITTEST_TEST(Finalize)
19 UNITTEST_FOOTER
20
21
22 UNITTEST_HEADER(SizeTest)
23 msg = (DNSMessage *)malloc (sizeof(DNSMessage));
24 UNITTEST_ASSERT_RETURN(msg != NULL);
25
26 // message header should be 12 bytes
27 UNITTEST_ASSERT(sizeof(msg->h) == 12);
28 UNITTEST_FOOTER
29
30
31 UNITTEST_HEADER(InitializeTest)
32 // Initialize the message
33 InitializeDNSMessage(&msg->h, onesID, QueryFlags);
34
35 // Check that the message is initialized properly
36 UNITTEST_ASSERT(msg->h.numAdditionals == 0);
37 UNITTEST_ASSERT(msg->h.numAnswers == 0);
38 UNITTEST_ASSERT(msg->h.numQuestions == 0);
39 UNITTEST_ASSERT(msg->h.numAuthorities == 0);
40 UNITTEST_FOOTER
41
42
43 UNITTEST_HEADER(PutDomainNameAsLabels)
44
45 UNITTEST_FOOTER
46
47 UNITTEST_HEADER(Finalize)
48 UNITTEST_ASSERT_RETURN(msg != NULL)
49 free(msg);
50 UNITTEST_FOOTER