File: | out/../test/cctest/test_sockaddr.cc |
Warning: | line 102, column 3 Value stored to 'foo' is never read |
Press '?' to see keyboard shortcuts
Keyboard shortcuts:
1 | #include "node_sockaddr-inl.h" |
2 | #include "gtest/gtest.h" |
3 | |
4 | using node::SocketAddress; |
5 | using node::SocketAddressBlockList; |
6 | using node::SocketAddressLRU; |
7 | |
8 | TEST(SocketAddress, SocketAddress)static_assert(sizeof("SocketAddress") > 1, "test_suite_name must not be empty" ); static_assert(sizeof("SocketAddress") > 1, "test_name must not be empty" ); class SocketAddress_SocketAddress_Test : public ::testing:: Test { public: SocketAddress_SocketAddress_Test() = default; ~ SocketAddress_SocketAddress_Test() override = default; SocketAddress_SocketAddress_Test (SocketAddress_SocketAddress_Test const&) = delete; SocketAddress_SocketAddress_Test & operator=(SocketAddress_SocketAddress_Test const&) = delete; SocketAddress_SocketAddress_Test(SocketAddress_SocketAddress_Test &&) noexcept = delete; SocketAddress_SocketAddress_Test & operator=(SocketAddress_SocketAddress_Test&&) noexcept = delete; private: void TestBody() override; static ::testing ::TestInfo* const test_info_ __attribute__ ((unused)); }; ::testing ::TestInfo* const SocketAddress_SocketAddress_Test::test_info_ = ::testing::internal::MakeAndRegisterTestInfo( "SocketAddress" , "SocketAddress", nullptr, nullptr, ::testing::internal::CodeLocation ("../test/cctest/test_sockaddr.cc", 8), (::testing::internal:: GetTestTypeId()), ::testing::internal::SuiteApiResolver< :: testing::Test>::GetSetUpCaseOrSuite("../test/cctest/test_sockaddr.cc" , 8), ::testing::internal::SuiteApiResolver< ::testing::Test >::GetTearDownCaseOrSuite("../test/cctest/test_sockaddr.cc" , 8), new ::testing::internal::TestFactoryImpl<SocketAddress_SocketAddress_Test >); void SocketAddress_SocketAddress_Test::TestBody() { |
9 | CHECK(SocketAddress::is_numeric_host("123.123.123.123"))do { if (__builtin_expect(!!(!(SocketAddress::is_numeric_host ("123.123.123.123"))), 0)) { do { static const node::AssertionInfo args = { "../test/cctest/test_sockaddr.cc" ":" "9", "SocketAddress::is_numeric_host(\"123.123.123.123\")" , __PRETTY_FUNCTION__ }; node::Assert(args); } while (0); } } while (0); |
10 | CHECK(!SocketAddress::is_numeric_host("localhost"))do { if (__builtin_expect(!!(!(!SocketAddress::is_numeric_host ("localhost"))), 0)) { do { static const node::AssertionInfo args = { "../test/cctest/test_sockaddr.cc" ":" "10", "!SocketAddress::is_numeric_host(\"localhost\")" , __PRETTY_FUNCTION__ }; node::Assert(args); } while (0); } } while (0); |
11 | |
12 | sockaddr_storage storage; |
13 | sockaddr_storage storage2; |
14 | SocketAddress::ToSockAddr(AF_INET2, "123.123.123.123", 443, &storage); |
15 | SocketAddress::ToSockAddr(AF_INET2, "1.1.1.1", 80, &storage2); |
16 | |
17 | SocketAddress addr(reinterpret_cast<const sockaddr*>(&storage)); |
18 | SocketAddress addr2(reinterpret_cast<const sockaddr*>(&storage2)); |
19 | |
20 | CHECK_EQ(addr.length(), sizeof(sockaddr_in))do { if (__builtin_expect(!!(!((addr.length()) == (sizeof(sockaddr_in )))), 0)) { do { static const node::AssertionInfo args = { "../test/cctest/test_sockaddr.cc" ":" "20", "(addr.length()) == (sizeof(sockaddr_in))", __PRETTY_FUNCTION__ }; node::Assert(args); } while (0); } } while (0); |
21 | CHECK_EQ(addr.family(), AF_INET)do { if (__builtin_expect(!!(!((addr.family()) == (2))), 0)) { do { static const node::AssertionInfo args = { "../test/cctest/test_sockaddr.cc" ":" "21", "(addr.family()) == (2)", __PRETTY_FUNCTION__ }; node ::Assert(args); } while (0); } } while (0); |
22 | CHECK_EQ(addr.address(), "123.123.123.123")do { if (__builtin_expect(!!(!((addr.address()) == ("123.123.123.123" ))), 0)) { do { static const node::AssertionInfo args = { "../test/cctest/test_sockaddr.cc" ":" "22", "(addr.address()) == (\"123.123.123.123\")", __PRETTY_FUNCTION__ }; node::Assert(args); } while (0); } } while (0); |
23 | CHECK_EQ(addr.port(), 443)do { if (__builtin_expect(!!(!((addr.port()) == (443))), 0)) { do { static const node::AssertionInfo args = { "../test/cctest/test_sockaddr.cc" ":" "23", "(addr.port()) == (443)", __PRETTY_FUNCTION__ }; node ::Assert(args); } while (0); } } while (0); |
24 | |
25 | addr.set_flow_label(12345); |
26 | CHECK_EQ(addr.flow_label(), 0)do { if (__builtin_expect(!!(!((addr.flow_label()) == (0))), 0 )) { do { static const node::AssertionInfo args = { "../test/cctest/test_sockaddr.cc" ":" "26", "(addr.flow_label()) == (0)", __PRETTY_FUNCTION__ } ; node::Assert(args); } while (0); } } while (0); |
27 | |
28 | CHECK_NE(addr, addr2)do { if (__builtin_expect(!!(!((addr) != (addr2))), 0)) { do { static const node::AssertionInfo args = { "../test/cctest/test_sockaddr.cc" ":" "28", "(addr) != (addr2)", __PRETTY_FUNCTION__ }; node:: Assert(args); } while (0); } } while (0); |
29 | CHECK_EQ(addr, addr)do { if (__builtin_expect(!!(!((addr) == (addr))), 0)) { do { static const node::AssertionInfo args = { "../test/cctest/test_sockaddr.cc" ":" "29", "(addr) == (addr)", __PRETTY_FUNCTION__ }; node::Assert (args); } while (0); } } while (0); |
30 | |
31 | CHECK_EQ(SocketAddress::Hash()(addr), SocketAddress::Hash()(addr))do { if (__builtin_expect(!!(!((SocketAddress::Hash()(addr)) == (SocketAddress::Hash()(addr)))), 0)) { do { static const node ::AssertionInfo args = { "../test/cctest/test_sockaddr.cc" ":" "31", "(SocketAddress::Hash()(addr)) == (SocketAddress::Hash()(addr))" , __PRETTY_FUNCTION__ }; node::Assert(args); } while (0); } } while (0); |
32 | CHECK_NE(SocketAddress::Hash()(addr), SocketAddress::Hash()(addr2))do { if (__builtin_expect(!!(!((SocketAddress::Hash()(addr)) != (SocketAddress::Hash()(addr2)))), 0)) { do { static const node ::AssertionInfo args = { "../test/cctest/test_sockaddr.cc" ":" "32", "(SocketAddress::Hash()(addr)) != (SocketAddress::Hash()(addr2))" , __PRETTY_FUNCTION__ }; node::Assert(args); } while (0); } } while (0); |
33 | |
34 | addr.Update(reinterpret_cast<uint8_t*>(&storage2), sizeof(sockaddr_in)); |
35 | CHECK_EQ(addr.length(), sizeof(sockaddr_in))do { if (__builtin_expect(!!(!((addr.length()) == (sizeof(sockaddr_in )))), 0)) { do { static const node::AssertionInfo args = { "../test/cctest/test_sockaddr.cc" ":" "35", "(addr.length()) == (sizeof(sockaddr_in))", __PRETTY_FUNCTION__ }; node::Assert(args); } while (0); } } while (0); |
36 | CHECK_EQ(addr.family(), AF_INET)do { if (__builtin_expect(!!(!((addr.family()) == (2))), 0)) { do { static const node::AssertionInfo args = { "../test/cctest/test_sockaddr.cc" ":" "36", "(addr.family()) == (2)", __PRETTY_FUNCTION__ }; node ::Assert(args); } while (0); } } while (0); |
37 | CHECK_EQ(addr.address(), "1.1.1.1")do { if (__builtin_expect(!!(!((addr.address()) == ("1.1.1.1" ))), 0)) { do { static const node::AssertionInfo args = { "../test/cctest/test_sockaddr.cc" ":" "37", "(addr.address()) == (\"1.1.1.1\")", __PRETTY_FUNCTION__ }; node::Assert(args); } while (0); } } while (0); |
38 | CHECK_EQ(addr.port(), 80)do { if (__builtin_expect(!!(!((addr.port()) == (80))), 0)) { do { static const node::AssertionInfo args = { "../test/cctest/test_sockaddr.cc" ":" "38", "(addr.port()) == (80)", __PRETTY_FUNCTION__ }; node ::Assert(args); } while (0); } } while (0); |
39 | |
40 | SocketAddress::Map<size_t> map; |
41 | map[addr]++; |
42 | map[addr]++; |
43 | CHECK_EQ(map[addr], 2)do { if (__builtin_expect(!!(!((map[addr]) == (2))), 0)) { do { static const node::AssertionInfo args = { "../test/cctest/test_sockaddr.cc" ":" "43", "(map[addr]) == (2)", __PRETTY_FUNCTION__ }; node:: Assert(args); } while (0); } } while (0); |
44 | } |
45 | |
46 | TEST(SocketAddress, SocketAddressIPv6)static_assert(sizeof("SocketAddress") > 1, "test_suite_name must not be empty" ); static_assert(sizeof("SocketAddressIPv6") > 1, "test_name must not be empty" ); class SocketAddress_SocketAddressIPv6_Test : public ::testing ::Test { public: SocketAddress_SocketAddressIPv6_Test() = default ; ~SocketAddress_SocketAddressIPv6_Test() override = default; SocketAddress_SocketAddressIPv6_Test(SocketAddress_SocketAddressIPv6_Test const&) = delete; SocketAddress_SocketAddressIPv6_Test& operator=(SocketAddress_SocketAddressIPv6_Test const&) = delete; SocketAddress_SocketAddressIPv6_Test(SocketAddress_SocketAddressIPv6_Test &&) noexcept = delete; SocketAddress_SocketAddressIPv6_Test & operator=(SocketAddress_SocketAddressIPv6_Test&& ) noexcept = delete; private: void TestBody() override; static ::testing::TestInfo* const test_info_ __attribute__ ((unused )); }; ::testing::TestInfo* const SocketAddress_SocketAddressIPv6_Test ::test_info_ = ::testing::internal::MakeAndRegisterTestInfo( "SocketAddress" , "SocketAddressIPv6", nullptr, nullptr, ::testing::internal:: CodeLocation("../test/cctest/test_sockaddr.cc", 46), (::testing ::internal::GetTestTypeId()), ::testing::internal::SuiteApiResolver < ::testing::Test>::GetSetUpCaseOrSuite("../test/cctest/test_sockaddr.cc" , 46), ::testing::internal::SuiteApiResolver< ::testing::Test >::GetTearDownCaseOrSuite("../test/cctest/test_sockaddr.cc" , 46), new ::testing::internal::TestFactoryImpl<SocketAddress_SocketAddressIPv6_Test >); void SocketAddress_SocketAddressIPv6_Test::TestBody() { |
47 | sockaddr_storage storage; |
48 | SocketAddress::ToSockAddr(AF_INET610, "::1", 443, &storage); |
49 | |
50 | SocketAddress addr(reinterpret_cast<const sockaddr*>(&storage)); |
51 | |
52 | CHECK_EQ(addr.length(), sizeof(sockaddr_in6))do { if (__builtin_expect(!!(!((addr.length()) == (sizeof(sockaddr_in6 )))), 0)) { do { static const node::AssertionInfo args = { "../test/cctest/test_sockaddr.cc" ":" "52", "(addr.length()) == (sizeof(sockaddr_in6))", __PRETTY_FUNCTION__ }; node::Assert(args); } while (0); } } while (0); |
53 | CHECK_EQ(addr.family(), AF_INET6)do { if (__builtin_expect(!!(!((addr.family()) == (10))), 0)) { do { static const node::AssertionInfo args = { "../test/cctest/test_sockaddr.cc" ":" "53", "(addr.family()) == (10)", __PRETTY_FUNCTION__ }; node ::Assert(args); } while (0); } } while (0); |
54 | CHECK_EQ(addr.address(), "::1")do { if (__builtin_expect(!!(!((addr.address()) == ("::1"))), 0)) { do { static const node::AssertionInfo args = { "../test/cctest/test_sockaddr.cc" ":" "54", "(addr.address()) == (\"::1\")", __PRETTY_FUNCTION__ }; node::Assert(args); } while (0); } } while (0); |
55 | CHECK_EQ(addr.port(), 443)do { if (__builtin_expect(!!(!((addr.port()) == (443))), 0)) { do { static const node::AssertionInfo args = { "../test/cctest/test_sockaddr.cc" ":" "55", "(addr.port()) == (443)", __PRETTY_FUNCTION__ }; node ::Assert(args); } while (0); } } while (0); |
56 | |
57 | addr.set_flow_label(12345); |
58 | CHECK_EQ(addr.flow_label(), 12345)do { if (__builtin_expect(!!(!((addr.flow_label()) == (12345) )), 0)) { do { static const node::AssertionInfo args = { "../test/cctest/test_sockaddr.cc" ":" "58", "(addr.flow_label()) == (12345)", __PRETTY_FUNCTION__ }; node::Assert(args); } while (0); } } while (0); |
59 | } |
60 | |
61 | TEST(SocketAddressLRU, SocketAddressLRU)static_assert(sizeof("SocketAddressLRU") > 1, "test_suite_name must not be empty" ); static_assert(sizeof("SocketAddressLRU") > 1, "test_name must not be empty" ); class SocketAddressLRU_SocketAddressLRU_Test : public ::testing ::Test { public: SocketAddressLRU_SocketAddressLRU_Test() = default ; ~SocketAddressLRU_SocketAddressLRU_Test() override = default ; SocketAddressLRU_SocketAddressLRU_Test(SocketAddressLRU_SocketAddressLRU_Test const&) = delete; SocketAddressLRU_SocketAddressLRU_Test & operator=(SocketAddressLRU_SocketAddressLRU_Test const& ) = delete; SocketAddressLRU_SocketAddressLRU_Test(SocketAddressLRU_SocketAddressLRU_Test &&) noexcept = delete; SocketAddressLRU_SocketAddressLRU_Test & operator=(SocketAddressLRU_SocketAddressLRU_Test&& ) noexcept = delete; private: void TestBody() override; static ::testing::TestInfo* const test_info_ __attribute__ ((unused )); }; ::testing::TestInfo* const SocketAddressLRU_SocketAddressLRU_Test ::test_info_ = ::testing::internal::MakeAndRegisterTestInfo( "SocketAddressLRU" , "SocketAddressLRU", nullptr, nullptr, ::testing::internal:: CodeLocation("../test/cctest/test_sockaddr.cc", 61), (::testing ::internal::GetTestTypeId()), ::testing::internal::SuiteApiResolver < ::testing::Test>::GetSetUpCaseOrSuite("../test/cctest/test_sockaddr.cc" , 61), ::testing::internal::SuiteApiResolver< ::testing::Test >::GetTearDownCaseOrSuite("../test/cctest/test_sockaddr.cc" , 61), new ::testing::internal::TestFactoryImpl<SocketAddressLRU_SocketAddressLRU_Test >); void SocketAddressLRU_SocketAddressLRU_Test::TestBody( ) { |
62 | struct Foo { |
63 | int c; |
64 | bool expired; |
65 | }; |
66 | |
67 | struct FooLRUTraits { |
68 | using Type = Foo; |
69 | |
70 | static bool CheckExpired(const SocketAddress& address, const Type& type) { |
71 | return type.expired; |
72 | } |
73 | |
74 | static void Touch(const SocketAddress& address, Type* type) { |
75 | type->expired = false; |
76 | } |
77 | }; |
78 | |
79 | SocketAddressLRU<FooLRUTraits> lru(2); |
80 | |
81 | sockaddr_storage storage[4]; |
82 | |
83 | SocketAddress::ToSockAddr(AF_INET2, "123.123.123.123", 443, &storage[0]); |
84 | SocketAddress::ToSockAddr(AF_INET2, "123.123.123.124", 443, &storage[1]); |
85 | SocketAddress::ToSockAddr(AF_INET2, "123.123.123.125", 443, &storage[2]); |
86 | SocketAddress::ToSockAddr(AF_INET2, "123.123.123.123", 443, &storage[3]); |
87 | |
88 | |
89 | SocketAddress addr1(reinterpret_cast<const sockaddr*>(&storage[0])); |
90 | SocketAddress addr2(reinterpret_cast<const sockaddr*>(&storage[1])); |
91 | SocketAddress addr3(reinterpret_cast<const sockaddr*>(&storage[2])); |
92 | SocketAddress addr4(reinterpret_cast<const sockaddr*>(&storage[3])); |
93 | |
94 | Foo* foo = lru.Upsert(addr1); |
95 | CHECK_NOT_NULL(foo)do { if (__builtin_expect(!!(!((foo) != nullptr)), 0)) { do { static const node::AssertionInfo args = { "../test/cctest/test_sockaddr.cc" ":" "95", "(foo) != nullptr", __PRETTY_FUNCTION__ }; node::Assert (args); } while (0); } } while (0); |
96 | CHECK_EQ(foo->c, 0)do { if (__builtin_expect(!!(!((foo->c) == (0))), 0)) { do { static const node::AssertionInfo args = { "../test/cctest/test_sockaddr.cc" ":" "96", "(foo->c) == (0)", __PRETTY_FUNCTION__ }; node:: Assert(args); } while (0); } } while (0); |
97 | CHECK_EQ(foo->expired, false)do { if (__builtin_expect(!!(!((foo->expired) == (false))) , 0)) { do { static const node::AssertionInfo args = { "../test/cctest/test_sockaddr.cc" ":" "97", "(foo->expired) == (false)", __PRETTY_FUNCTION__ }; node::Assert(args); } while (0); } } while (0); |
98 | |
99 | foo->c = 1; |
100 | foo->expired = true; |
101 | |
102 | foo = lru.Upsert(addr1); |
Value stored to 'foo' is never read | |
103 | CHECK_NOT_NULL(lru.Peek(addr1))do { if (__builtin_expect(!!(!((lru.Peek(addr1)) != nullptr)) , 0)) { do { static const node::AssertionInfo args = { "../test/cctest/test_sockaddr.cc" ":" "103", "(lru.Peek(addr1)) != nullptr", __PRETTY_FUNCTION__ }; node::Assert(args); } while (0); } } while (0); |
104 | CHECK_EQ(lru.Peek(addr1), lru.Peek(addr4))do { if (__builtin_expect(!!(!((lru.Peek(addr1)) == (lru.Peek (addr4)))), 0)) { do { static const node::AssertionInfo args = { "../test/cctest/test_sockaddr.cc" ":" "104", "(lru.Peek(addr1)) == (lru.Peek(addr4))" , __PRETTY_FUNCTION__ }; node::Assert(args); } while (0); } } while (0); |
105 | CHECK_EQ(lru.Peek(addr1)->c, 1)do { if (__builtin_expect(!!(!((lru.Peek(addr1)->c) == (1) )), 0)) { do { static const node::AssertionInfo args = { "../test/cctest/test_sockaddr.cc" ":" "105", "(lru.Peek(addr1)->c) == (1)", __PRETTY_FUNCTION__ }; node::Assert(args); } while (0); } } while (0); |
106 | CHECK_EQ(lru.Peek(addr1)->expired, false)do { if (__builtin_expect(!!(!((lru.Peek(addr1)->expired) == (false))), 0)) { do { static const node::AssertionInfo args = { "../test/cctest/test_sockaddr.cc" ":" "106", "(lru.Peek(addr1)->expired) == (false)" , __PRETTY_FUNCTION__ }; node::Assert(args); } while (0); } } while (0); |
107 | CHECK_EQ(lru.size(), 1)do { if (__builtin_expect(!!(!((lru.size()) == (1))), 0)) { do { static const node::AssertionInfo args = { "../test/cctest/test_sockaddr.cc" ":" "107", "(lru.size()) == (1)", __PRETTY_FUNCTION__ }; node ::Assert(args); } while (0); } } while (0); |
108 | |
109 | foo = lru.Upsert(addr2); |
110 | foo->c = 2; |
111 | foo->expired = true; |
112 | CHECK_NOT_NULL(lru.Peek(addr2))do { if (__builtin_expect(!!(!((lru.Peek(addr2)) != nullptr)) , 0)) { do { static const node::AssertionInfo args = { "../test/cctest/test_sockaddr.cc" ":" "112", "(lru.Peek(addr2)) != nullptr", __PRETTY_FUNCTION__ }; node::Assert(args); } while (0); } } while (0); |
113 | CHECK_EQ(lru.Peek(addr2)->c, 2)do { if (__builtin_expect(!!(!((lru.Peek(addr2)->c) == (2) )), 0)) { do { static const node::AssertionInfo args = { "../test/cctest/test_sockaddr.cc" ":" "113", "(lru.Peek(addr2)->c) == (2)", __PRETTY_FUNCTION__ }; node::Assert(args); } while (0); } } while (0); |
114 | CHECK_EQ(lru.size(), 2)do { if (__builtin_expect(!!(!((lru.size()) == (2))), 0)) { do { static const node::AssertionInfo args = { "../test/cctest/test_sockaddr.cc" ":" "114", "(lru.size()) == (2)", __PRETTY_FUNCTION__ }; node ::Assert(args); } while (0); } } while (0); |
115 | |
116 | foo->expired = true; |
117 | |
118 | foo = lru.Upsert(addr3); |
119 | foo->c = 3; |
120 | foo->expired = false; |
121 | CHECK_NOT_NULL(lru.Peek(addr3))do { if (__builtin_expect(!!(!((lru.Peek(addr3)) != nullptr)) , 0)) { do { static const node::AssertionInfo args = { "../test/cctest/test_sockaddr.cc" ":" "121", "(lru.Peek(addr3)) != nullptr", __PRETTY_FUNCTION__ }; node::Assert(args); } while (0); } } while (0); |
122 | CHECK_EQ(lru.Peek(addr3)->c, 3)do { if (__builtin_expect(!!(!((lru.Peek(addr3)->c) == (3) )), 0)) { do { static const node::AssertionInfo args = { "../test/cctest/test_sockaddr.cc" ":" "122", "(lru.Peek(addr3)->c) == (3)", __PRETTY_FUNCTION__ }; node::Assert(args); } while (0); } } while (0); |
123 | CHECK_EQ(lru.size(), 1)do { if (__builtin_expect(!!(!((lru.size()) == (1))), 0)) { do { static const node::AssertionInfo args = { "../test/cctest/test_sockaddr.cc" ":" "123", "(lru.size()) == (1)", __PRETTY_FUNCTION__ }; node ::Assert(args); } while (0); } } while (0); |
124 | |
125 | // addr1 was removed because we exceeded size. |
126 | // addr2 was removed because it was expired. |
127 | CHECK_NULL(lru.Peek(addr1))do { if (__builtin_expect(!!(!((lru.Peek(addr1)) == nullptr)) , 0)) { do { static const node::AssertionInfo args = { "../test/cctest/test_sockaddr.cc" ":" "127", "(lru.Peek(addr1)) == nullptr", __PRETTY_FUNCTION__ }; node::Assert(args); } while (0); } } while (0); |
128 | CHECK_NULL(lru.Peek(addr2))do { if (__builtin_expect(!!(!((lru.Peek(addr2)) == nullptr)) , 0)) { do { static const node::AssertionInfo args = { "../test/cctest/test_sockaddr.cc" ":" "128", "(lru.Peek(addr2)) == nullptr", __PRETTY_FUNCTION__ }; node::Assert(args); } while (0); } } while (0); |
129 | } |
130 | |
131 | TEST(SocketAddress, Comparison)static_assert(sizeof("SocketAddress") > 1, "test_suite_name must not be empty" ); static_assert(sizeof("Comparison") > 1, "test_name must not be empty" ); class SocketAddress_Comparison_Test : public ::testing::Test { public: SocketAddress_Comparison_Test() = default; ~SocketAddress_Comparison_Test () override = default; SocketAddress_Comparison_Test(SocketAddress_Comparison_Test const&) = delete; SocketAddress_Comparison_Test& operator =(SocketAddress_Comparison_Test const&) = delete; SocketAddress_Comparison_Test (SocketAddress_Comparison_Test&&) noexcept = delete; SocketAddress_Comparison_Test & operator=(SocketAddress_Comparison_Test&&) noexcept = delete; private: void TestBody() override; static ::testing ::TestInfo* const test_info_ __attribute__ ((unused)); }; ::testing ::TestInfo* const SocketAddress_Comparison_Test::test_info_ = ::testing::internal::MakeAndRegisterTestInfo( "SocketAddress" , "Comparison", nullptr, nullptr, ::testing::internal::CodeLocation ("../test/cctest/test_sockaddr.cc", 131), (::testing::internal ::GetTestTypeId()), ::testing::internal::SuiteApiResolver< ::testing::Test>::GetSetUpCaseOrSuite("../test/cctest/test_sockaddr.cc" , 131), ::testing::internal::SuiteApiResolver< ::testing:: Test>::GetTearDownCaseOrSuite("../test/cctest/test_sockaddr.cc" , 131), new ::testing::internal::TestFactoryImpl<SocketAddress_Comparison_Test >); void SocketAddress_Comparison_Test::TestBody() { |
132 | sockaddr_storage storage[6]; |
133 | |
134 | SocketAddress::ToSockAddr(AF_INET2, "10.0.0.1", 0, &storage[0]); |
135 | SocketAddress::ToSockAddr(AF_INET2, "10.0.0.2", 0, &storage[1]); |
136 | SocketAddress::ToSockAddr(AF_INET610, "::1", 0, &storage[2]); |
137 | SocketAddress::ToSockAddr(AF_INET610, "::2", 0, &storage[3]); |
138 | SocketAddress::ToSockAddr(AF_INET610, "::ffff:10.0.0.1", 0, &storage[4]); |
139 | SocketAddress::ToSockAddr(AF_INET610, "::ffff:10.0.0.2", 0, &storage[5]); |
140 | |
141 | SocketAddress addr1(reinterpret_cast<const sockaddr*>(&storage[0])); |
142 | SocketAddress addr2(reinterpret_cast<const sockaddr*>(&storage[1])); |
143 | SocketAddress addr3(reinterpret_cast<const sockaddr*>(&storage[2])); |
144 | SocketAddress addr4(reinterpret_cast<const sockaddr*>(&storage[3])); |
145 | SocketAddress addr5(reinterpret_cast<const sockaddr*>(&storage[4])); |
146 | SocketAddress addr6(reinterpret_cast<const sockaddr*>(&storage[5])); |
147 | |
148 | CHECK_EQ(addr1.compare(addr1), SocketAddress::CompareResult::SAME)do { if (__builtin_expect(!!(!((addr1.compare(addr1)) == (SocketAddress ::CompareResult::SAME))), 0)) { do { static const node::AssertionInfo args = { "../test/cctest/test_sockaddr.cc" ":" "148", "(addr1.compare(addr1)) == (SocketAddress::CompareResult::SAME)" , __PRETTY_FUNCTION__ }; node::Assert(args); } while (0); } } while (0); |
149 | CHECK_EQ(addr1.compare(addr2), SocketAddress::CompareResult::LESS_THAN)do { if (__builtin_expect(!!(!((addr1.compare(addr2)) == (SocketAddress ::CompareResult::LESS_THAN))), 0)) { do { static const node:: AssertionInfo args = { "../test/cctest/test_sockaddr.cc" ":" "149" , "(addr1.compare(addr2)) == (SocketAddress::CompareResult::LESS_THAN)" , __PRETTY_FUNCTION__ }; node::Assert(args); } while (0); } } while (0); |
150 | CHECK_EQ(addr2.compare(addr1), SocketAddress::CompareResult::GREATER_THAN)do { if (__builtin_expect(!!(!((addr2.compare(addr1)) == (SocketAddress ::CompareResult::GREATER_THAN))), 0)) { do { static const node ::AssertionInfo args = { "../test/cctest/test_sockaddr.cc" ":" "150", "(addr2.compare(addr1)) == (SocketAddress::CompareResult::GREATER_THAN)" , __PRETTY_FUNCTION__ }; node::Assert(args); } while (0); } } while (0); |
151 | CHECK(addr1 <= addr1)do { if (__builtin_expect(!!(!(addr1 <= addr1)), 0)) { do { static const node::AssertionInfo args = { "../test/cctest/test_sockaddr.cc" ":" "151", "addr1 <= addr1", __PRETTY_FUNCTION__ }; node:: Assert(args); } while (0); } } while (0); |
152 | CHECK(addr1 < addr2)do { if (__builtin_expect(!!(!(addr1 < addr2)), 0)) { do { static const node::AssertionInfo args = { "../test/cctest/test_sockaddr.cc" ":" "152", "addr1 < addr2", __PRETTY_FUNCTION__ }; node:: Assert(args); } while (0); } } while (0); |
153 | CHECK(addr1 <= addr2)do { if (__builtin_expect(!!(!(addr1 <= addr2)), 0)) { do { static const node::AssertionInfo args = { "../test/cctest/test_sockaddr.cc" ":" "153", "addr1 <= addr2", __PRETTY_FUNCTION__ }; node:: Assert(args); } while (0); } } while (0); |
154 | CHECK(addr2 >= addr2)do { if (__builtin_expect(!!(!(addr2 >= addr2)), 0)) { do { static const node::AssertionInfo args = { "../test/cctest/test_sockaddr.cc" ":" "154", "addr2 >= addr2", __PRETTY_FUNCTION__ }; node:: Assert(args); } while (0); } } while (0); |
155 | CHECK(addr2 > addr1)do { if (__builtin_expect(!!(!(addr2 > addr1)), 0)) { do { static const node::AssertionInfo args = { "../test/cctest/test_sockaddr.cc" ":" "155", "addr2 > addr1", __PRETTY_FUNCTION__ }; node:: Assert(args); } while (0); } } while (0); |
156 | CHECK(addr2 >= addr1)do { if (__builtin_expect(!!(!(addr2 >= addr1)), 0)) { do { static const node::AssertionInfo args = { "../test/cctest/test_sockaddr.cc" ":" "156", "addr2 >= addr1", __PRETTY_FUNCTION__ }; node:: Assert(args); } while (0); } } while (0); |
157 | |
158 | CHECK_EQ(addr3.compare(addr3), SocketAddress::CompareResult::SAME)do { if (__builtin_expect(!!(!((addr3.compare(addr3)) == (SocketAddress ::CompareResult::SAME))), 0)) { do { static const node::AssertionInfo args = { "../test/cctest/test_sockaddr.cc" ":" "158", "(addr3.compare(addr3)) == (SocketAddress::CompareResult::SAME)" , __PRETTY_FUNCTION__ }; node::Assert(args); } while (0); } } while (0); |
159 | CHECK_EQ(addr3.compare(addr4), SocketAddress::CompareResult::LESS_THAN)do { if (__builtin_expect(!!(!((addr3.compare(addr4)) == (SocketAddress ::CompareResult::LESS_THAN))), 0)) { do { static const node:: AssertionInfo args = { "../test/cctest/test_sockaddr.cc" ":" "159" , "(addr3.compare(addr4)) == (SocketAddress::CompareResult::LESS_THAN)" , __PRETTY_FUNCTION__ }; node::Assert(args); } while (0); } } while (0); |
160 | CHECK_EQ(addr4.compare(addr3), SocketAddress::CompareResult::GREATER_THAN)do { if (__builtin_expect(!!(!((addr4.compare(addr3)) == (SocketAddress ::CompareResult::GREATER_THAN))), 0)) { do { static const node ::AssertionInfo args = { "../test/cctest/test_sockaddr.cc" ":" "160", "(addr4.compare(addr3)) == (SocketAddress::CompareResult::GREATER_THAN)" , __PRETTY_FUNCTION__ }; node::Assert(args); } while (0); } } while (0); |
161 | CHECK(addr3 <= addr3)do { if (__builtin_expect(!!(!(addr3 <= addr3)), 0)) { do { static const node::AssertionInfo args = { "../test/cctest/test_sockaddr.cc" ":" "161", "addr3 <= addr3", __PRETTY_FUNCTION__ }; node:: Assert(args); } while (0); } } while (0); |
162 | CHECK(addr3 < addr4)do { if (__builtin_expect(!!(!(addr3 < addr4)), 0)) { do { static const node::AssertionInfo args = { "../test/cctest/test_sockaddr.cc" ":" "162", "addr3 < addr4", __PRETTY_FUNCTION__ }; node:: Assert(args); } while (0); } } while (0); |
163 | CHECK(addr3 <= addr4)do { if (__builtin_expect(!!(!(addr3 <= addr4)), 0)) { do { static const node::AssertionInfo args = { "../test/cctest/test_sockaddr.cc" ":" "163", "addr3 <= addr4", __PRETTY_FUNCTION__ }; node:: Assert(args); } while (0); } } while (0); |
164 | CHECK(addr4 >= addr4)do { if (__builtin_expect(!!(!(addr4 >= addr4)), 0)) { do { static const node::AssertionInfo args = { "../test/cctest/test_sockaddr.cc" ":" "164", "addr4 >= addr4", __PRETTY_FUNCTION__ }; node:: Assert(args); } while (0); } } while (0); |
165 | CHECK(addr4 > addr3)do { if (__builtin_expect(!!(!(addr4 > addr3)), 0)) { do { static const node::AssertionInfo args = { "../test/cctest/test_sockaddr.cc" ":" "165", "addr4 > addr3", __PRETTY_FUNCTION__ }; node:: Assert(args); } while (0); } } while (0); |
166 | CHECK(addr4 >= addr3)do { if (__builtin_expect(!!(!(addr4 >= addr3)), 0)) { do { static const node::AssertionInfo args = { "../test/cctest/test_sockaddr.cc" ":" "166", "addr4 >= addr3", __PRETTY_FUNCTION__ }; node:: Assert(args); } while (0); } } while (0); |
167 | |
168 | // Not comparable |
169 | CHECK_EQ(addr1.compare(addr3), SocketAddress::CompareResult::NOT_COMPARABLE)do { if (__builtin_expect(!!(!((addr1.compare(addr3)) == (SocketAddress ::CompareResult::NOT_COMPARABLE))), 0)) { do { static const node ::AssertionInfo args = { "../test/cctest/test_sockaddr.cc" ":" "169", "(addr1.compare(addr3)) == (SocketAddress::CompareResult::NOT_COMPARABLE)" , __PRETTY_FUNCTION__ }; node::Assert(args); } while (0); } } while (0); |
170 | CHECK_EQ(addr3.compare(addr1), SocketAddress::CompareResult::NOT_COMPARABLE)do { if (__builtin_expect(!!(!((addr3.compare(addr1)) == (SocketAddress ::CompareResult::NOT_COMPARABLE))), 0)) { do { static const node ::AssertionInfo args = { "../test/cctest/test_sockaddr.cc" ":" "170", "(addr3.compare(addr1)) == (SocketAddress::CompareResult::NOT_COMPARABLE)" , __PRETTY_FUNCTION__ }; node::Assert(args); } while (0); } } while (0); |
171 | CHECK(!(addr1 < addr3))do { if (__builtin_expect(!!(!(!(addr1 < addr3))), 0)) { do { static const node::AssertionInfo args = { "../test/cctest/test_sockaddr.cc" ":" "171", "!(addr1 < addr3)", __PRETTY_FUNCTION__ }; node ::Assert(args); } while (0); } } while (0); |
172 | CHECK(!(addr1 > addr3))do { if (__builtin_expect(!!(!(!(addr1 > addr3))), 0)) { do { static const node::AssertionInfo args = { "../test/cctest/test_sockaddr.cc" ":" "172", "!(addr1 > addr3)", __PRETTY_FUNCTION__ }; node ::Assert(args); } while (0); } } while (0); |
173 | CHECK(!(addr1 >= addr3))do { if (__builtin_expect(!!(!(!(addr1 >= addr3))), 0)) { do { static const node::AssertionInfo args = { "../test/cctest/test_sockaddr.cc" ":" "173", "!(addr1 >= addr3)", __PRETTY_FUNCTION__ }; node ::Assert(args); } while (0); } } while (0); |
174 | CHECK(!(addr1 <= addr3))do { if (__builtin_expect(!!(!(!(addr1 <= addr3))), 0)) { do { static const node::AssertionInfo args = { "../test/cctest/test_sockaddr.cc" ":" "174", "!(addr1 <= addr3)", __PRETTY_FUNCTION__ }; node ::Assert(args); } while (0); } } while (0); |
175 | CHECK(!(addr3 < addr1))do { if (__builtin_expect(!!(!(!(addr3 < addr1))), 0)) { do { static const node::AssertionInfo args = { "../test/cctest/test_sockaddr.cc" ":" "175", "!(addr3 < addr1)", __PRETTY_FUNCTION__ }; node ::Assert(args); } while (0); } } while (0); |
176 | CHECK(!(addr3 > addr1))do { if (__builtin_expect(!!(!(!(addr3 > addr1))), 0)) { do { static const node::AssertionInfo args = { "../test/cctest/test_sockaddr.cc" ":" "176", "!(addr3 > addr1)", __PRETTY_FUNCTION__ }; node ::Assert(args); } while (0); } } while (0); |
177 | CHECK(!(addr3 >= addr1))do { if (__builtin_expect(!!(!(!(addr3 >= addr1))), 0)) { do { static const node::AssertionInfo args = { "../test/cctest/test_sockaddr.cc" ":" "177", "!(addr3 >= addr1)", __PRETTY_FUNCTION__ }; node ::Assert(args); } while (0); } } while (0); |
178 | CHECK(!(addr3 <= addr1))do { if (__builtin_expect(!!(!(!(addr3 <= addr1))), 0)) { do { static const node::AssertionInfo args = { "../test/cctest/test_sockaddr.cc" ":" "178", "!(addr3 <= addr1)", __PRETTY_FUNCTION__ }; node ::Assert(args); } while (0); } } while (0); |
179 | |
180 | // Comparable |
181 | CHECK_EQ(addr1.compare(addr5), SocketAddress::CompareResult::SAME)do { if (__builtin_expect(!!(!((addr1.compare(addr5)) == (SocketAddress ::CompareResult::SAME))), 0)) { do { static const node::AssertionInfo args = { "../test/cctest/test_sockaddr.cc" ":" "181", "(addr1.compare(addr5)) == (SocketAddress::CompareResult::SAME)" , __PRETTY_FUNCTION__ }; node::Assert(args); } while (0); } } while (0); |
182 | CHECK_EQ(addr2.compare(addr6), SocketAddress::CompareResult::SAME)do { if (__builtin_expect(!!(!((addr2.compare(addr6)) == (SocketAddress ::CompareResult::SAME))), 0)) { do { static const node::AssertionInfo args = { "../test/cctest/test_sockaddr.cc" ":" "182", "(addr2.compare(addr6)) == (SocketAddress::CompareResult::SAME)" , __PRETTY_FUNCTION__ }; node::Assert(args); } while (0); } } while (0); |
183 | CHECK_EQ(addr1.compare(addr6), SocketAddress::CompareResult::LESS_THAN)do { if (__builtin_expect(!!(!((addr1.compare(addr6)) == (SocketAddress ::CompareResult::LESS_THAN))), 0)) { do { static const node:: AssertionInfo args = { "../test/cctest/test_sockaddr.cc" ":" "183" , "(addr1.compare(addr6)) == (SocketAddress::CompareResult::LESS_THAN)" , __PRETTY_FUNCTION__ }; node::Assert(args); } while (0); } } while (0); |
184 | CHECK_EQ(addr6.compare(addr1), SocketAddress::CompareResult::GREATER_THAN)do { if (__builtin_expect(!!(!((addr6.compare(addr1)) == (SocketAddress ::CompareResult::GREATER_THAN))), 0)) { do { static const node ::AssertionInfo args = { "../test/cctest/test_sockaddr.cc" ":" "184", "(addr6.compare(addr1)) == (SocketAddress::CompareResult::GREATER_THAN)" , __PRETTY_FUNCTION__ }; node::Assert(args); } while (0); } } while (0); |
185 | CHECK(addr1 <= addr5)do { if (__builtin_expect(!!(!(addr1 <= addr5)), 0)) { do { static const node::AssertionInfo args = { "../test/cctest/test_sockaddr.cc" ":" "185", "addr1 <= addr5", __PRETTY_FUNCTION__ }; node:: Assert(args); } while (0); } } while (0); |
186 | CHECK(addr1 <= addr6)do { if (__builtin_expect(!!(!(addr1 <= addr6)), 0)) { do { static const node::AssertionInfo args = { "../test/cctest/test_sockaddr.cc" ":" "186", "addr1 <= addr6", __PRETTY_FUNCTION__ }; node:: Assert(args); } while (0); } } while (0); |
187 | CHECK(addr1 < addr6)do { if (__builtin_expect(!!(!(addr1 < addr6)), 0)) { do { static const node::AssertionInfo args = { "../test/cctest/test_sockaddr.cc" ":" "187", "addr1 < addr6", __PRETTY_FUNCTION__ }; node:: Assert(args); } while (0); } } while (0); |
188 | CHECK(addr6 > addr1)do { if (__builtin_expect(!!(!(addr6 > addr1)), 0)) { do { static const node::AssertionInfo args = { "../test/cctest/test_sockaddr.cc" ":" "188", "addr6 > addr1", __PRETTY_FUNCTION__ }; node:: Assert(args); } while (0); } } while (0); |
189 | CHECK(addr6 >= addr1)do { if (__builtin_expect(!!(!(addr6 >= addr1)), 0)) { do { static const node::AssertionInfo args = { "../test/cctest/test_sockaddr.cc" ":" "189", "addr6 >= addr1", __PRETTY_FUNCTION__ }; node:: Assert(args); } while (0); } } while (0); |
190 | CHECK(addr2 >= addr6)do { if (__builtin_expect(!!(!(addr2 >= addr6)), 0)) { do { static const node::AssertionInfo args = { "../test/cctest/test_sockaddr.cc" ":" "190", "addr2 >= addr6", __PRETTY_FUNCTION__ }; node:: Assert(args); } while (0); } } while (0); |
191 | CHECK(addr2 >= addr5)do { if (__builtin_expect(!!(!(addr2 >= addr5)), 0)) { do { static const node::AssertionInfo args = { "../test/cctest/test_sockaddr.cc" ":" "191", "addr2 >= addr5", __PRETTY_FUNCTION__ }; node:: Assert(args); } while (0); } } while (0); |
192 | } |
193 | |
194 | TEST(SocketAddressBlockList, Simple)static_assert(sizeof("SocketAddressBlockList") > 1, "test_suite_name must not be empty" ); static_assert(sizeof("Simple") > 1, "test_name must not be empty" ); class SocketAddressBlockList_Simple_Test : public ::testing ::Test { public: SocketAddressBlockList_Simple_Test() = default ; ~SocketAddressBlockList_Simple_Test() override = default; SocketAddressBlockList_Simple_Test (SocketAddressBlockList_Simple_Test const&) = delete; SocketAddressBlockList_Simple_Test & operator=(SocketAddressBlockList_Simple_Test const& ) = delete; SocketAddressBlockList_Simple_Test(SocketAddressBlockList_Simple_Test &&) noexcept = delete; SocketAddressBlockList_Simple_Test & operator=(SocketAddressBlockList_Simple_Test&&) noexcept = delete; private: void TestBody() override; static ::testing::TestInfo* const test_info_ __attribute__ ((unused )); }; ::testing::TestInfo* const SocketAddressBlockList_Simple_Test ::test_info_ = ::testing::internal::MakeAndRegisterTestInfo( "SocketAddressBlockList" , "Simple", nullptr, nullptr, ::testing::internal::CodeLocation ("../test/cctest/test_sockaddr.cc", 194), (::testing::internal ::GetTestTypeId()), ::testing::internal::SuiteApiResolver< ::testing::Test>::GetSetUpCaseOrSuite("../test/cctest/test_sockaddr.cc" , 194), ::testing::internal::SuiteApiResolver< ::testing:: Test>::GetTearDownCaseOrSuite("../test/cctest/test_sockaddr.cc" , 194), new ::testing::internal::TestFactoryImpl<SocketAddressBlockList_Simple_Test >); void SocketAddressBlockList_Simple_Test::TestBody() { |
195 | SocketAddressBlockList bl; |
196 | |
197 | sockaddr_storage storage[2]; |
198 | SocketAddress::ToSockAddr(AF_INET2, "10.0.0.1", 0, &storage[0]); |
199 | SocketAddress::ToSockAddr(AF_INET2, "10.0.0.2", 0, &storage[1]); |
200 | std::shared_ptr<SocketAddress> addr1 = |
201 | std::make_shared<SocketAddress>( |
202 | reinterpret_cast<const sockaddr*>(&storage[0])); |
203 | std::shared_ptr<SocketAddress> addr2 = |
204 | std::make_shared<SocketAddress>( |
205 | reinterpret_cast<const sockaddr*>(&storage[1])); |
206 | |
207 | bl.AddSocketAddress(addr1); |
208 | bl.AddSocketAddress(addr2); |
209 | |
210 | CHECK(bl.Apply(addr1))do { if (__builtin_expect(!!(!(bl.Apply(addr1))), 0)) { do { static const node::AssertionInfo args = { "../test/cctest/test_sockaddr.cc" ":" "210", "bl.Apply(addr1)", __PRETTY_FUNCTION__ }; node::Assert (args); } while (0); } } while (0); |
211 | CHECK(bl.Apply(addr2))do { if (__builtin_expect(!!(!(bl.Apply(addr2))), 0)) { do { static const node::AssertionInfo args = { "../test/cctest/test_sockaddr.cc" ":" "211", "bl.Apply(addr2)", __PRETTY_FUNCTION__ }; node::Assert (args); } while (0); } } while (0); |
212 | |
213 | bl.RemoveSocketAddress(addr1); |
214 | |
215 | CHECK(!bl.Apply(addr1))do { if (__builtin_expect(!!(!(!bl.Apply(addr1))), 0)) { do { static const node::AssertionInfo args = { "../test/cctest/test_sockaddr.cc" ":" "215", "!bl.Apply(addr1)", __PRETTY_FUNCTION__ }; node:: Assert(args); } while (0); } } while (0); |
216 | CHECK(bl.Apply(addr2))do { if (__builtin_expect(!!(!(bl.Apply(addr2))), 0)) { do { static const node::AssertionInfo args = { "../test/cctest/test_sockaddr.cc" ":" "216", "bl.Apply(addr2)", __PRETTY_FUNCTION__ }; node::Assert (args); } while (0); } } while (0); |
217 | } |