src/connectivity/network/drivers/network-device/device/network_device-test.cc
// Regression test for session name not respecting fidl::StringView lack of null termination
// character.
Regression test for session name not respecting fidl::StringView lack of null termination
character.
Regression test for session name not respecting fidl :: StringView lack of null termination character .
TEST_F(NetworkDeviceTest, SessionNameRespectsStringView) {
  ASSERT_OK(CreateDevice());
  auto* dev = static_cast<internal::DeviceInterface*>(device_.get());
  netdev::SessionInfo info;
  TestSession test_session;
  ASSERT_OK(test_session.Init(kDefaultDescriptorCount, kDefaultBufferLength));
  ASSERT_OK(test_session.GetInfo(&info));
  const char* name_str = "hello world";
  fidl::StringView name(fidl::unowned_ptr(name_str), 5u);
  zx::channel req, ch;
  ASSERT_OK(zx::channel::create(0, &req, &ch));
  netdev::Device_OpenSession_Response rsp;
  ASSERT_OK(dev->OpenSession(std::move(name), std::move(info), &rsp));
  const auto& session = dev->sessions_unsafe().front();
  ASSERT_STR_EQ("hello", session.name());
}
TEST_F ( NetworkDeviceTest , SessionNameRespectsStringView ) { ASSERT_OK ( CreateDevice ( ) ) ; auto * dev = static_cast < internal :: DeviceInterface * > ( device_ . get ( ) ) ; netdev :: SessionInfo info ; TestSession test_session ; ASSERT_OK ( test_session . Init ( kDefaultDescriptorCount , kDefaultBufferLength ) ) ; ASSERT_OK ( test_session . GetInfo ( & info ) ) ; const char * name_str = " " ; fidl :: StringView name ( fidl :: unowned_ptr ( name_str ) , 5u ) ; zx :: channel req , ch ; ASSERT_OK ( zx :: channel :: create ( 0 , & req , & ch ) ) ; netdev :: Device_OpenSession_Response rsp ; ASSERT_OK ( dev -> OpenSession ( std :: move ( name ) , std :: move ( info ) , & rsp ) ) ; const auto & session = dev -> sessions_unsafe ( ) . front ( ) ; ASSERT_STR_EQ ( " " , session . name ( ) ) ; }
Regression test for session name not respecting fidl::StringView lack of null termination
character.
Regression test for session name not respecting fidl :: StringView lack of null termination character .
// Cast to internal implementation to access methods directly. // String view only contains "hello".