Skip to content

Commit 5e69888

Browse files
author
Teppo Järvelin
committed
Cellular: review fix removed magic numbers from unit tests.
1 parent ccb75d2 commit 5e69888

File tree

3 files changed

+7
-5
lines changed

3 files changed

+7
-5
lines changed

features/cellular/UNITTESTS/at/at_cellulardevice/test_at_cellulardevice.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@ void Test_AT_CellularDevice::test_AT_CellularDevice_close_network()
122122
CHECK(ATHandler_stub::ref_count == 1);
123123

124124
dev.close_network();
125-
CHECK(ATHandler_stub::ref_count == -909);
125+
CHECK(ATHandler_stub::ref_count == kATHandler_destructor_ref_ount);
126126
}
127127

128128
void Test_AT_CellularDevice::test_AT_CellularDevice_close_sms()
@@ -137,7 +137,7 @@ void Test_AT_CellularDevice::test_AT_CellularDevice_close_sms()
137137
CHECK(ATHandler_stub::ref_count == 1);
138138

139139
dev.close_sms();
140-
CHECK(ATHandler_stub::ref_count == -909);
140+
CHECK(ATHandler_stub::ref_count == kATHandler_destructor_ref_ount);
141141
}
142142

143143
void Test_AT_CellularDevice::test_AT_CellularDevice_close_power()
@@ -152,7 +152,7 @@ void Test_AT_CellularDevice::test_AT_CellularDevice_close_power()
152152
CHECK(ATHandler_stub::ref_count == 1);
153153

154154
dev.close_power();
155-
CHECK(ATHandler_stub::ref_count == -909);
155+
CHECK(ATHandler_stub::ref_count == kATHandler_destructor_ref_ount);
156156
}
157157

158158
void Test_AT_CellularDevice::test_AT_CellularDevice_close_sim()
@@ -170,7 +170,7 @@ void Test_AT_CellularDevice::test_AT_CellularDevice_close_sim()
170170
CHECK(ATHandler_stub::ref_count == 1);
171171

172172
dev.close_sim();
173-
CHECK(ATHandler_stub::ref_count == -909);
173+
CHECK(ATHandler_stub::ref_count == kATHandler_destructor_ref_ount);
174174
}
175175

176176
void Test_AT_CellularDevice::test_AT_CellularDevice_close_information()

features/cellular/UNITTESTS/stubs/ATHandler_stub.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ void ATHandler::set_debug(bool debug_on)
6868

6969
ATHandler::~ATHandler()
7070
{
71-
ATHandler_stub::ref_count = -909;
71+
ATHandler_stub::ref_count = kATHandler_destructor_ref_ount;
7272
}
7373

7474
void ATHandler::inc_ref_count()

features/cellular/UNITTESTS/stubs/ATHandler_stub.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,8 @@
2626
static const int kRead_string_table_size = 100;
2727
static const int kRead_int_table_size = 100;
2828
static const int kResp_stop_count_default = 100;
29+
// set reference count to -909 to separate it from zero so we can test that ATHandler is really deleted.
30+
static const int kATHandler_destructor_ref_ount = -909;
2931

3032
namespace ATHandler_stub {
3133
extern nsapi_error_t nsapi_error_value;

0 commit comments

Comments
 (0)