@@ -47,12 +47,15 @@ class testContext : public CellularContext
47
47
{
48
48
_device = dev;
49
49
_cp_netif = new ControlPlane_netif_stub ();
50
+
51
+ nonip_pdp_string = NULL ;
50
52
}
51
53
52
54
~testContext ()
53
55
{
54
56
delete _cp_netif;
55
57
}
58
+
56
59
int get_retry_count ()
57
60
{
58
61
return _retry_count;
@@ -180,6 +183,11 @@ class testContext : public CellularContext
180
183
181
184
}
182
185
186
+ const char *get_nonip_context_type_str ()
187
+ {
188
+ return nonip_pdp_string;
189
+ }
190
+
183
191
void cp_data_received ()
184
192
{
185
193
CellularContext::cp_data_received ();
@@ -198,6 +206,58 @@ class testContext : public CellularContext
198
206
{
199
207
CellularContext::do_connect_with_retry ();
200
208
}
209
+
210
+ void test_string_to_pdp_type ()
211
+ {
212
+ pdp_type_t type = string_to_pdp_type (" IPV4V6" );
213
+ ASSERT_EQ (type, IPV4V6_PDP_TYPE);
214
+
215
+ type = string_to_pdp_type (" IPV6" );
216
+ ASSERT_EQ (type, IPV6_PDP_TYPE);
217
+
218
+ type = string_to_pdp_type (" IP" );
219
+ ASSERT_EQ (type, IPV4_PDP_TYPE);
220
+
221
+ type = string_to_pdp_type (" Non-IP" );
222
+ ASSERT_EQ (type, NON_IP_PDP_TYPE);
223
+
224
+ nonip_pdp_string = NULL ;
225
+ type = string_to_pdp_type (" diipadaapa" );
226
+ ASSERT_EQ (type, DEFAULT_PDP_TYPE);
227
+ }
228
+
229
+ void test_nonip_context_type_str ()
230
+ {
231
+ nonip_pdp_string = " NONIP" ;
232
+
233
+ pdp_type_t type = string_to_pdp_type (" diipadaapa" );
234
+ ASSERT_EQ (type, DEFAULT_PDP_TYPE);
235
+
236
+ type = string_to_pdp_type (" NONIP" );
237
+ ASSERT_EQ (type, NON_IP_PDP_TYPE);
238
+
239
+ type = string_to_pdp_type (" nonip" );
240
+ ASSERT_EQ (type, DEFAULT_PDP_TYPE);
241
+
242
+ type = string_to_pdp_type (" IPV6" );
243
+ ASSERT_EQ (type, IPV6_PDP_TYPE);
244
+
245
+ nonip_pdp_string = " testnonip" ;
246
+
247
+ type = string_to_pdp_type (" diipadaapa" );
248
+ ASSERT_EQ (type, DEFAULT_PDP_TYPE);
249
+
250
+ type = string_to_pdp_type (" testnonip" );
251
+ ASSERT_EQ (type, NON_IP_PDP_TYPE);
252
+
253
+ type = string_to_pdp_type (" nonip" );
254
+ ASSERT_EQ (type, DEFAULT_PDP_TYPE);
255
+
256
+ type = string_to_pdp_type (" IPV6" );
257
+ ASSERT_EQ (type, IPV6_PDP_TYPE);
258
+ }
259
+
260
+ const char *nonip_pdp_string;
201
261
};
202
262
203
263
static int network_cb_count = 0 ;
@@ -314,6 +374,20 @@ TEST_F(TestCellularContext, do_connect_with_retry_async)
314
374
delete dev;
315
375
}
316
376
377
+ TEST_F (TestCellularContext, string_to_pdp_type)
378
+ {
379
+ testContext *ctx = new testContext ();
380
+ EXPECT_TRUE (ctx != NULL );
317
381
382
+ ctx->test_string_to_pdp_type ();
383
+ delete ctx;
384
+ }
318
385
386
+ TEST_F (TestCellularContext, nonip_context_type_str)
387
+ {
388
+ testContext *ctx = new testContext ();
389
+ EXPECT_TRUE (ctx != NULL );
319
390
391
+ ctx->test_nonip_context_type_str ();
392
+ delete ctx;
393
+ }
0 commit comments