@@ -6577,6 +6577,40 @@ test_ScaledNormalizedConversion()
65776577 TEST_ASSERT_EQUAL_FLOAT (0.0f , NormalizedValue_fromScaled (0 ));
65786578}
65796579
6580+ void
6581+ test_CS104Connection_cannotWriteToSocketWhenNotConnected ()
6582+ {
6583+ /* test that the client does not crash when it tries to send a message after the connection is closed */
6584+
6585+ CS104_Slave slave = CS104_Slave_create (10 , 10 );
6586+
6587+ CS104_Slave_setServerMode (slave , CS104_MODE_SINGLE_REDUNDANCY_GROUP );
6588+ CS104_Slave_setLocalPort (slave , 20004 );
6589+
6590+ CS104_Slave_start (slave );
6591+
6592+ CS101_AppLayerParameters alParams = CS104_Slave_getAppLayerParameters (slave );
6593+
6594+ CS104_Connection con = CS104_Connection_create ("127.0.0.1" , 20004 );
6595+
6596+ bool result = CS104_Connection_connect (con );
6597+ TEST_ASSERT_TRUE (result );
6598+
6599+ CS104_Connection_sendStartDT (con );
6600+
6601+ CS104_Slave_stop (slave );
6602+
6603+ Thread_sleep (500 );
6604+
6605+ CS104_Connection_sendStopDT (con );
6606+
6607+ CS104_Connection_close (con );
6608+
6609+ CS104_Connection_destroy (con );
6610+
6611+ CS104_Slave_destroy (slave );
6612+ }
6613+
65806614int
65816615main (int argc , char * * argv )
65826616{
@@ -6703,5 +6737,7 @@ main(int argc, char** argv)
67036737
67046738 RUN_TEST (test_ScaledNormalizedConversion );
67056739
6740+ RUN_TEST (test_CS104Connection_cannotWriteToSocketWhenNotConnected );
6741+
67066742 return UNITY_END ();
67076743}
0 commit comments