#include #include #include static const char kTag[] = "asio"; TEST(asio, base) { asio::io_context io_context; asio::post(io_context, []() {}); asio::ip::tcp::resolver::query query("www.baidu.com", "http"); asio::ip::tcp::socket::reuse_address reuse_address(true); asio::ip::tcp::resolver resolver(io_context); int count = 0; resolver.async_resolve( query, [&](const asio::error_code &ec, asio::ip::tcp::resolver::iterator iter) { ASSERT_FALSE(ec); if (iter == asio::ip::tcp::resolver::iterator()) { return; } ++count; ULOG_ERROR(kTag, "iter-> {}:{}", iter->endpoint().address().to_string(), iter->endpoint().port()); }); io_context.run(); EXPECT_GE(count, 1); }