aboutsummaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorElliott Hughes2014-11-17 12:26:45 -0600
committerGerrit Code Review2014-11-17 12:26:46 -0600
commitf2c882095b5747cd7f3158428208580a7ff72ed6 (patch)
treeb29a812c92cc70cdc20a4cdfd8020c1287a031b0 /tests
parent35f8910e4cdf3f7d0b877394524c7dd719084187 (diff)
parent32fea147eaac4b811440a29d362fdad7e2c5a4ec (diff)
downloadplatform-bionic-f2c882095b5747cd7f3158428208580a7ff72ed6.tar.gz
platform-bionic-f2c882095b5747cd7f3158428208580a7ff72ed6.tar.xz
platform-bionic-f2c882095b5747cd7f3158428208580a7ff72ed6.zip
Merge "Add getaddrinfo(3) tests for NULL arguments."
Diffstat (limited to 'tests')
-rw-r--r--tests/netdb_test.cpp17
1 files changed, 17 insertions, 0 deletions
diff --git a/tests/netdb_test.cpp b/tests/netdb_test.cpp
index ef2c8dac..0cebe4e8 100644
--- a/tests/netdb_test.cpp
+++ b/tests/netdb_test.cpp
@@ -21,6 +21,23 @@
21#include <netdb.h> 21#include <netdb.h>
22#include <netinet/in.h> 22#include <netinet/in.h>
23 23
24TEST(netdb, getaddrinfo_NULL_host) {
25 // It's okay for the host argument to be NULL, as long as service isn't.
26 addrinfo* ai = NULL;
27 ASSERT_EQ(0, getaddrinfo(NULL, "smtp", NULL, &ai));
28 // (sockaddr_in::sin_port and sockaddr_in6::sin6_port overlap.)
29 ASSERT_EQ(25U, ntohs(reinterpret_cast<sockaddr_in*>(ai->ai_addr)->sin_port));
30 freeaddrinfo(ai);
31}
32
33TEST(netdb, getaddrinfo_NULL_service) {
34 // It's okay for the service argument to be NULL, as long as host isn't.
35 addrinfo* ai = NULL;
36 ASSERT_EQ(0, getaddrinfo("localhost", NULL, NULL, &ai));
37 ASSERT_TRUE(ai != NULL);
38 freeaddrinfo(ai);
39}
40
24TEST(netdb, getaddrinfo_NULL_hints) { 41TEST(netdb, getaddrinfo_NULL_hints) {
25 addrinfo* ai = NULL; 42 addrinfo* ai = NULL;
26 ASSERT_EQ(0, getaddrinfo("localhost", "9999", NULL, &ai)); 43 ASSERT_EQ(0, getaddrinfo("localhost", "9999", NULL, &ai));