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.
Dependencies: MAX44000 PWM_Tone_Library nexpaq_mdk
Fork of LED_Demo by
test_m2minterfacefactory.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_m2minterfacefactory.h" 00018 #include "m2minterfaceobserver.h" 00019 #include "m2mserver.h" 00020 #include "m2mdevice.h" 00021 #include "m2mfirmware.h" 00022 00023 class TestObserver : public M2MInterfaceObserver { 00024 00025 public: 00026 TestObserver(){} 00027 void bootstrap_done(M2MSecurity */*server_object*/){} 00028 void object_registered(M2MSecurity */*security_object*/, 00029 const M2MServer &/*server_object*/) {} 00030 00031 void object_unregistered(M2MSecurity */*server_object*/){} 00032 00033 void registration_updated(M2MSecurity */*security_object*/, 00034 const M2MServer &/*server_object*/){} 00035 00036 void error(M2MInterface::Error /*error*/){} 00037 00038 void value_updated(M2MBase */*base*/, M2MBase::BaseType /*type*/){} 00039 }; 00040 00041 Test_M2MInterfaceFactory::Test_M2MInterfaceFactory() 00042 { 00043 } 00044 00045 Test_M2MInterfaceFactory::~Test_M2MInterfaceFactory() 00046 { 00047 00048 } 00049 00050 void Test_M2MInterfaceFactory::test_create_interface() 00051 { 00052 TestObserver test_obs; 00053 M2MInterface *test = M2MInterfaceFactory::create_interface(test_obs, 00054 "endpoint_name", 00055 "endpoint_type", 00056 120, 00057 8000, 00058 "domain"); 00059 CHECK(test != NULL); 00060 delete test; 00061 test = NULL; 00062 00063 // Endpoint name and type of length more than 64 characters 00064 test = M2MInterfaceFactory::create_interface(test_obs, 00065 "endpoint_name-very-long-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1", 00066 "endpoint_type-very-long-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1", 00067 120, 00068 8000, 00069 "domain"); 00070 CHECK(test == NULL); 00071 delete test; 00072 00073 // Domain length more than 64 characters 00074 test = M2MInterfaceFactory::create_interface(test_obs, 00075 "endpoint_name", 00076 "endpoint_type", 00077 120, 00078 8000, 00079 "domaidomaindomaindomaindomaindomaindomaindomaindomaindomaindomaindomaindomaindomain"); 00080 CHECK(test == NULL); 00081 delete test; 00082 00083 } 00084 00085 void Test_M2MInterfaceFactory::test_create_security() 00086 { 00087 M2MSecurity *test = M2MInterfaceFactory::create_security(M2MSecurity::Bootstrap); 00088 CHECK(test != NULL); 00089 delete test; 00090 test = NULL; 00091 } 00092 00093 void Test_M2MInterfaceFactory::test_create_device() 00094 { 00095 M2MDevice *test = M2MInterfaceFactory::create_device(); 00096 CHECK(test != NULL); 00097 delete test; 00098 test = NULL; 00099 } 00100 00101 void Test_M2MInterfaceFactory::test_create_firmware() 00102 { 00103 M2MFirmware *test = M2MInterfaceFactory::create_firmware(); 00104 CHECK(test != NULL); 00105 delete test; 00106 test = NULL; 00107 } 00108 00109 void Test_M2MInterfaceFactory::test_create_server() 00110 { 00111 M2MServer *test = M2MInterfaceFactory::create_server(); 00112 CHECK(test != NULL); 00113 delete test; 00114 test = NULL; 00115 } 00116 00117 void Test_M2MInterfaceFactory::test_create_object() 00118 { 00119 M2MObject *test = M2MInterfaceFactory::create_object("name"); 00120 CHECK(test != NULL); 00121 delete test; 00122 test = NULL; 00123 00124 // Length 65, should fail 00125 String max_lenght = "65656565656565656565656565656565656565656565656565656565656565656"; 00126 CHECK(M2MInterfaceFactory::create_object("") == NULL); 00127 CHECK(M2MInterfaceFactory::create_object(max_lenght) == NULL); 00128 }
Generated on Tue Jul 12 2022 12:28:54 by
