diff options
author | Steve Huston <shuston@riverace.com> | 2017-03-30 16:48:11 -0400 |
---|---|---|
committer | Steve Huston <shuston@riverace.com> | 2017-03-30 16:48:11 -0400 |
commit | 1ba8d16b35572416afebe6ee710b564c67cbbc05 (patch) | |
tree | 0fdd1382f005bf7268842593c24a1fd2cf074b52 | |
parent | 77985464a97d2e484393edb3f476196ce32e71d2 (diff) | |
parent | 30998b2627c5694749bcfb5ff4dceb2d413c7ac1 (diff) | |
download | ATCD-1ba8d16b35572416afebe6ee710b564c67cbbc05.tar.gz |
Add new test case for selecting protocol by name
-rw-r--r-- | ACE/tests/INET_Addr_Test_IPV6.cpp | 34 |
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 f88712dc5a1..7ea9ac1cd60 100644 --- a/ACE/tests/INET_Addr_Test_IPV6.cpp +++ b/ACE/tests/INET_Addr_Test_IPV6.cpp @@ -24,7 +24,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; @@ -53,6 +53,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 *[]) { @@ -156,6 +185,9 @@ int run_main (int, ACE_TCHAR *[]) #endif /* ACE_LINUX */ } + if (!check_both_families()) + status = 1; + #endif /* ACE_HAS_IPV6 */ ACE_END_TEST; |