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_specification.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_SPECIFICATION_H 00020 #define UTEST_SPECIFICATION_H 00021 00022 #include <stdint.h> 00023 #include <stdbool.h> 00024 #include <stdio.h> 00025 #include "utest/utest_types.h" 00026 #include "utest/utest_case.h" 00027 #include "utest/utest_default_handlers.h" 00028 00029 00030 namespace utest { 00031 namespace v1 { 00032 00033 /** Test specification containing the setup and teardown handlers and test cases. 00034 * 00035 * This class simply holds the test cases and allows you to specify default handlers, and 00036 * override setup and teardown handlers. 00037 * The order of arguments is: 00038 * - test setup handler (optional) 00039 * - array of test cases (required) 00040 * - test teardown handler (optional) 00041 * - default handlers (optional) 00042 * 00043 * @note You cannot set the size of the test case array dynamically, it is template deducted at compile 00044 * time. Creating test specifications for unittests at runtime is explicitly not supported. 00045 */ 00046 class Specification 00047 { 00048 public: 00049 template< size_t N > 00050 Specification(const Case (&cases)[N], 00051 const handlers_t defaults = default_handlers) : 00052 setup_handler(default_handler), teardown_handler(default_handler), failure_handler(default_handler), 00053 cases(cases), length(N), 00054 defaults(defaults) 00055 {} 00056 00057 template< size_t N > 00058 Specification(const Case (&cases)[N], 00059 const test_failure_handler_t failure_handler, 00060 const handlers_t defaults = default_handlers) : 00061 setup_handler(default_handler), teardown_handler(default_handler), failure_handler(failure_handler), 00062 cases(cases), length(N), 00063 defaults(defaults) 00064 {} 00065 00066 template< size_t N > 00067 Specification(const Case (&cases)[N], 00068 const test_teardown_handler_t teardown_handler, 00069 const handlers_t defaults = default_handlers) : 00070 setup_handler(default_handler), teardown_handler(teardown_handler), failure_handler(default_handler), 00071 cases(cases), length(N), 00072 defaults(defaults) 00073 {} 00074 00075 template< size_t N > 00076 Specification(const Case (&cases)[N], 00077 const test_teardown_handler_t teardown_handler, 00078 const test_failure_handler_t failure_handler, 00079 const handlers_t defaults = default_handlers) : 00080 setup_handler(default_handler), teardown_handler(teardown_handler), failure_handler(failure_handler), 00081 cases(cases), length(N), 00082 defaults(defaults) 00083 {} 00084 00085 template< size_t N > 00086 Specification(const test_setup_handler_t setup_handler, 00087 const Case (&cases)[N], 00088 const handlers_t defaults = default_handlers) : 00089 setup_handler(setup_handler), teardown_handler(default_handler), failure_handler(default_handler), 00090 cases(cases), length(N), 00091 defaults(defaults) 00092 {} 00093 00094 template< size_t N > 00095 Specification(const test_setup_handler_t setup_handler, 00096 const Case (&cases)[N], 00097 const test_failure_handler_t failure_handler, 00098 const handlers_t defaults = default_handlers) : 00099 setup_handler(setup_handler), teardown_handler(default_handler), failure_handler(failure_handler), 00100 cases(cases), length(N), 00101 defaults(defaults) 00102 {} 00103 00104 template< size_t N > 00105 Specification(const test_setup_handler_t setup_handler, 00106 const Case (&cases)[N], 00107 const test_teardown_handler_t teardown_handler, 00108 const handlers_t defaults = default_handlers) : 00109 setup_handler(setup_handler), teardown_handler(teardown_handler), failure_handler(default_handler), 00110 cases(cases), length(N), 00111 defaults(defaults) 00112 {} 00113 00114 template< size_t N > 00115 Specification(const test_setup_handler_t setup_handler, 00116 const Case (&cases)[N], 00117 const test_teardown_handler_t teardown_handler, 00118 const test_failure_handler_t failure_handler, 00119 const handlers_t defaults = default_handlers) : 00120 setup_handler(setup_handler), teardown_handler(teardown_handler), failure_handler(failure_handler), 00121 cases(cases), length(N), 00122 defaults(defaults) 00123 {} 00124 00125 private: 00126 const test_setup_handler_t setup_handler; 00127 const test_teardown_handler_t teardown_handler; 00128 const test_failure_handler_t failure_handler; 00129 const Case *const cases; 00130 const size_t length; 00131 const handlers_t defaults; 00132 00133 friend class Harness; 00134 }; 00135 00136 } // namespace v1 00137 } // namespace utest 00138 00139 #endif // UTEST_SPECIFICATION_H
Generated on Tue Jul 12 2022 12:28:58 by
1.7.2
