diff --git a/test/unit/BasicTests.cpp b/test/unit/BasicTests.cpp index 4d5bcad..b918c8e 100644 --- a/test/unit/BasicTests.cpp +++ b/test/unit/BasicTests.cpp @@ -31,7 +31,6 @@ namespace { std::string device0Name_ = TestUtil::GetInstance().GetDevice0Name(); std::string device1Name_ = TestUtil::GetInstance().GetDevice1Name(); - }; TEST_F(BasicTests, CanBeConstructed) { diff --git a/test/unit/ConfigTests.cpp b/test/unit/ConfigTests.cpp index 6101329..94fe5fb 100644 --- a/test/unit/ConfigTests.cpp +++ b/test/unit/ConfigTests.cpp @@ -24,37 +24,33 @@ namespace { protected: ConfigTests() { + serialPort_ = SerialPort(TestUtil::GetInstance().GetDevice0Name(), BaudRate::B_57600); + serialPort_.Open(); + sttyOutput_ = TestUtil::GetInstance().Exec("stty -a -F " + TestUtil::GetInstance().GetDevice0Name()); } virtual ~ConfigTests() { } - std::string device0Name_ = TestUtil::GetInstance().GetDevice0Name(); + SerialPort serialPort_; + std::string sttyOutput_; }; TEST_F(ConfigTests, BaudRateSetCorrectly) { - SerialPort serialPort0(device0Name_, BaudRate::B_57600); - serialPort0.Open(); - auto retVal = TestUtil::GetInstance().Exec("stty -a -F " + device0Name_); - EXPECT_NE(std::string::npos, retVal.find("speed 57600 baud")); - - serialPort0.SetBaudRate(BaudRate::B_115200); - retVal = TestUtil::GetInstance().Exec("stty -a -F " + device0Name_); - EXPECT_NE(std::string::npos, retVal.find("speed 115200 baud")); + EXPECT_NE(std::string::npos, sttyOutput_.find("speed 57600 baud")); + serialPort_.SetBaudRate(BaudRate::B_115200); + sttyOutput_ = TestUtil::GetInstance().Exec("stty -a -F " + TestUtil::GetInstance().GetDevice0Name()); + EXPECT_NE(std::string::npos, sttyOutput_.find("speed 115200 baud")); } TEST_F(ConfigTests, CanonicalModeOff) { - SerialPort serialPort0(device0Name_, BaudRate::B_57600); - serialPort0.Open(); - auto retVal = TestUtil::GetInstance().Exec("stty -a -F " + device0Name_); - EXPECT_NE(std::string::npos, retVal.find("-icanon")); + EXPECT_NE(std::string::npos, sttyOutput_.find("-icanon")); } TEST_F(ConfigTests, EchoModeOff) { - SerialPort serialPort0(device0Name_, BaudRate::B_57600); - serialPort0.Open(); - auto retVal = TestUtil::GetInstance().Exec("stty -a -F " + device0Name_); - EXPECT_NE(std::string::npos, retVal.find("-echo")); + EXPECT_NE(std::string::npos, sttyOutput_.find("-echo")); + EXPECT_NE(std::string::npos, sttyOutput_.find("-echoe")); + EXPECT_NE(std::string::npos, sttyOutput_.find("-echonl")); } } // namespace \ No newline at end of file