joey shelton / LED_Demo

Dependencies:   MAX44000 PWM_Tone_Library nexpaq_mdk

Fork of LED_Demo by Maxim nexpaq

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers libCoap_header_test.cpp Source File

libCoap_header_test.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 <string.h>
00018 #include <stdint.h>
00019 #include "sn_nsdl.h"
00020 #include "sn_coap_protocol.h"
00021 #include "sn_nsdl_lib.h"
00022 #include "sn_coap_header_internal.h"
00023 
00024 
00025 TEST_GROUP(libCoap_header_check)
00026 {
00027     void setup() {
00028 
00029     }
00030 
00031     void teardown() {
00032 
00033     }
00034 };
00035 
00036 TEST(libCoap_header_check, header_check)
00037 {
00038     sn_coap_hdr_s coap_header;
00039 
00040     memset(&coap_header, 0, sizeof(sn_coap_hdr_s));
00041     coap_header.msg_type = COAP_MSG_TYPE_CONFIRMABLE;
00042     coap_header.msg_code = COAP_MSG_CODE_REQUEST_GET;
00043 
00044     /* Happy-happy case */
00045     CHECK(sn_coap_header_validity_check(&coap_header, (coap_version_e)COAP_VERSION_1) == 0);
00046 
00047 
00048     CHECK(sn_coap_header_validity_check(&coap_header, (coap_version_e) 0) == -1);
00049 
00050     coap_header.msg_type = (sn_coap_msg_type_e)0x40;
00051 
00052     CHECK(sn_coap_header_validity_check(&coap_header, (coap_version_e)COAP_VERSION_1) == -1);
00053 
00054     coap_header.msg_type = (sn_coap_msg_type_e)COAP_MSG_TYPE_CONFIRMABLE;
00055     coap_header.msg_code = (sn_coap_msg_code_e)5;
00056 
00057     CHECK(sn_coap_header_validity_check(&coap_header, (coap_version_e)COAP_VERSION_1) == -1);
00058 }