unittests: Remove ATHandler test interdependencies

Some tests in athandlertest.cpp relied on the state of stubs set in
previous tests. This caused test failures if the tests cases were ran in
isolation. Remove the interdependencies between tests by setting stub
values in the tests that rely on them.
pull/14944/head
Robert Walton 2021-07-21 22:16:14 +01:00
parent a09d08917b
commit 2e75d184b6
1 changed files with 5 additions and 0 deletions

View File

@ -906,6 +906,7 @@ TEST_F(TestATHandler, test_ATHandler_resp_start)
filehandle_stub_table = NULL;
filehandle_stub_table_pos = 0;
mbed_poll_stub::revents_value = POLLIN;
ATHandler at(&fh1, que, 0, ",");
at.resp_start();
@ -914,6 +915,7 @@ TEST_F(TestATHandler, test_ATHandler_resp_start)
char table2[] = "\"2,\"OK\r\n\0";
filehandle_stub_table = table2;
filehandle_stub_table_pos = 0;
mbed_poll_stub::int_value = strlen(table2);
at.flush();
at.clear_error();
@ -1052,12 +1054,14 @@ TEST_F(TestATHandler, test_ATHandler_resp_stop)
{
EventQueue que;
FileHandle_stub fh1;
mbed_poll_stub::revents_value = POLLIN;
ATHandler at(&fh1, que, 0, ",");
char table[] = "21 OK\r\n\0";
filehandle_stub_table = table;
filehandle_stub_table_pos = 0;
mbed_poll_stub::int_value = strlen(table);
at.info_elem('2');
at.set_stop_tag("OK\r\n");
@ -1266,6 +1270,7 @@ TEST_F(TestATHandler, test_ATHandler_at_cmd_str)
{
EventQueue que;
FileHandle_stub fh1;
mbed_poll_stub::revents_value = POLLIN;
ATHandler at(&fh1, que, 0, ",");
uint8_t byte[] = {1, 2, 3, 4};