77#include < unistd.h>
88#include < memory>
99#include < string>
10+ #include < iostream>
1011
1112#include " libserial/ports.hpp"
1213#include " libserial/serial_exception.hpp"
@@ -51,24 +52,25 @@ TEST_F(PortsTest, ScanPortsThrowsWhenPathMissing) {
5152 libserial::Ports ports (missing_path);
5253
5354
54- try {
55+ try {
5556 (void )ports.scanPorts ();
5657 FAIL () << " Expected libserial::SerialException to be thrown" ;
57- } catch (const libserial::SerialException& e) {
58+ }
59+ catch (const libserial::SerialException& e) {
5860 std::cout << " Caught SerialException: " << e.what () << std::endl;
5961 // Optionally assert something about the message:
6062 EXPECT_NE (std::string (e.what ()).find (" Error while reading" ), std::string::npos);
61- } catch (...) {
63+ }
64+ catch (...) {
6265 FAIL () << " Expected libserial::SerialException, but got a different exception" ;
6366 }
6467}
6568
6669TEST_F (PortsTest, ScanPortsWithFakeDevices) {
67-
6870 // Create fake device symlinks
6971 std::string fake_device1 = std::string (temp_dir_) + " /usb-FTDI_FT232R_USB_UART_A1B2C3D4" ;
7072 std::string fake_device2 = std::string (temp_dir_) + " /usb-Arduino_Uno_12345678" ;
71-
73+
7274 // Create symlinks pointing to fake /dev/ttyUSB* paths
7375 // The actual target doesn't need to exist for scanPorts to process it
7476 ASSERT_EQ (symlink (" ../../ttyUSB0" , fake_device1.c_str ()), 0 );
@@ -80,7 +82,7 @@ TEST_F(PortsTest, ScanPortsWithFakeDevices) {
8082 EXPECT_NO_THROW ({
8183 count = ports.scanPorts ();
8284 });
83-
85+
8486 EXPECT_EQ (count, 2 ) << " Should find 2 fake devices" ;
8587
8688 EXPECT_EQ (ports.findName (1 ).value (), " usb-FTDI_FT232R_USB_UART_A1B2C3D4" );
0 commit comments