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.
utest_case.h
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 #ifndef UTEST_CASES_H 00020 #define UTEST_CASES_H 00021 00022 #include <stdint.h> 00023 #include <stdbool.h> 00024 #include <stdio.h> 00025 #include "utest/utest_types.h" 00026 #include "utest/utest_default_handlers.h" 00027 00028 00029 namespace utest { 00030 /** \addtogroup frameworks */ 00031 /** @{*/ 00032 namespace v1 { 00033 00034 /** Test case wrapper class. 00035 * 00036 * This class contains the description of the test case and all handlers 00037 * for setting up, running the test case, tearing down and handling failures. 00038 * 00039 * By default you only need to provide a description and a test case handler. 00040 * You may override the setup, teardown and failure handlers, but you do not have to. 00041 * If you do not override these handler, the specified default handlers will be called. 00042 * 00043 * These constructors are overloaded to allow you a comfortable declaration of all your 00044 * callbacks. 00045 * The order is always: 00046 * - description (required) 00047 * - setup handler (optional) 00048 * - test case handler (required) 00049 * - teardown handler (optional) 00050 * - failure handler (optional) 00051 * 00052 * @note While you can specify an empty test case (ie. use `ignore_handler` for all callbacks), 00053 * the harness will abort the test unconditionally. 00054 */ 00055 class Case 00056 { 00057 public: 00058 // overloads for case_handler_t 00059 Case(const char *description, 00060 const case_setup_handler_t setup_handler, 00061 const case_handler_t case_handler, 00062 const case_teardown_handler_t teardown_handler = default_handler, 00063 const case_failure_handler_t failure_handler = default_handler); 00064 00065 Case(const char *description, 00066 const case_handler_t case_handler, 00067 const case_failure_handler_t failure_handler = default_handler); 00068 00069 Case(const char *description, 00070 const case_handler_t case_handler, 00071 const case_teardown_handler_t teardown_handler, 00072 const case_failure_handler_t failure_handler = default_handler); 00073 00074 // overloads for case_control_handler_t 00075 Case(const char *description, 00076 const case_setup_handler_t setup_handler, 00077 const case_control_handler_t case_handler, 00078 const case_teardown_handler_t teardown_handler = default_handler, 00079 const case_failure_handler_t failure_handler = default_handler); 00080 00081 Case(const char *description, 00082 const case_control_handler_t case_handler, 00083 const case_failure_handler_t failure_handler = default_handler); 00084 00085 Case(const char *description, 00086 const case_control_handler_t case_handler, 00087 const case_teardown_handler_t teardown_handler, 00088 const case_failure_handler_t failure_handler = default_handler); 00089 00090 // overloads for case_call_count_handler_t 00091 Case(const char *description, 00092 const case_setup_handler_t setup_handler, 00093 const case_call_count_handler_t case_handler, 00094 const case_teardown_handler_t teardown_handler = default_handler, 00095 const case_failure_handler_t failure_handler = default_handler); 00096 00097 Case(const char *description, 00098 const case_call_count_handler_t case_handler, 00099 const case_failure_handler_t failure_handler = default_handler); 00100 00101 Case(const char *description, 00102 const case_call_count_handler_t case_handler, 00103 const case_teardown_handler_t teardown_handler, 00104 const case_failure_handler_t failure_handler = default_handler); 00105 00106 00107 /// @returns the textual description of the test case 00108 const char* get_description () const; 00109 00110 /// @returns `true` if setup, test and teardown handlers are set to `ignore_handler` 00111 bool is_empty () const; 00112 00113 private: 00114 const char *description; 00115 00116 const case_handler_t handler; 00117 const case_control_handler_t control_handler; 00118 const case_call_count_handler_t repeat_count_handler; 00119 00120 const case_setup_handler_t setup_handler; 00121 const case_teardown_handler_t teardown_handler; 00122 00123 const case_failure_handler_t failure_handler; 00124 00125 friend class Harness; 00126 }; 00127 00128 } // namespace v1 00129 } // namespace utest 00130 00131 #endif // UTEST_CASES_H 00132 00133 /** @}*/
Generated on Tue Jul 12 2022 17:35:00 by
