summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSteve Huston <shuston@riverace.com>2017-03-29 19:01:09 -0400
committerSteve Huston <shuston@riverace.com>2017-03-29 19:01:09 -0400
commit0318992095a5635752553814811ad92e500e968f (patch)
treee72bb93e815d3c18d0b5a539867530983237ccf7
parent21353c4629708cdafe839b296a40e828eeb19e9f (diff)
downloadATCD-0318992095a5635752553814811ad92e500e968f.tar.gz
Add new test case for selecting protocol by name
-rw-r--r--ACE/tests/INET_Addr_Test_IPV6.cpp34
1 files changed, 33 insertions, 1 deletions
diff --git a/ACE/tests/INET_Addr_Test_IPV6.cpp b/ACE/tests/INET_Addr_Test_IPV6.cpp
index d9409bed5e8..a3c37ce6412 100644
--- a/ACE/tests/INET_Addr_Test_IPV6.cpp
+++ b/ACE/tests/INET_Addr_Test_IPV6.cpp
@@ -22,7 +22,7 @@
// Make sure that ACE_Addr::addr_type_ is the same
// as the family of the inet_addr_.
-int check_type_consistency (const ACE_INET_Addr &addr)
+static int check_type_consistency (const ACE_INET_Addr &addr)
{
int family = -1;
@@ -51,6 +51,35 @@ int check_type_consistency (const ACE_INET_Addr &addr)
return 0;
}
+// A test to ensure ACE_INET_Addr can select the protocol family.
+static bool check_both_families()
+{
+ bool good = true;
+ ACE_INET_Addr a;
+ if (-1 == a.set(ACE_TEXT (""), ACE_TEXT ("facebook.com"), ACE_TEXT ("tcp")))
+ {
+ ACE_ERROR ((LM_ERROR,
+ ACE_TEXT ("%p\n"),
+ ACE_TEXT ("both test, facebook.com")));
+ good = false;
+ }
+ else
+ {
+ ACE_TCHAR str[1000];
+ a.addr_to_string (str, 1000, 1);
+ ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("got type %d, addr %s\n"), a.get_type(), str));
+ // Should have selected IPv4.
+ if (a.get_type() != AF_INET)
+ {
+ ACE_ERROR ((LM_ERROR,
+ ACE_TEXT ("Wrong address family, expecting IPv4\n")));
+ good = false;
+ }
+ }
+
+ return good;
+}
+
int run_main (int, ACE_TCHAR *[])
{
@@ -154,6 +183,9 @@ int run_main (int, ACE_TCHAR *[])
#endif /* ACE_LINUX */
}
+ if (!check_both_families())
+ status = 1;
+
#endif /* ACE_HAS_IPV6 */
ACE_END_TEST;