Ram Gandikota
/
ABCD
A metronome using the FRDM K64F board
mbed-client/test/mbedclient/utest/m2mserver/test_m2mserver.cpp@0:a7a43371b306, 2017-05-14 (annotated)
- Committer:
- ram54288
- Date:
- Sun May 14 18:40:18 2017 +0000
- Revision:
- 0:a7a43371b306
Initial commit
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
ram54288 | 0:a7a43371b306 | 1 | /* |
ram54288 | 0:a7a43371b306 | 2 | * Copyright (c) 2015 ARM Limited. All rights reserved. |
ram54288 | 0:a7a43371b306 | 3 | * SPDX-License-Identifier: Apache-2.0 |
ram54288 | 0:a7a43371b306 | 4 | * Licensed under the Apache License, Version 2.0 (the License); you may |
ram54288 | 0:a7a43371b306 | 5 | * not use this file except in compliance with the License. |
ram54288 | 0:a7a43371b306 | 6 | * You may obtain a copy of the License at |
ram54288 | 0:a7a43371b306 | 7 | * |
ram54288 | 0:a7a43371b306 | 8 | * http://www.apache.org/licenses/LICENSE-2.0 |
ram54288 | 0:a7a43371b306 | 9 | * |
ram54288 | 0:a7a43371b306 | 10 | * Unless required by applicable law or agreed to in writing, software |
ram54288 | 0:a7a43371b306 | 11 | * distributed under the License is distributed on an AS IS BASIS, WITHOUT |
ram54288 | 0:a7a43371b306 | 12 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
ram54288 | 0:a7a43371b306 | 13 | * See the License for the specific language governing permissions and |
ram54288 | 0:a7a43371b306 | 14 | * limitations under the License. |
ram54288 | 0:a7a43371b306 | 15 | */ |
ram54288 | 0:a7a43371b306 | 16 | #include "CppUTest/TestHarness.h" |
ram54288 | 0:a7a43371b306 | 17 | #include "test_m2mserver.h" |
ram54288 | 0:a7a43371b306 | 18 | #include "m2mobject_stub.h" |
ram54288 | 0:a7a43371b306 | 19 | #include "m2mobjectinstance_stub.h" |
ram54288 | 0:a7a43371b306 | 20 | #include "m2mresource_stub.h" |
ram54288 | 0:a7a43371b306 | 21 | #include "m2mresourceinstance_stub.h" |
ram54288 | 0:a7a43371b306 | 22 | #include "m2mbase_stub.h" |
ram54288 | 0:a7a43371b306 | 23 | #include "nsdlaccesshelper_stub.h" |
ram54288 | 0:a7a43371b306 | 24 | |
ram54288 | 0:a7a43371b306 | 25 | Test_M2MServer::Test_M2MServer() |
ram54288 | 0:a7a43371b306 | 26 | { |
ram54288 | 0:a7a43371b306 | 27 | M2MObject* obj = new M2MObject("name", "name"); |
ram54288 | 0:a7a43371b306 | 28 | m2mobject_stub::inst = new M2MObjectInstance(*obj,"name", "type", "name"); |
ram54288 | 0:a7a43371b306 | 29 | m2mresource_stub::bool_value = true; |
ram54288 | 0:a7a43371b306 | 30 | m2mobjectinstance_stub::create_resource = new M2MResource(*m2mobject_stub::inst, |
ram54288 | 0:a7a43371b306 | 31 | "name", |
ram54288 | 0:a7a43371b306 | 32 | "type", |
ram54288 | 0:a7a43371b306 | 33 | M2MResourceInstance::STRING, |
ram54288 | 0:a7a43371b306 | 34 | false, |
ram54288 | 0:a7a43371b306 | 35 | "name"); |
ram54288 | 0:a7a43371b306 | 36 | server = new M2MServer(); |
ram54288 | 0:a7a43371b306 | 37 | |
ram54288 | 0:a7a43371b306 | 38 | delete m2mobjectinstance_stub::create_resource; |
ram54288 | 0:a7a43371b306 | 39 | m2mobjectinstance_stub::create_resource = NULL; |
ram54288 | 0:a7a43371b306 | 40 | delete obj; |
ram54288 | 0:a7a43371b306 | 41 | } |
ram54288 | 0:a7a43371b306 | 42 | |
ram54288 | 0:a7a43371b306 | 43 | Test_M2MServer::~Test_M2MServer() |
ram54288 | 0:a7a43371b306 | 44 | { |
ram54288 | 0:a7a43371b306 | 45 | delete m2mobject_stub::inst; |
ram54288 | 0:a7a43371b306 | 46 | m2mobject_stub::inst = NULL; |
ram54288 | 0:a7a43371b306 | 47 | |
ram54288 | 0:a7a43371b306 | 48 | m2mobject_stub::clear(); |
ram54288 | 0:a7a43371b306 | 49 | m2mobjectinstance_stub::clear(); |
ram54288 | 0:a7a43371b306 | 50 | m2mresource_stub::clear(); |
ram54288 | 0:a7a43371b306 | 51 | m2mbase_stub::clear(); |
ram54288 | 0:a7a43371b306 | 52 | delete server; |
ram54288 | 0:a7a43371b306 | 53 | } |
ram54288 | 0:a7a43371b306 | 54 | |
ram54288 | 0:a7a43371b306 | 55 | void Test_M2MServer::test_create_resource_int() |
ram54288 | 0:a7a43371b306 | 56 | { |
ram54288 | 0:a7a43371b306 | 57 | m2mobjectinstance_stub::create_resource = new M2MResource(*m2mobject_stub::inst, |
ram54288 | 0:a7a43371b306 | 58 | "name", |
ram54288 | 0:a7a43371b306 | 59 | "type", |
ram54288 | 0:a7a43371b306 | 60 | M2MResourceInstance::STRING, |
ram54288 | 0:a7a43371b306 | 61 | false, |
ram54288 | 0:a7a43371b306 | 62 | "name"); |
ram54288 | 0:a7a43371b306 | 63 | |
ram54288 | 0:a7a43371b306 | 64 | CHECK(server->create_resource(M2MServer::DefaultMinPeriod,10) != NULL); |
ram54288 | 0:a7a43371b306 | 65 | CHECK(server->create_resource(M2MServer::DefaultMaxPeriod,10) != NULL); |
ram54288 | 0:a7a43371b306 | 66 | CHECK(server->create_resource(M2MServer::DisableTimeout,10) != NULL); |
ram54288 | 0:a7a43371b306 | 67 | |
ram54288 | 0:a7a43371b306 | 68 | CHECK(server->create_resource(M2MServer::ShortServerID,10) == NULL); |
ram54288 | 0:a7a43371b306 | 69 | CHECK(server->create_resource(M2MServer::Lifetime,10) == NULL); |
ram54288 | 0:a7a43371b306 | 70 | CHECK(server->create_resource(M2MServer::Disable,10) == NULL); |
ram54288 | 0:a7a43371b306 | 71 | CHECK(server->create_resource(M2MServer::Binding,10) == NULL); |
ram54288 | 0:a7a43371b306 | 72 | CHECK(server->create_resource(M2MServer::NotificationStorage,10) == NULL); |
ram54288 | 0:a7a43371b306 | 73 | CHECK(server->create_resource(M2MServer::Binding,10) == NULL); |
ram54288 | 0:a7a43371b306 | 74 | CHECK(server->create_resource(M2MServer::RegistrationUpdate,10) == NULL); |
ram54288 | 0:a7a43371b306 | 75 | |
ram54288 | 0:a7a43371b306 | 76 | delete m2mobjectinstance_stub::create_resource; |
ram54288 | 0:a7a43371b306 | 77 | m2mobjectinstance_stub::create_resource = NULL; |
ram54288 | 0:a7a43371b306 | 78 | } |
ram54288 | 0:a7a43371b306 | 79 | |
ram54288 | 0:a7a43371b306 | 80 | void Test_M2MServer::test_create_resource() |
ram54288 | 0:a7a43371b306 | 81 | { |
ram54288 | 0:a7a43371b306 | 82 | m2mobjectinstance_stub::create_resource = new M2MResource(*m2mobject_stub::inst, |
ram54288 | 0:a7a43371b306 | 83 | "name", |
ram54288 | 0:a7a43371b306 | 84 | "type", |
ram54288 | 0:a7a43371b306 | 85 | M2MResourceInstance::STRING, |
ram54288 | 0:a7a43371b306 | 86 | false, |
ram54288 | 0:a7a43371b306 | 87 | "name"); |
ram54288 | 0:a7a43371b306 | 88 | |
ram54288 | 0:a7a43371b306 | 89 | CHECK(server->create_resource(M2MServer::Disable) != NULL); |
ram54288 | 0:a7a43371b306 | 90 | |
ram54288 | 0:a7a43371b306 | 91 | CHECK(server->create_resource(M2MServer::DefaultMinPeriod) == NULL); |
ram54288 | 0:a7a43371b306 | 92 | CHECK(server->create_resource(M2MServer::DefaultMaxPeriod) == NULL); |
ram54288 | 0:a7a43371b306 | 93 | CHECK(server->create_resource(M2MServer::DefaultMaxPeriod) == NULL); |
ram54288 | 0:a7a43371b306 | 94 | CHECK(server->create_resource(M2MServer::ShortServerID) == NULL); |
ram54288 | 0:a7a43371b306 | 95 | CHECK(server->create_resource(M2MServer::Lifetime) == NULL); |
ram54288 | 0:a7a43371b306 | 96 | CHECK(server->create_resource(M2MServer::DisableTimeout) == NULL); |
ram54288 | 0:a7a43371b306 | 97 | CHECK(server->create_resource(M2MServer::Binding) == NULL); |
ram54288 | 0:a7a43371b306 | 98 | CHECK(server->create_resource(M2MServer::NotificationStorage) == NULL); |
ram54288 | 0:a7a43371b306 | 99 | CHECK(server->create_resource(M2MServer::RegistrationUpdate) == NULL); |
ram54288 | 0:a7a43371b306 | 100 | |
ram54288 | 0:a7a43371b306 | 101 | delete m2mobjectinstance_stub::create_resource; |
ram54288 | 0:a7a43371b306 | 102 | m2mobjectinstance_stub::create_resource = NULL; |
ram54288 | 0:a7a43371b306 | 103 | } |
ram54288 | 0:a7a43371b306 | 104 | |
ram54288 | 0:a7a43371b306 | 105 | void Test_M2MServer::test_delete_resource() |
ram54288 | 0:a7a43371b306 | 106 | { |
ram54288 | 0:a7a43371b306 | 107 | m2mobjectinstance_stub::bool_value = true; |
ram54288 | 0:a7a43371b306 | 108 | |
ram54288 | 0:a7a43371b306 | 109 | CHECK(server->delete_resource(M2MServer::ShortServerID) == false); |
ram54288 | 0:a7a43371b306 | 110 | CHECK(server->delete_resource(M2MServer::Binding) == false); |
ram54288 | 0:a7a43371b306 | 111 | CHECK(server->delete_resource(M2MServer::NotificationStorage) == false); |
ram54288 | 0:a7a43371b306 | 112 | CHECK(server->delete_resource(M2MServer::Lifetime) == false); |
ram54288 | 0:a7a43371b306 | 113 | CHECK(server->delete_resource(M2MServer::RegistrationUpdate) == false); |
ram54288 | 0:a7a43371b306 | 114 | |
ram54288 | 0:a7a43371b306 | 115 | CHECK(server->delete_resource(M2MServer::DefaultMinPeriod) == true); |
ram54288 | 0:a7a43371b306 | 116 | CHECK(server->delete_resource(M2MServer::DefaultMaxPeriod) == true); |
ram54288 | 0:a7a43371b306 | 117 | CHECK(server->delete_resource(M2MServer::DisableTimeout) == true); |
ram54288 | 0:a7a43371b306 | 118 | CHECK(server->delete_resource(M2MServer::Disable) == true); |
ram54288 | 0:a7a43371b306 | 119 | } |
ram54288 | 0:a7a43371b306 | 120 | |
ram54288 | 0:a7a43371b306 | 121 | void Test_M2MServer::test_set_resource_value_int() |
ram54288 | 0:a7a43371b306 | 122 | { |
ram54288 | 0:a7a43371b306 | 123 | m2mbase_stub::bool_value = true; |
ram54288 | 0:a7a43371b306 | 124 | |
ram54288 | 0:a7a43371b306 | 125 | m2mobjectinstance_stub::resource = new M2MResource(*m2mobject_stub::inst, |
ram54288 | 0:a7a43371b306 | 126 | "name", |
ram54288 | 0:a7a43371b306 | 127 | "type", |
ram54288 | 0:a7a43371b306 | 128 | M2MResourceInstance::STRING, |
ram54288 | 0:a7a43371b306 | 129 | false, |
ram54288 | 0:a7a43371b306 | 130 | "name"); |
ram54288 | 0:a7a43371b306 | 131 | |
ram54288 | 0:a7a43371b306 | 132 | CHECK(server->set_resource_value(M2MServer::DefaultMinPeriod,10) == true); |
ram54288 | 0:a7a43371b306 | 133 | CHECK(server->set_resource_value(M2MServer::DefaultMaxPeriod,10) == true); |
ram54288 | 0:a7a43371b306 | 134 | CHECK(server->set_resource_value(M2MServer::DisableTimeout,10) == true); |
ram54288 | 0:a7a43371b306 | 135 | CHECK(server->set_resource_value(M2MServer::ShortServerID,10) == true); |
ram54288 | 0:a7a43371b306 | 136 | CHECK(server->set_resource_value(M2MServer::NotificationStorage,10) == true); |
ram54288 | 0:a7a43371b306 | 137 | CHECK(server->set_resource_value(M2MServer::Lifetime,10) == true); |
ram54288 | 0:a7a43371b306 | 138 | |
ram54288 | 0:a7a43371b306 | 139 | CHECK(server->set_resource_value(M2MServer::Binding,10) == false); |
ram54288 | 0:a7a43371b306 | 140 | CHECK(server->set_resource_value(M2MServer::RegistrationUpdate,10) == false); |
ram54288 | 0:a7a43371b306 | 141 | CHECK(server->set_resource_value(M2MServer::Disable,10) == false); |
ram54288 | 0:a7a43371b306 | 142 | |
ram54288 | 0:a7a43371b306 | 143 | delete m2mobjectinstance_stub::resource; |
ram54288 | 0:a7a43371b306 | 144 | m2mobjectinstance_stub::resource = NULL; |
ram54288 | 0:a7a43371b306 | 145 | } |
ram54288 | 0:a7a43371b306 | 146 | |
ram54288 | 0:a7a43371b306 | 147 | void Test_M2MServer::test_set_resource_value_string() |
ram54288 | 0:a7a43371b306 | 148 | { |
ram54288 | 0:a7a43371b306 | 149 | m2mresourceinstance_stub::bool_value = true; |
ram54288 | 0:a7a43371b306 | 150 | |
ram54288 | 0:a7a43371b306 | 151 | m2mobjectinstance_stub::resource = new M2MResource(*m2mobject_stub::inst, |
ram54288 | 0:a7a43371b306 | 152 | "name", |
ram54288 | 0:a7a43371b306 | 153 | "type", |
ram54288 | 0:a7a43371b306 | 154 | M2MResourceInstance::STRING, |
ram54288 | 0:a7a43371b306 | 155 | false, |
ram54288 | 0:a7a43371b306 | 156 | "name"); |
ram54288 | 0:a7a43371b306 | 157 | |
ram54288 | 0:a7a43371b306 | 158 | CHECK(server->set_resource_value(M2MServer::Binding,"test") == true); |
ram54288 | 0:a7a43371b306 | 159 | |
ram54288 | 0:a7a43371b306 | 160 | CHECK(server->set_resource_value(M2MServer::DefaultMinPeriod,"test") == false); |
ram54288 | 0:a7a43371b306 | 161 | CHECK(server->set_resource_value(M2MServer::DefaultMaxPeriod,"test") == false); |
ram54288 | 0:a7a43371b306 | 162 | CHECK(server->set_resource_value(M2MServer::DisableTimeout,"test") == false); |
ram54288 | 0:a7a43371b306 | 163 | CHECK(server->set_resource_value(M2MServer::ShortServerID,"test") == false); |
ram54288 | 0:a7a43371b306 | 164 | CHECK(server->set_resource_value(M2MServer::NotificationStorage,"test") == false); |
ram54288 | 0:a7a43371b306 | 165 | CHECK(server->set_resource_value(M2MServer::Lifetime,"test") == false); |
ram54288 | 0:a7a43371b306 | 166 | CHECK(server->set_resource_value(M2MServer::RegistrationUpdate,"test") == false); |
ram54288 | 0:a7a43371b306 | 167 | CHECK(server->set_resource_value(M2MServer::Disable,"test") == false); |
ram54288 | 0:a7a43371b306 | 168 | |
ram54288 | 0:a7a43371b306 | 169 | delete m2mobjectinstance_stub::resource; |
ram54288 | 0:a7a43371b306 | 170 | m2mobjectinstance_stub::resource = NULL; |
ram54288 | 0:a7a43371b306 | 171 | } |
ram54288 | 0:a7a43371b306 | 172 | |
ram54288 | 0:a7a43371b306 | 173 | void Test_M2MServer::test_resource_value_int() |
ram54288 | 0:a7a43371b306 | 174 | { |
ram54288 | 0:a7a43371b306 | 175 | uint8_t value[] = {"10"}; |
ram54288 | 0:a7a43371b306 | 176 | m2mresourceinstance_stub::value = (uint8_t*)malloc((uint32_t)sizeof(value)); |
ram54288 | 0:a7a43371b306 | 177 | memset(m2mresourceinstance_stub::value,0,(uint32_t)sizeof(value)); |
ram54288 | 0:a7a43371b306 | 178 | memcpy(m2mresourceinstance_stub::value,value,sizeof(value)); |
ram54288 | 0:a7a43371b306 | 179 | m2mresourceinstance_stub::int_value = (uint32_t)sizeof(value); |
ram54288 | 0:a7a43371b306 | 180 | |
ram54288 | 0:a7a43371b306 | 181 | m2mobjectinstance_stub::resource = new M2MResource(*m2mobject_stub::inst, |
ram54288 | 0:a7a43371b306 | 182 | "name", |
ram54288 | 0:a7a43371b306 | 183 | "type", |
ram54288 | 0:a7a43371b306 | 184 | M2MResourceInstance::STRING, |
ram54288 | 0:a7a43371b306 | 185 | false, |
ram54288 | 0:a7a43371b306 | 186 | "name"); |
ram54288 | 0:a7a43371b306 | 187 | |
ram54288 | 0:a7a43371b306 | 188 | CHECK(server->resource_value_int(M2MServer::ShortServerID) == 10); |
ram54288 | 0:a7a43371b306 | 189 | CHECK(server->resource_value_int(M2MServer::DefaultMinPeriod) == 10); |
ram54288 | 0:a7a43371b306 | 190 | CHECK(server->resource_value_int(M2MServer::DefaultMaxPeriod) == 10); |
ram54288 | 0:a7a43371b306 | 191 | CHECK(server->resource_value_int(M2MServer::DisableTimeout) == 10); |
ram54288 | 0:a7a43371b306 | 192 | CHECK(server->resource_value_int(M2MServer::NotificationStorage) == 10); |
ram54288 | 0:a7a43371b306 | 193 | CHECK(server->resource_value_int(M2MServer::Lifetime) == 10); |
ram54288 | 0:a7a43371b306 | 194 | CHECK(server->resource_value_int(M2MServer::Binding) == 0); |
ram54288 | 0:a7a43371b306 | 195 | CHECK(server->resource_value_int(M2MServer::RegistrationUpdate) == 0); |
ram54288 | 0:a7a43371b306 | 196 | CHECK(server->resource_value_int(M2MServer::Disable) == 0); |
ram54288 | 0:a7a43371b306 | 197 | |
ram54288 | 0:a7a43371b306 | 198 | delete m2mobjectinstance_stub::resource; |
ram54288 | 0:a7a43371b306 | 199 | m2mobjectinstance_stub::resource = NULL; |
ram54288 | 0:a7a43371b306 | 200 | |
ram54288 | 0:a7a43371b306 | 201 | free(m2mresourceinstance_stub::value); |
ram54288 | 0:a7a43371b306 | 202 | m2mresourceinstance_stub::value = NULL; |
ram54288 | 0:a7a43371b306 | 203 | } |
ram54288 | 0:a7a43371b306 | 204 | |
ram54288 | 0:a7a43371b306 | 205 | void Test_M2MServer::test_resource_value_string() |
ram54288 | 0:a7a43371b306 | 206 | { |
ram54288 | 0:a7a43371b306 | 207 | String test = "string"; |
ram54288 | 0:a7a43371b306 | 208 | uint8_t value[] = {"string"}; |
ram54288 | 0:a7a43371b306 | 209 | |
ram54288 | 0:a7a43371b306 | 210 | m2mresourceinstance_stub::value = (uint8_t*)malloc((uint32_t)sizeof(value)); |
ram54288 | 0:a7a43371b306 | 211 | memset(m2mresourceinstance_stub::value,0,(uint32_t)sizeof(value)); |
ram54288 | 0:a7a43371b306 | 212 | memcpy(m2mresourceinstance_stub::value,value,sizeof(value)); |
ram54288 | 0:a7a43371b306 | 213 | m2mresourceinstance_stub::int_value = (uint32_t)sizeof(value); |
ram54288 | 0:a7a43371b306 | 214 | |
ram54288 | 0:a7a43371b306 | 215 | m2mobjectinstance_stub::resource = new M2MResource(*m2mobject_stub::inst, |
ram54288 | 0:a7a43371b306 | 216 | "name", |
ram54288 | 0:a7a43371b306 | 217 | "type", |
ram54288 | 0:a7a43371b306 | 218 | M2MResourceInstance::STRING, |
ram54288 | 0:a7a43371b306 | 219 | false, |
ram54288 | 0:a7a43371b306 | 220 | "name"); |
ram54288 | 0:a7a43371b306 | 221 | |
ram54288 | 0:a7a43371b306 | 222 | CHECK(server->resource_value_string(M2MServer::Binding) == test); |
ram54288 | 0:a7a43371b306 | 223 | |
ram54288 | 0:a7a43371b306 | 224 | CHECK(server->resource_value_string(M2MServer::Disable) == ""); |
ram54288 | 0:a7a43371b306 | 225 | CHECK(server->resource_value_string(M2MServer::RegistrationUpdate) == ""); |
ram54288 | 0:a7a43371b306 | 226 | CHECK(server->resource_value_string(M2MServer::Lifetime) == ""); |
ram54288 | 0:a7a43371b306 | 227 | CHECK(server->resource_value_string(M2MServer::NotificationStorage) == ""); |
ram54288 | 0:a7a43371b306 | 228 | CHECK(server->resource_value_string(M2MServer::DisableTimeout) == ""); |
ram54288 | 0:a7a43371b306 | 229 | CHECK(server->resource_value_string(M2MServer::DefaultMaxPeriod) == ""); |
ram54288 | 0:a7a43371b306 | 230 | CHECK(server->resource_value_string(M2MServer::DefaultMinPeriod) == ""); |
ram54288 | 0:a7a43371b306 | 231 | CHECK(server->resource_value_string(M2MServer::ShortServerID) == ""); |
ram54288 | 0:a7a43371b306 | 232 | |
ram54288 | 0:a7a43371b306 | 233 | delete m2mobjectinstance_stub::resource; |
ram54288 | 0:a7a43371b306 | 234 | m2mobjectinstance_stub::resource = NULL; |
ram54288 | 0:a7a43371b306 | 235 | |
ram54288 | 0:a7a43371b306 | 236 | free(m2mresourceinstance_stub::value); |
ram54288 | 0:a7a43371b306 | 237 | m2mresourceinstance_stub::value = NULL; |
ram54288 | 0:a7a43371b306 | 238 | } |
ram54288 | 0:a7a43371b306 | 239 | |
ram54288 | 0:a7a43371b306 | 240 | void Test_M2MServer::test_is_resource_present() |
ram54288 | 0:a7a43371b306 | 241 | { |
ram54288 | 0:a7a43371b306 | 242 | m2mobjectinstance_stub::resource = new M2MResource(*m2mobject_stub::inst, |
ram54288 | 0:a7a43371b306 | 243 | "name", |
ram54288 | 0:a7a43371b306 | 244 | "type", |
ram54288 | 0:a7a43371b306 | 245 | M2MResourceInstance::STRING, |
ram54288 | 0:a7a43371b306 | 246 | false, |
ram54288 | 0:a7a43371b306 | 247 | "name"); |
ram54288 | 0:a7a43371b306 | 248 | |
ram54288 | 0:a7a43371b306 | 249 | CHECK(server->is_resource_present(M2MServer::ShortServerID) == true); |
ram54288 | 0:a7a43371b306 | 250 | |
ram54288 | 0:a7a43371b306 | 251 | delete m2mobjectinstance_stub::resource; |
ram54288 | 0:a7a43371b306 | 252 | m2mobjectinstance_stub::resource = NULL; |
ram54288 | 0:a7a43371b306 | 253 | |
ram54288 | 0:a7a43371b306 | 254 | CHECK(server->is_resource_present(M2MServer::DefaultMinPeriod) == false); |
ram54288 | 0:a7a43371b306 | 255 | } |
ram54288 | 0:a7a43371b306 | 256 | |
ram54288 | 0:a7a43371b306 | 257 | void Test_M2MServer::test_total_resource_count() |
ram54288 | 0:a7a43371b306 | 258 | { |
ram54288 | 0:a7a43371b306 | 259 | M2MResource *res = new M2MResource(*m2mobject_stub::inst, |
ram54288 | 0:a7a43371b306 | 260 | "name", |
ram54288 | 0:a7a43371b306 | 261 | "type", |
ram54288 | 0:a7a43371b306 | 262 | M2MResourceInstance::STRING, |
ram54288 | 0:a7a43371b306 | 263 | false, |
ram54288 | 0:a7a43371b306 | 264 | "name"); |
ram54288 | 0:a7a43371b306 | 265 | |
ram54288 | 0:a7a43371b306 | 266 | m2mobjectinstance_stub::resource_list.push_back(res); |
ram54288 | 0:a7a43371b306 | 267 | M2MResource *res2 = new M2MResource(*m2mobject_stub::inst, |
ram54288 | 0:a7a43371b306 | 268 | "name", |
ram54288 | 0:a7a43371b306 | 269 | "type", |
ram54288 | 0:a7a43371b306 | 270 | M2MResourceInstance::STRING, |
ram54288 | 0:a7a43371b306 | 271 | false, |
ram54288 | 0:a7a43371b306 | 272 | "name"); |
ram54288 | 0:a7a43371b306 | 273 | |
ram54288 | 0:a7a43371b306 | 274 | m2mobjectinstance_stub::resource_list.push_back(res2); |
ram54288 | 0:a7a43371b306 | 275 | |
ram54288 | 0:a7a43371b306 | 276 | CHECK(server->total_resource_count() == 2); |
ram54288 | 0:a7a43371b306 | 277 | |
ram54288 | 0:a7a43371b306 | 278 | m2mobjectinstance_stub::resource_list.clear(); |
ram54288 | 0:a7a43371b306 | 279 | |
ram54288 | 0:a7a43371b306 | 280 | delete res2; |
ram54288 | 0:a7a43371b306 | 281 | delete res; |
ram54288 | 0:a7a43371b306 | 282 | } |