Ram Gandikota
/
IOTMetronome
FRDM K64F Metronome
mbed-client/test/mbedclient/utest/m2mstringbufferbase/test_m2mstringbufferbase.cpp@0:dbad57390bd1, 2017-05-14 (annotated)
- Committer:
- ram54288
- Date:
- Sun May 14 18:37:05 2017 +0000
- Revision:
- 0:dbad57390bd1
Initial commit
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
ram54288 | 0:dbad57390bd1 | 1 | /* |
ram54288 | 0:dbad57390bd1 | 2 | * Copyright (c) 2016 ARM Limited. All rights reserved. |
ram54288 | 0:dbad57390bd1 | 3 | * SPDX-License-Identifier: Apache-2.0 |
ram54288 | 0:dbad57390bd1 | 4 | * Licensed under the Apache License, Version 2.0 (the License); you may |
ram54288 | 0:dbad57390bd1 | 5 | * not use this file except in compliance with the License. |
ram54288 | 0:dbad57390bd1 | 6 | * You may obtain a copy of the License at |
ram54288 | 0:dbad57390bd1 | 7 | * |
ram54288 | 0:dbad57390bd1 | 8 | * http://www.apache.org/licenses/LICENSE-2.0 |
ram54288 | 0:dbad57390bd1 | 9 | * |
ram54288 | 0:dbad57390bd1 | 10 | * Unless required by applicable law or agreed to in writing, software |
ram54288 | 0:dbad57390bd1 | 11 | * distributed under the License is distributed on an AS IS BASIS, WITHOUT |
ram54288 | 0:dbad57390bd1 | 12 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
ram54288 | 0:dbad57390bd1 | 13 | * See the License for the specific language governing permissions and |
ram54288 | 0:dbad57390bd1 | 14 | * limitations under the License. |
ram54288 | 0:dbad57390bd1 | 15 | */ |
ram54288 | 0:dbad57390bd1 | 16 | #include "CppUTest/TestHarness.h" |
ram54288 | 0:dbad57390bd1 | 17 | #include "test_m2mstringbufferbase.h" |
ram54288 | 0:dbad57390bd1 | 18 | //#include "m2mstringbuffer.h" |
ram54288 | 0:dbad57390bd1 | 19 | |
ram54288 | 0:dbad57390bd1 | 20 | |
ram54288 | 0:dbad57390bd1 | 21 | |
ram54288 | 0:dbad57390bd1 | 22 | Test_M2Mstringbufferbase::Test_M2Mstringbufferbase() |
ram54288 | 0:dbad57390bd1 | 23 | { |
ram54288 | 0:dbad57390bd1 | 24 | } |
ram54288 | 0:dbad57390bd1 | 25 | |
ram54288 | 0:dbad57390bd1 | 26 | Test_M2Mstringbufferbase::~Test_M2Mstringbufferbase() |
ram54288 | 0:dbad57390bd1 | 27 | { |
ram54288 | 0:dbad57390bd1 | 28 | } |
ram54288 | 0:dbad57390bd1 | 29 | |
ram54288 | 0:dbad57390bd1 | 30 | void Test_M2Mstringbufferbase::test_ensure_space() |
ram54288 | 0:dbad57390bd1 | 31 | { |
ram54288 | 0:dbad57390bd1 | 32 | CHECK(ensure_space(1, 1)); |
ram54288 | 0:dbad57390bd1 | 33 | CHECK(!ensure_space(1, 2)); |
ram54288 | 0:dbad57390bd1 | 34 | } |
ram54288 | 0:dbad57390bd1 | 35 | |
ram54288 | 0:dbad57390bd1 | 36 | void Test_M2Mstringbufferbase::test_append() |
ram54288 | 0:dbad57390bd1 | 37 | { |
ram54288 | 0:dbad57390bd1 | 38 | char data[2]; |
ram54288 | 0:dbad57390bd1 | 39 | |
ram54288 | 0:dbad57390bd1 | 40 | _curr_size = 0; |
ram54288 | 0:dbad57390bd1 | 41 | CHECK(append(data, 2, 'a')); |
ram54288 | 0:dbad57390bd1 | 42 | CHECK(!append(data, 2, 'a')); |
ram54288 | 0:dbad57390bd1 | 43 | |
ram54288 | 0:dbad57390bd1 | 44 | _curr_size = 0; |
ram54288 | 0:dbad57390bd1 | 45 | CHECK(append(data, 2, "a")); |
ram54288 | 0:dbad57390bd1 | 46 | CHECK(!append(data, 2, "a")); |
ram54288 | 0:dbad57390bd1 | 47 | |
ram54288 | 0:dbad57390bd1 | 48 | _curr_size = 0; |
ram54288 | 0:dbad57390bd1 | 49 | CHECK(!append(data, 2, "aa")); |
ram54288 | 0:dbad57390bd1 | 50 | |
ram54288 | 0:dbad57390bd1 | 51 | _curr_size = 0; |
ram54288 | 0:dbad57390bd1 | 52 | CHECK(append(data, 2, "aa", 1)); |
ram54288 | 0:dbad57390bd1 | 53 | |
ram54288 | 0:dbad57390bd1 | 54 | _curr_size = 0; |
ram54288 | 0:dbad57390bd1 | 55 | CHECK(!append(data, 2, "aa", 2)); |
ram54288 | 0:dbad57390bd1 | 56 | |
ram54288 | 0:dbad57390bd1 | 57 | |
ram54288 | 0:dbad57390bd1 | 58 | } |
ram54288 | 0:dbad57390bd1 | 59 | |
ram54288 | 0:dbad57390bd1 | 60 | void Test_M2Mstringbufferbase::test_append_int() |
ram54288 | 0:dbad57390bd1 | 61 | { |
ram54288 | 0:dbad57390bd1 | 62 | char data[2]; |
ram54288 | 0:dbad57390bd1 | 63 | _curr_size = 0; |
ram54288 | 0:dbad57390bd1 | 64 | CHECK(append_int(data, 2, 1)); |
ram54288 | 0:dbad57390bd1 | 65 | CHECK(!append_int(data, 2, 2)); |
ram54288 | 0:dbad57390bd1 | 66 | _curr_size = 0; |
ram54288 | 0:dbad57390bd1 | 67 | CHECK(!append_int(data, 2, 666)); |
ram54288 | 0:dbad57390bd1 | 68 | } |
ram54288 | 0:dbad57390bd1 | 69 | |
ram54288 | 0:dbad57390bd1 | 70 | void Test_M2Mstringbufferbase::test_find_last_of() |
ram54288 | 0:dbad57390bd1 | 71 | { |
ram54288 | 0:dbad57390bd1 | 72 | char data[2]; |
ram54288 | 0:dbad57390bd1 | 73 | _curr_size = 0; |
ram54288 | 0:dbad57390bd1 | 74 | CHECK(append(data, 2, 'a')); |
ram54288 | 0:dbad57390bd1 | 75 | CHECK(0 == find_last_of(data, 'a')); |
ram54288 | 0:dbad57390bd1 | 76 | CHECK(0 > find_last_of(data, 'b')); |
ram54288 | 0:dbad57390bd1 | 77 | } |
ram54288 | 0:dbad57390bd1 | 78 | |
ram54288 | 0:dbad57390bd1 | 79 | /* |
ram54288 | 0:dbad57390bd1 | 80 | bool ensure_space(size_t max_size, size_t required_size) const; |
ram54288 | 0:dbad57390bd1 | 81 | |
ram54288 | 0:dbad57390bd1 | 82 | bool append(char *buff, size_t max_size, char data); |
ram54288 | 0:dbad57390bd1 | 83 | |
ram54288 | 0:dbad57390bd1 | 84 | bool append(char *buff, size_t max_size, const char *data); |
ram54288 | 0:dbad57390bd1 | 85 | |
ram54288 | 0:dbad57390bd1 | 86 | bool append(char *buff, size_t max_size, const char *data, size_t data_len); |
ram54288 | 0:dbad57390bd1 | 87 | |
ram54288 | 0:dbad57390bd1 | 88 | bool append_int(char *buff, size_t max_size, uint16_t data); |
ram54288 | 0:dbad57390bd1 | 89 | |
ram54288 | 0:dbad57390bd1 | 90 | int find_last_of(const char *buff, char search_char) const;*/ |