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