20
20
#include " ATHandler_stub.h"
21
21
#include " EventQueue.h"
22
22
#include " FileHandle_stub.h"
23
+ #include " AT_CellularBase_stub.h"
23
24
#include " ATHandler.h"
24
25
#include " AT_CellularInformation.h"
25
26
#include " AT_CellularBase.h"
@@ -43,10 +44,19 @@ void Test_AT_CellularInformation::test_AT_CellularInformation_get_manufacturer()
43
44
ATHandler ah (&fh, eq, 0 , " ," );
44
45
AT_CellularInformation aci (ah);
45
46
46
- ATHandler_stub::nsapi_error_value = 8 ;
47
+ ATHandler_stub::nsapi_error_value = NSAPI_ERROR_OK;
48
+ ATHandler_stub::read_string_value = " some" ;
49
+ ATHandler_stub::ssize_value = 4 ;
47
50
48
51
char buf[8 ];
49
- CHECK (8 == aci.get_manufacturer (buf, 8 ));
52
+ CHECK (NSAPI_ERROR_OK == aci.get_manufacturer (buf, 8 ));
53
+ CHECK (strcmp (" some" , buf) == 0 );
54
+
55
+ ATHandler_stub::nsapi_error_value = NSAPI_ERROR_DEVICE_ERROR;
56
+ ATHandler_stub::ssize_value = -1 ;
57
+ buf[0 ] = 0 ;
58
+ CHECK (NSAPI_ERROR_DEVICE_ERROR == aci.get_manufacturer (buf, 8 ));
59
+ CHECK (strlen (buf) == 0 );
50
60
}
51
61
52
62
void Test_AT_CellularInformation::test_AT_CellularInformation_get_model ()
@@ -56,10 +66,18 @@ void Test_AT_CellularInformation::test_AT_CellularInformation_get_model()
56
66
ATHandler ah (&fh, eq, 0 , " ," );
57
67
AT_CellularInformation aci (ah);
58
68
59
- ATHandler_stub::nsapi_error_value = 7 ;
60
-
69
+ ATHandler_stub::nsapi_error_value = NSAPI_ERROR_OK;
70
+ ATHandler_stub::read_string_value = " model" ;
71
+ ATHandler_stub::ssize_value = 5 ;
61
72
char buf[8 ];
62
- CHECK (7 == aci.get_model (buf, 8 ));
73
+ CHECK (NSAPI_ERROR_OK == aci.get_model (buf, 8 ));
74
+ CHECK (strcmp (" model" , buf) == 0 );
75
+
76
+ ATHandler_stub::nsapi_error_value = NSAPI_ERROR_DEVICE_ERROR;
77
+ ATHandler_stub::ssize_value = -1 ;
78
+ buf[0 ] = 0 ;
79
+ CHECK (NSAPI_ERROR_DEVICE_ERROR == aci.get_model (buf, 8 ));
80
+ CHECK (strlen (buf) == 0 );
63
81
}
64
82
65
83
void Test_AT_CellularInformation::test_AT_CellularInformation_get_revision ()
@@ -71,11 +89,53 @@ void Test_AT_CellularInformation::test_AT_CellularInformation_get_revision()
71
89
// Used heap var here to visit heap constructor
72
90
AT_CellularInformation *aci = new AT_CellularInformation (ah);
73
91
74
- ATHandler_stub::nsapi_error_value = 6 ;
92
+ ATHandler_stub::nsapi_error_value = NSAPI_ERROR_OK;
93
+ ATHandler_stub::read_string_value = " revision" ;
94
+ ATHandler_stub::ssize_value = 8 ;
75
95
76
- char buf[8 ];
77
- CHECK (6 == aci->get_revision (buf, 8 ));
96
+ char buf[9 ];
97
+ CHECK (NSAPI_ERROR_OK == aci->get_revision (buf, 9 ));
98
+ CHECK (strcmp (" revision" , buf) == 0 );
99
+
100
+ ATHandler_stub::nsapi_error_value = NSAPI_ERROR_DEVICE_ERROR;
101
+ ATHandler_stub::ssize_value = -1 ;
102
+ buf[0 ] = 0 ;
103
+ CHECK (NSAPI_ERROR_DEVICE_ERROR == aci->get_revision (buf, 8 ));
104
+ CHECK (strlen (buf) == 0 );
78
105
79
106
delete aci;
80
107
}
81
108
109
+ void Test_AT_CellularInformation::test_AT_CellularInformation_get_serial_number ()
110
+ {
111
+ EventQueue eq;
112
+ FileHandle_stub fh;
113
+ ATHandler ah (&fh, eq, 0 , " ," );
114
+ AT_CellularInformation aci (ah);
115
+
116
+ ATHandler_stub::nsapi_error_value = NSAPI_ERROR_OK;
117
+ ATHandler_stub::read_string_value = " 1234567" ;
118
+ ATHandler_stub::ssize_value = 7 ;
119
+ char buf[8 ];
120
+
121
+ CHECK (NSAPI_ERROR_OK == aci.get_serial_number (buf, 8 , CellularInformation::SN));
122
+ CHECK (strcmp (" 1234567" , buf) == 0 );
123
+
124
+ ATHandler_stub::nsapi_error_value = NSAPI_ERROR_DEVICE_ERROR;
125
+ ATHandler_stub::ssize_value = -1 ;
126
+ buf[0 ] = 0 ;
127
+ CHECK (NSAPI_ERROR_DEVICE_ERROR == aci.get_serial_number (buf, 8 , CellularInformation::SN));
128
+ CHECK (strlen (buf) == 0 );
129
+
130
+ AT_CellularBase_stub::supported_bool = false ;
131
+ CHECK (NSAPI_ERROR_UNSUPPORTED == aci.get_serial_number (buf, 8 , CellularInformation::IMEI));
132
+ CHECK (strlen (buf) == 0 );
133
+
134
+ ATHandler_stub::nsapi_error_value = NSAPI_ERROR_OK;
135
+ ATHandler_stub::read_string_value = " 1234567" ;
136
+ ATHandler_stub::ssize_value = 7 ;
137
+ AT_CellularBase_stub::supported_bool = true ;
138
+ CHECK (NSAPI_ERROR_OK == aci.get_serial_number (buf, 8 , CellularInformation::IMEI));
139
+ CHECK (strcmp (" 1234567" , buf) == 0 );
140
+ }
141
+
0 commit comments