@@ -47,12 +47,15 @@ class testContext : public CellularContext
4747 {
4848 _device = dev;
4949 _cp_netif = new ControlPlane_netif_stub ();
50+
51+ nonip_pdp_string = NULL ;
5052 }
5153
5254 ~testContext ()
5355 {
5456 delete _cp_netif;
5557 }
58+
5659 int get_retry_count ()
5760 {
5861 return _retry_count;
@@ -180,6 +183,11 @@ class testContext : public CellularContext
180183
181184 }
182185
186+ const char *get_nonip_context_type_str ()
187+ {
188+ return nonip_pdp_string;
189+ }
190+
183191 void cp_data_received ()
184192 {
185193 CellularContext::cp_data_received ();
@@ -198,6 +206,58 @@ class testContext : public CellularContext
198206 {
199207 CellularContext::do_connect_with_retry ();
200208 }
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;
201261};
202262
203263static int network_cb_count = 0 ;
@@ -314,6 +374,20 @@ TEST_F(TestCellularContext, do_connect_with_retry_async)
314374 delete dev;
315375}
316376
377+ TEST_F (TestCellularContext, string_to_pdp_type)
378+ {
379+ testContext *ctx = new testContext ();
380+ EXPECT_TRUE (ctx != NULL );
317381
382+ ctx->test_string_to_pdp_type ();
383+ delete ctx;
384+ }
318385
386+ TEST_F (TestCellularContext, nonip_context_type_str)
387+ {
388+ testContext *ctx = new testContext ();
389+ EXPECT_TRUE (ctx != NULL );
319390
391+ ctx->test_nonip_context_type_str ();
392+ delete ctx;
393+ }
0 commit comments