Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
test_m2mobject.cpp
00001 /* 00002 * Copyright (c) 2015 ARM Limited. All rights reserved. 00003 * SPDX-License-Identifier: Apache-2.0 00004 * Licensed under the Apache License, Version 2.0 (the License); you may 00005 * not use this file except in compliance with the License. 00006 * You may obtain a copy of the License at 00007 * 00008 * http://www.apache.org/licenses/LICENSE-2.0 00009 * 00010 * Unless required by applicable law or agreed to in writing, software 00011 * distributed under the License is distributed on an AS IS BASIS, WITHOUT 00012 * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 00013 * See the License for the specific language governing permissions and 00014 * limitations under the License. 00015 */ 00016 #include "CppUTest/TestHarness.h" 00017 #include "test_m2mobject.h" 00018 #include "m2mobjectinstance_stub.h" 00019 #include "m2mresource_stub.h" 00020 #include "m2mbase_stub.h" 00021 #include "common_stub.h" 00022 #include "m2mtlvdeserializer_stub.h" 00023 #include "m2mtlvserializer_stub.h" 00024 #include "m2mreporthandler_stub.h" 00025 #include "nsdlaccesshelper_stub.h" 00026 00027 class TestReportObserver : public M2MReportObserver{ 00028 public : 00029 TestReportObserver() {} 00030 ~TestReportObserver() {} 00031 void observation_to_be_sent(m2m::Vector<uint16_t>,bool){ } 00032 }; 00033 00034 class Handler : public M2MObservationHandler { 00035 00036 public: 00037 00038 Handler(){} 00039 ~Handler(){} 00040 void observation_to_be_sent(M2MBase *, uint16_t, m2m::Vector<uint16_t>,bool){ 00041 visited = true; 00042 } 00043 void send_delayed_response(M2MBase *){} 00044 void resource_to_be_deleted(M2MBase *){visited=true;} 00045 void remove_object(M2MBase *){visited = true;} 00046 void value_updated(M2MBase *,const String&){visited = true;} 00047 00048 void clear() {visited = false;} 00049 bool visited; 00050 }; 00051 00052 Test_M2MObject::Test_M2MObject() 00053 { 00054 handler = new Handler(); 00055 object = new M2MObject("name", "name"); 00056 } 00057 00058 Test_M2MObject::~Test_M2MObject() 00059 { 00060 m2mobjectinstance_stub::clear(); 00061 m2mresource_stub::clear(); 00062 m2mbase_stub::clear(); 00063 m2mtlvdeserializer_stub::clear(); 00064 m2mtlvserializer_stub::clear(); 00065 delete object; 00066 delete handler; 00067 } 00068 00069 void Test_M2MObject::test_ctor() 00070 { 00071 M2MObject *object = new M2MObject(¶ms); 00072 delete object; 00073 } 00074 00075 void Test_M2MObject::test_create_object_instance() 00076 { 00077 m2mbase_stub::name_id_value = 1; 00078 m2mbase_stub::string_value = "name"; 00079 CHECK(object->create_object_instance() != NULL); 00080 CHECK(object->create_object_instance(¶ms) != NULL); 00081 } 00082 00083 void Test_M2MObject::test_remove_object_instance() 00084 { 00085 m2mbase_stub::string_value = "name"; 00086 00087 M2MObjectInstance *ins = new M2MObjectInstance(*object,"name","type", ""); 00088 object->set_instance_id(0); 00089 object->_instance_list.push_back(ins); 00090 00091 CHECK(true == object->remove_object_instance(0)); 00092 00093 CHECK(false == object->remove_object_instance(0)); 00094 } 00095 00096 void Test_M2MObject::test_object_instance() 00097 { 00098 M2MObjectInstance *ins = new M2MObjectInstance(*object, "name", "type", ""); 00099 object->set_instance_id(0); 00100 object->_instance_list.push_back(ins); 00101 00102 m2mbase_stub::string_value = "name"; 00103 00104 M2MObjectInstance *obj = object->object_instance(0); 00105 00106 CHECK(obj != NULL); 00107 STRCMP_EQUAL(obj->name(), "name"); 00108 //CHECK(0 == obj->name().compare(0,test->size(),*test)); 00109 } 00110 00111 void Test_M2MObject::test_instances() 00112 { 00113 00114 M2MObjectInstance *ins = new M2MObjectInstance(*object, "name", "type", ""); 00115 ins->set_instance_id(0); 00116 object->_instance_list.push_back(ins); 00117 00118 M2MObjectInstance *ins1 = new M2MObjectInstance(*object, "name","type", ""); 00119 ins1->set_instance_id(1); 00120 object->_instance_list.push_back(ins1); 00121 00122 m2mbase_stub::string_value = "name"; 00123 00124 M2MObjectInstanceList list = object->instances(); 00125 00126 M2MObjectInstance *obj = list[0]; 00127 CHECK(2 == list.size()); 00128 STRCMP_EQUAL(obj->name(), "name"); 00129 //CHECK(0 == obj->name().compare(0,test->size(),*test)); 00130 } 00131 00132 void Test_M2MObject::test_instance_count() 00133 { 00134 M2MObjectInstance *ins = new M2MObjectInstance(*object, "name", "type", ""); 00135 object->set_instance_id(0); 00136 object->_instance_list.push_back(ins); 00137 00138 M2MObjectInstance *ins1 = new M2MObjectInstance(*object, "name", "type", ""); 00139 object->set_instance_id(1); 00140 object->_instance_list.push_back(ins1); 00141 00142 CHECK(2 == object->instance_count()); 00143 00144 object->_instance_list.clear(); 00145 delete ins; 00146 delete ins1; 00147 } 00148 00149 void Test_M2MObject::test_base_type() 00150 { 00151 CHECK(M2MBase::Object == object->base_type()); 00152 } 00153 00154 void Test_M2MObject::test_handle_get_request() 00155 { 00156 M2MObjectInstance *ins = new M2MObjectInstance(*object, "name", "type", ""); 00157 object->set_instance_id(0); 00158 object->_instance_list.push_back(ins); 00159 00160 uint8_t value[] = {"name"}; 00161 sn_coap_hdr_s *coap_header = (sn_coap_hdr_s *)malloc(sizeof(sn_coap_hdr_s)); 00162 memset(coap_header, 0, sizeof(sn_coap_hdr_s)); 00163 00164 coap_header->uri_path_ptr = value; 00165 coap_header->uri_path_len = sizeof(value); 00166 00167 coap_header->msg_code = COAP_MSG_CODE_REQUEST_GET; 00168 00169 common_stub::int_value = 0; 00170 m2mbase_stub::string_value = "name"; 00171 00172 m2mbase_stub::operation = M2MBase::GET_ALLOWED; 00173 m2mbase_stub::uint8_value = 200; 00174 00175 common_stub::coap_header = (sn_coap_hdr_ *)malloc(sizeof(sn_coap_hdr_)); 00176 memset(common_stub::coap_header,0,sizeof(sn_coap_hdr_)); 00177 common_stub::coap_header->options_list_ptr = (sn_coap_options_list_s*)malloc(sizeof(sn_coap_options_list_s)); 00178 m2mtlvserializer_stub::uint8_value = (uint8_t*)malloc(1); 00179 00180 coap_header->token_ptr = (uint8_t*)malloc(sizeof(value)); 00181 memcpy(coap_header->token_ptr, value, sizeof(value)); 00182 00183 coap_header->options_list_ptr = (sn_coap_options_list_s*)malloc(sizeof(sn_coap_options_list_s)); 00184 coap_header->options_list_ptr->observe = 0; 00185 00186 coap_header->content_format = sn_coap_content_format_e(110); 00187 00188 CHECK(object->handle_get_request(NULL,coap_header,handler) != NULL); 00189 00190 // Not OMA TLV or JSON 00191 m2mbase_stub::uint8_value = 110; 00192 CHECK(object->handle_get_request(NULL,coap_header,handler) != NULL); 00193 00194 // Content type set CT_NONE 00195 m2mbase_stub::uint8_value = 99; 00196 coap_header->content_format = sn_coap_content_format_e(-1); 00197 CHECK(object->handle_get_request(NULL,coap_header,handler) != NULL); 00198 00199 common_stub::coap_header->content_format = sn_coap_content_format_e(-1); // CT_NONE 00200 m2mbase_stub::uint8_value = 100; 00201 coap_header->content_format = sn_coap_content_format_e(-1); 00202 CHECK(object->handle_get_request(NULL,coap_header,handler) != NULL); 00203 00204 // OMA TLV 00205 coap_header->content_format = sn_coap_content_format_e(99); 00206 m2mbase_stub::uint8_value = 99; 00207 CHECK(object->handle_get_request(NULL,coap_header,handler) != NULL); 00208 00209 // OMA JSON 00210 coap_header->content_format = sn_coap_content_format_e(100); 00211 m2mbase_stub::uint8_value = 100; 00212 CHECK(object->handle_get_request(NULL,coap_header,handler) != NULL); 00213 00214 coap_header->options_list_ptr->observe = 0; 00215 m2mbase_stub::uint16_value = 0x1c1c; 00216 m2mbase_stub::uint8_value = 99; 00217 m2mbase_stub::bool_value = true; 00218 coap_header->content_format = sn_coap_content_format_e(99); 00219 00220 CHECK(object->handle_get_request(NULL,coap_header,handler) != NULL); 00221 00222 m2mbase_stub::uint16_value = 10; 00223 CHECK(object->handle_get_request(NULL,coap_header,handler) != NULL); 00224 00225 // Not observable 00226 m2mbase_stub::bool_value = false; 00227 CHECK(object->handle_get_request(NULL,coap_header,handler) != NULL); 00228 00229 m2mbase_stub::bool_value = true; 00230 coap_header->options_list_ptr->observe = 0; 00231 00232 CHECK(object->handle_get_request(NULL,coap_header,handler) != NULL); 00233 00234 coap_header->options_list_ptr->observe = 1; 00235 CHECK(object->handle_get_request(NULL,coap_header,handler) != NULL); 00236 00237 m2mbase_stub::operation = M2MBase::NOT_ALLOWED; 00238 CHECK(object->handle_get_request(NULL,coap_header,handler) != NULL); 00239 00240 CHECK(object->handle_get_request(NULL,NULL,handler) != NULL); 00241 00242 if(coap_header->token_ptr) { 00243 free(coap_header->token_ptr); 00244 coap_header->token_ptr = NULL; 00245 } 00246 if(coap_header->options_list_ptr) { 00247 free(coap_header->options_list_ptr); 00248 coap_header->options_list_ptr = NULL; 00249 } 00250 00251 if(common_stub::coap_header){ 00252 if(common_stub::coap_header->options_list_ptr) { 00253 free(common_stub::coap_header->options_list_ptr); 00254 common_stub::coap_header->options_list_ptr = NULL; 00255 } 00256 free(common_stub::coap_header); 00257 common_stub::coap_header = NULL; 00258 } 00259 free(coap_header); 00260 coap_header = NULL; 00261 00262 if(m2mtlvserializer_stub::uint8_value) { 00263 free(m2mtlvserializer_stub::uint8_value); 00264 } 00265 m2mtlvserializer_stub::clear(); 00266 00267 m2mbase_stub::clear(); 00268 common_stub::clear(); 00269 00270 object->_instance_list.clear(); 00271 delete ins; 00272 } 00273 00274 void Test_M2MObject::test_handle_put_request() 00275 { 00276 uint8_t value[] = {"name"}; 00277 bool execute_value_updated = false; 00278 sn_coap_hdr_s *coap_header = (sn_coap_hdr_s *)malloc(sizeof(sn_coap_hdr_s)); 00279 memset(coap_header, 0, sizeof(sn_coap_hdr_s)); 00280 sn_coap_hdr_s * coap_response = NULL; 00281 00282 coap_header->uri_path_ptr = value; 00283 coap_header->uri_path_len = sizeof(value); 00284 00285 coap_header->msg_code = COAP_MSG_CODE_REQUEST_PUT; 00286 00287 common_stub::int_value = 0; 00288 m2mbase_stub::string_value = "name"; 00289 00290 m2mbase_stub::operation = M2MBase::PUT_ALLOWED; 00291 m2mbase_stub::uint8_value = 200; 00292 00293 common_stub::coap_header = (sn_coap_hdr_ *)malloc(sizeof(sn_coap_hdr_)); 00294 memset(common_stub::coap_header,0,sizeof(sn_coap_hdr_)); 00295 00296 coap_header->payload_ptr = (uint8_t*)malloc(1); 00297 00298 CHECK(object->handle_put_request(NULL,coap_header,handler,execute_value_updated) != NULL); 00299 free(coap_header->payload_ptr); 00300 coap_header->payload_ptr = NULL; 00301 00302 CHECK(object->handle_put_request(NULL,coap_header,handler,execute_value_updated) != NULL); 00303 00304 coap_header->options_list_ptr = (sn_coap_options_list_s*)malloc(sizeof(sn_coap_options_list_s)); 00305 coap_header->options_list_ptr->uri_query_ptr = value; 00306 coap_header->options_list_ptr->uri_query_len = sizeof(value); 00307 00308 coap_header->content_format = sn_coap_content_format_e(99); 00309 m2mtlvdeserializer_stub::bool_value = true; 00310 00311 m2mbase_stub::bool_value = false; 00312 00313 CHECK(object->handle_put_request(NULL,coap_header,handler,execute_value_updated) != NULL); 00314 00315 m2mtlvdeserializer_stub::bool_value = false; 00316 00317 CHECK(object->handle_put_request(NULL,coap_header,handler, execute_value_updated) != NULL); 00318 00319 coap_header->content_format = sn_coap_content_format_e(100); 00320 00321 CHECK(object->handle_put_request(NULL,coap_header,handler, execute_value_updated) != NULL); 00322 00323 m2mbase_stub::bool_value = true; 00324 00325 CHECK(object->handle_put_request(NULL,coap_header,handler, execute_value_updated) != NULL); 00326 00327 m2mbase_stub::operation = M2MBase::NOT_ALLOWED; 00328 00329 CHECK(object->handle_put_request(NULL,coap_header,handler, execute_value_updated) != NULL); 00330 00331 CHECK(object->handle_put_request(NULL,NULL,handler, execute_value_updated) != NULL); 00332 00333 m2mbase_stub::operation = M2MBase::PUT_ALLOWED; 00334 00335 free(coap_header->payload_ptr); 00336 coap_header->payload_ptr = NULL; 00337 coap_response = object->handle_put_request(NULL,coap_header,handler,execute_value_updated); 00338 CHECK(coap_response != NULL); 00339 CHECK(coap_response->msg_code == COAP_MSG_CODE_RESPONSE_CHANGED); 00340 00341 m2mbase_stub::bool_value = false; 00342 coap_response = object->handle_put_request(NULL,coap_header,handler,execute_value_updated); 00343 CHECK(coap_response != NULL); 00344 CHECK(coap_response->msg_code == COAP_MSG_CODE_RESPONSE_BAD_REQUEST); 00345 00346 free(coap_header->options_list_ptr); 00347 coap_header->options_list_ptr = NULL; 00348 coap_response = object->handle_put_request(NULL,coap_header,handler,execute_value_updated); 00349 CHECK(coap_response != NULL); 00350 CHECK(coap_response->msg_code == COAP_MSG_CODE_RESPONSE_BAD_REQUEST); 00351 00352 free(coap_header->options_list_ptr); 00353 free(common_stub::coap_header); 00354 free(coap_header); 00355 00356 m2mtlvdeserializer_stub::clear(); 00357 common_stub::clear(); 00358 m2mbase_stub::clear(); 00359 } 00360 00361 void Test_M2MObject::test_handle_post_request() 00362 { 00363 uint8_t value[] = {"name"}; 00364 bool execute_value_updated = false; 00365 sn_coap_hdr_s *coap_header = (sn_coap_hdr_s *)malloc(sizeof(sn_coap_hdr_s)); 00366 memset(coap_header, 0, sizeof(sn_coap_hdr_s)); 00367 00368 coap_header->uri_path_ptr = value; 00369 coap_header->uri_path_len = sizeof(value); 00370 00371 coap_header->msg_code = COAP_MSG_CODE_REQUEST_POST; 00372 00373 common_stub::int_value = 0; 00374 m2mbase_stub::string_value = "name"; 00375 00376 m2mbase_stub::operation = M2MBase::POST_ALLOWED; 00377 m2mbase_stub::uint8_value = 200; 00378 00379 common_stub::coap_header = (sn_coap_hdr_ *)malloc(sizeof(sn_coap_hdr_)); 00380 memset(common_stub::coap_header,0,sizeof(sn_coap_hdr_)); 00381 common_stub::coap_header->options_list_ptr = (sn_coap_options_list_s*)malloc(sizeof(sn_coap_options_list_s)); 00382 00383 m2mbase_stub::bool_value = false; 00384 00385 sn_coap_hdr_s * coap_response = NULL; 00386 m2mbase_stub::uint8_value = 99; 00387 00388 coap_response = object->handle_post_request(NULL,coap_header,handler,execute_value_updated); 00389 CHECK( coap_response != NULL); 00390 00391 00392 m2mbase_stub::uint8_value = 100; 00393 00394 coap_response = object->handle_post_request(NULL,coap_header,handler,execute_value_updated); 00395 CHECK( coap_response != NULL); 00396 00397 coap_header->payload_ptr = (uint8_t*)malloc(1); 00398 00399 coap_response = object->handle_post_request(NULL,coap_header,handler,execute_value_updated); 00400 CHECK( coap_response != NULL); 00401 00402 m2mbase_stub::uint8_value = 99; 00403 00404 object->_max_instance_count = 0; 00405 00406 M2MObjectInstance *ins = new M2MObjectInstance(*object, "name", "type", ""); 00407 ins->set_instance_id(0); 00408 object->_instance_list.push_back(ins); 00409 coap_header->content_format = sn_coap_content_format_e(-1); 00410 coap_response = object->handle_post_request(NULL,coap_header,handler,execute_value_updated); 00411 CHECK( coap_response != NULL); 00412 00413 object->remove_object_instance(0); 00414 00415 00416 object->_max_instance_count = 65535; 00417 00418 m2mbase_stub::uint8_value = 0; 00419 00420 coap_header->options_list_ptr = (sn_coap_options_list_s*)malloc(sizeof(sn_coap_options_list_s)); 00421 coap_header->options_list_ptr->uri_query_ptr = value; 00422 coap_header->options_list_ptr->uri_query_len = sizeof(value); 00423 00424 coap_header->content_format = sn_coap_content_format_e(99); 00425 m2mtlvdeserializer_stub::is_object_bool_value = true; 00426 m2mtlvdeserializer_stub::bool_value = false; 00427 m2mbase_stub::bool_value = false; 00428 00429 m2mtlvdeserializer_stub::error = M2MTLVDeserializer::None; 00430 coap_response = object->handle_post_request(NULL,coap_header,handler,execute_value_updated); 00431 00432 CHECK( coap_response != NULL); 00433 if(coap_response) { 00434 if (coap_response->options_list_ptr->location_path_ptr) { 00435 free(coap_response->options_list_ptr->location_path_ptr); 00436 coap_response->options_list_ptr->location_path_ptr = NULL; 00437 } 00438 // if (coap_response->options_list_ptr) { 00439 // free(coap_response->options_list_ptr); 00440 // coap_response->options_list_ptr = NULL; 00441 // } 00442 } 00443 00444 m2mbase_stub::operation = M2MBase::POST_ALLOWED; 00445 m2mtlvdeserializer_stub::is_object_bool_value = true; 00446 m2mtlvdeserializer_stub::bool_value = false; 00447 m2mtlvdeserializer_stub::int_value = 10; 00448 m2mbase_stub::bool_value = false; 00449 00450 m2mtlvdeserializer_stub::error = M2MTLVDeserializer::NotAllowed; 00451 00452 coap_response = object->handle_post_request(NULL,coap_header,handler,execute_value_updated); 00453 00454 CHECK( coap_response != NULL); 00455 if(coap_response) { 00456 if (coap_response->options_list_ptr) { 00457 if (coap_response->options_list_ptr->location_path_ptr) { 00458 free(coap_response->options_list_ptr->location_path_ptr); 00459 coap_response->options_list_ptr->location_path_ptr = NULL; 00460 } 00461 // free(coap_response->options_list_ptr); 00462 // coap_response->options_list_ptr = NULL; 00463 } 00464 } 00465 00466 m2mbase_stub::operation = M2MBase::POST_ALLOWED; 00467 m2mtlvdeserializer_stub::is_object_bool_value = false; 00468 m2mtlvdeserializer_stub::bool_value = true; 00469 m2mbase_stub::bool_value = false; 00470 m2mtlvdeserializer_stub::error = M2MTLVDeserializer::None; 00471 00472 coap_response = object->handle_post_request(NULL,coap_header,handler,execute_value_updated); 00473 00474 CHECK( coap_response != NULL); 00475 if(coap_response) { 00476 if (coap_response->options_list_ptr) { 00477 if (coap_response->options_list_ptr->location_path_ptr) { 00478 free(coap_response->options_list_ptr->location_path_ptr); 00479 coap_response->options_list_ptr->location_path_ptr = NULL; 00480 } 00481 // free(coap_response->options_list_ptr); 00482 // coap_response->options_list_ptr = NULL; 00483 } 00484 } 00485 00486 m2mbase_stub::operation = M2MBase::POST_ALLOWED; 00487 m2mtlvdeserializer_stub::is_object_bool_value = false; 00488 m2mtlvdeserializer_stub::bool_value = true; 00489 m2mbase_stub::bool_value = false; 00490 m2mtlvdeserializer_stub::error = M2MTLVDeserializer::NotFound; 00491 00492 coap_response = object->handle_post_request(NULL,coap_header,handler,execute_value_updated); 00493 00494 CHECK( coap_response != NULL); 00495 if(coap_response) { 00496 if (coap_response->options_list_ptr) { 00497 if (coap_response->options_list_ptr->location_path_ptr) { 00498 free(coap_response->options_list_ptr->location_path_ptr); 00499 coap_response->options_list_ptr->location_path_ptr = NULL; 00500 } 00501 // free(coap_response->options_list_ptr); 00502 // coap_response->options_list_ptr = NULL; 00503 } 00504 } 00505 00506 m2mbase_stub::operation = M2MBase::POST_ALLOWED; 00507 m2mtlvdeserializer_stub::bool_value = false; 00508 00509 coap_response = object->handle_post_request(NULL,coap_header,handler,execute_value_updated); 00510 00511 CHECK( coap_response != NULL); 00512 if(coap_response) { 00513 if (coap_response->options_list_ptr) { 00514 if (coap_response->options_list_ptr->location_path_ptr) { 00515 free(coap_response->options_list_ptr->location_path_ptr); 00516 coap_response->options_list_ptr->location_path_ptr = NULL; 00517 } 00518 // free(coap_response->options_list_ptr); 00519 // coap_response->options_list_ptr = NULL; 00520 } 00521 } 00522 00523 00524 coap_header->content_format = sn_coap_content_format_e(100); 00525 00526 coap_response = object->handle_post_request(NULL,coap_header,handler,execute_value_updated); 00527 00528 CHECK( coap_response != NULL); 00529 if(coap_response) { 00530 if (coap_response->options_list_ptr) { 00531 if (coap_response->options_list_ptr->location_path_ptr) { 00532 free(coap_response->options_list_ptr->location_path_ptr); 00533 coap_response->options_list_ptr->location_path_ptr = NULL; 00534 } 00535 // free(coap_response->options_list_ptr); 00536 // coap_response->options_list_ptr = NULL; 00537 } 00538 } 00539 00540 00541 m2mbase_stub::bool_value = true; 00542 00543 coap_response = object->handle_post_request(NULL,coap_header,handler,execute_value_updated); 00544 00545 CHECK( coap_response != NULL); 00546 if(coap_response) { 00547 if (coap_response->options_list_ptr) { 00548 if (coap_response->options_list_ptr->location_path_ptr) { 00549 free(coap_response->options_list_ptr->location_path_ptr); 00550 coap_response->options_list_ptr->location_path_ptr = NULL; 00551 } 00552 // free(coap_response->options_list_ptr); 00553 // coap_response->options_list_ptr = NULL; 00554 } 00555 } 00556 00557 00558 m2mbase_stub::operation = M2MBase::NOT_ALLOWED; 00559 00560 coap_response = object->handle_post_request(NULL,coap_header,handler,execute_value_updated); 00561 00562 CHECK( coap_response != NULL); 00563 00564 coap_response = object->handle_post_request(NULL,NULL,handler,execute_value_updated); 00565 00566 CHECK( coap_response != NULL); 00567 if(coap_response) { 00568 if (coap_response->options_list_ptr) { 00569 if (coap_response->options_list_ptr->location_path_ptr) { 00570 free(coap_response->options_list_ptr->location_path_ptr); 00571 coap_response->options_list_ptr->location_path_ptr = NULL; 00572 } 00573 // free(coap_response->options_list_ptr); 00574 // coap_response->options_list_ptr = NULL; 00575 } 00576 } 00577 00578 m2mbase_stub::operation = M2MBase::POST_ALLOWED; 00579 m2mtlvdeserializer_stub::int_value = 0; 00580 m2mtlvdeserializer_stub::is_object_bool_value = true; 00581 coap_header->content_format = sn_coap_content_format_e(99); 00582 coap_response = object->handle_post_request(NULL,coap_header,handler,execute_value_updated); 00583 00584 CHECK( coap_response != NULL); 00585 if(coap_response) { 00586 if (coap_response->options_list_ptr) { 00587 if (coap_response->options_list_ptr->location_path_ptr) { 00588 free(coap_response->options_list_ptr->location_path_ptr); 00589 coap_response->options_list_ptr->location_path_ptr = NULL; 00590 } 00591 // free(coap_response->options_list_ptr); 00592 // coap_response->options_list_ptr = NULL; 00593 } 00594 } 00595 00596 free(coap_header->options_list_ptr); 00597 free(coap_header->payload_ptr); 00598 free(common_stub::coap_header->options_list_ptr); 00599 free(common_stub::coap_header); 00600 free(coap_header); 00601 00602 m2mtlvdeserializer_stub::clear(); 00603 common_stub::clear(); 00604 m2mbase_stub::clear(); 00605 } 00606 00607 void Test_M2MObject::test_notification_update() 00608 { 00609 TestReportObserver obs; 00610 m2mbase_stub::report = new M2MReportHandler(obs); 00611 m2mbase_stub::bool_value = true; 00612 00613 object->notification_update(0); 00614 00615 delete m2mbase_stub::report; 00616 m2mbase_stub::report = NULL; 00617 } 00618
Generated on Tue Jul 12 2022 21:20:29 by
