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.
Dependents: TYBLE16_simple_data_logger TYBLE16_MP3_Air
utest_case.cpp
00001 /**************************************************************************** 00002 * Copyright (c) 2015, ARM Limited, All Rights Reserved 00003 * SPDX-License-Identifier: Apache-2.0 00004 * 00005 * Licensed under the Apache License, Version 2.0 (the "License"); you may 00006 * not use this file except in compliance with the License. 00007 * You may obtain a copy of the License at 00008 * 00009 * http://www.apache.org/licenses/LICENSE-2.0 00010 * 00011 * Unless required by applicable law or agreed to in writing, software 00012 * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 00013 * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 00014 * See the License for the specific language governing permissions and 00015 * limitations under the License. 00016 **************************************************************************** 00017 */ 00018 00019 #include "utest/utest_case.h" 00020 #include "utest/utest_serial.h" 00021 00022 using namespace utest::v1; 00023 00024 // case_t factory used by Case contructor 00025 static inline case_t make_case( 00026 const char *description, 00027 const case_handler_t handler, 00028 const case_control_handler_t control_handler, 00029 const case_call_count_handler_t repeat_count_handler, 00030 const case_setup_handler_t setup_handler, 00031 const case_teardown_handler_t teardown_handler, 00032 const case_failure_handler_t failure_handler) 00033 { 00034 case_t result = { 00035 description, 00036 handler, 00037 control_handler, 00038 repeat_count_handler, 00039 setup_handler, 00040 teardown_handler, 00041 failure_handler 00042 }; 00043 00044 return result; 00045 } 00046 00047 // normal handler 00048 Case::Case(const char *description, 00049 const case_setup_handler_t setup_handler, 00050 const case_handler_t handler, 00051 const case_teardown_handler_t teardown_handler, 00052 const case_failure_handler_t failure_handler) : 00053 case_t(make_case( 00054 description, 00055 handler, 00056 ignore_handler, 00057 ignore_handler, 00058 setup_handler, 00059 teardown_handler, 00060 failure_handler 00061 )) 00062 00063 {} 00064 00065 Case::Case(const char *description, 00066 const case_handler_t handler, 00067 const case_teardown_handler_t teardown_handler, 00068 const case_failure_handler_t failure_handler) : 00069 case_t(make_case( 00070 description, 00071 handler, 00072 ignore_handler, 00073 ignore_handler, 00074 default_handler, 00075 teardown_handler, 00076 failure_handler 00077 )) 00078 00079 {} 00080 00081 Case::Case(const char *description, 00082 const case_handler_t handler, 00083 const case_failure_handler_t failure_handler) : 00084 case_t(make_case( 00085 description, 00086 handler, 00087 ignore_handler, 00088 ignore_handler, 00089 default_handler, 00090 default_handler, 00091 failure_handler 00092 )) 00093 {} 00094 00095 // control handler 00096 Case::Case(const char *description, 00097 const case_setup_handler_t setup_handler, 00098 const case_control_handler_t handler, 00099 const case_teardown_handler_t teardown_handler, 00100 const case_failure_handler_t failure_handler) : 00101 case_t(make_case( 00102 description, 00103 ignore_handler, 00104 handler, 00105 ignore_handler, 00106 setup_handler, 00107 teardown_handler, 00108 failure_handler 00109 )) 00110 {} 00111 00112 Case::Case(const char *description, 00113 const case_control_handler_t handler, 00114 const case_teardown_handler_t teardown_handler, 00115 const case_failure_handler_t failure_handler) : 00116 case_t(make_case( 00117 description, 00118 ignore_handler, 00119 handler, 00120 ignore_handler, 00121 default_handler, 00122 teardown_handler, 00123 failure_handler 00124 )) 00125 {} 00126 00127 Case::Case(const char *description, 00128 const case_control_handler_t handler, 00129 const case_failure_handler_t failure_handler) : 00130 case_t(make_case( 00131 description, 00132 ignore_handler, 00133 handler, 00134 ignore_handler, 00135 default_handler, 00136 default_handler, 00137 failure_handler 00138 )) 00139 {} 00140 00141 // control flow handler 00142 Case::Case(const char *description, 00143 const case_setup_handler_t setup_handler, 00144 const case_call_count_handler_t case_repeat_count_handler, 00145 const case_teardown_handler_t teardown_handler, 00146 const case_failure_handler_t failure_handler) : 00147 case_t(make_case( 00148 description, 00149 ignore_handler, 00150 ignore_handler, 00151 case_repeat_count_handler, 00152 setup_handler, 00153 teardown_handler, 00154 failure_handler 00155 )) 00156 {} 00157 00158 Case::Case(const char *description, 00159 const case_call_count_handler_t case_repeat_count_handler, 00160 const case_failure_handler_t failure_handler) : 00161 case_t(make_case( 00162 description, 00163 ignore_handler, 00164 ignore_handler, 00165 case_repeat_count_handler, 00166 default_handler, 00167 default_handler, 00168 failure_handler 00169 )) 00170 {} 00171 00172 Case::Case(const char *description, 00173 const case_call_count_handler_t case_repeat_count_handler, 00174 const case_teardown_handler_t teardown_handler, 00175 const case_failure_handler_t failure_handler) : 00176 case_t(make_case( 00177 description, 00178 ignore_handler, 00179 ignore_handler, 00180 case_repeat_count_handler, 00181 default_handler, 00182 teardown_handler, 00183 failure_handler 00184 )) 00185 {} 00186 00187 const char* 00188 Case::get_description() const { 00189 return description; 00190 } 00191 00192 bool 00193 Case::is_empty () const { 00194 return !(handler || control_handler || repeat_count_handler || setup_handler || teardown_handler); 00195 }
Generated on Tue Jul 12 2022 13:55:03 by
