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