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.
test_m2mtimer.cpp
00001 /* 00002 * Copyright (c) 2016 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_m2mtimer.h" 00018 #include "m2mtimerpimpl_stub.h" 00019 00020 class TestObserver : public M2MTimerObserver { 00021 00022 public: 00023 TestObserver(){} 00024 virtual ~TestObserver(){} 00025 void timer_expired(M2MTimerObserver::Type){ 00026 visited = true; 00027 } 00028 bool visited; 00029 00030 }; 00031 00032 Test_M2MTimer::Test_M2MTimer() 00033 { 00034 observer = new TestObserver(); 00035 timer = new M2MTimer(*observer); 00036 } 00037 00038 Test_M2MTimer::~Test_M2MTimer() 00039 { 00040 m2mtimerpimpl_stub::clear(); 00041 delete observer; 00042 delete timer; 00043 } 00044 00045 void Test_M2MTimer::test_start_timer() 00046 { 00047 timer->start_timer(100, M2MTimerObserver::Notdefined,true); 00048 CHECK(m2mtimerpimpl_stub::visited == true); 00049 } 00050 00051 void Test_M2MTimer::test_stop_timer() 00052 { 00053 timer->stop_timer(); 00054 CHECK(m2mtimerpimpl_stub::visited == true); 00055 } 00056 00057 void Test_M2MTimer::test_start_dtls_timer() 00058 { 00059 timer->start_dtls_timer(100, 110); 00060 CHECK(m2mtimerpimpl_stub::visited == true); 00061 } 00062 00063 void Test_M2MTimer::test_is_intermediate_interval_passed() 00064 { 00065 m2mtimerpimpl_stub::bool_value = true; 00066 CHECK(true == timer->is_intermediate_interval_passed()); 00067 } 00068 00069 void Test_M2MTimer::test_is_total_interval_passed() 00070 { 00071 m2mtimerpimpl_stub::bool_value = true; 00072 CHECK(true == timer->is_total_interval_passed()); 00073 }
Generated on Tue Jul 12 2022 21:20:30 by
