6e1491fd41
All checks were successful
rpcrypto-build / build (Debug, himix200.toolchain.cmake) (push) Successful in 1m8s
rpcrypto-build / build (Debug, hisiv510.toolchain.cmake) (push) Successful in 1m8s
rpcrypto-build / build (Release, hisiv510.toolchain.cmake) (push) Successful in 1m17s
rpcrypto-build / build (Release, himix200.toolchain.cmake) (push) Successful in 1m21s
linux-hisiv500-gcc / linux-gcc-hisiv500 (push) Successful in 1m26s
linux-mips64-gcc / linux-gcc-mips64el (push) Successful in 1m43s
linux-x64-gcc / linux-gcc (push) Successful in 1m52s
31 lines
876 B
C++
31 lines
876 B
C++
#include <gtest/gtest.h>
|
|
#include <ulib/log/log.h>
|
|
#include <asio.hpp>
|
|
|
|
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);
|
|
}
|