├── .gitignore ├── .travis.yml ├── CMakeLists.txt ├── LICENSE ├── README.md ├── app ├── CMakeLists.txt └── example_app.c ├── build └── .gitkeep ├── include └── example │ └── example.h ├── src ├── CMakeLists.txt └── example.c └── test ├── CMakeLists.txt ├── example_test.c └── unity ├── CMakeLists.txt ├── license.txt ├── unity.c ├── unity.h ├── unity_fixture.c ├── unity_fixture.h ├── unity_fixture_internals.h ├── unity_fixture_malloc_overrides.h └── unity_internals.h /.gitignore: -------------------------------------------------------------------------------- 1 | # Build directory. 2 | build/ 3 | 4 | # Prerequisites 5 | *.d 6 | 7 | # Object files 8 | *.o 9 | *.ko 10 | *.obj 11 | *.elf 12 | 13 | # Linker output 14 | *.ilk 15 | *.map 16 | *.exp 17 | 18 | # Precompiled Headers 19 | *.gch 20 | *.pch 21 | 22 | # Libraries 23 | *.lib 24 | *.a 25 | *.la 26 | *.lo 27 | 28 | # Shared objects (inc. Windows DLLs) 29 | *.dll 30 | *.so 31 | *.so.* 32 | *.dylib 33 | 34 | # Executables 35 | *.exe 36 | *.out 37 | *.app 38 | *.i*86 39 | *.x86_64 40 | *.hex 41 | 42 | # Debug files 43 | *.dSYM/ 44 | *.su 45 | *.idb 46 | *.pdb 47 | 48 | # Kernel Module Compile Results 49 | *.mod* 50 | *.cmd 51 | .tmp_versions/ 52 | modules.order 53 | Module.symvers 54 | Mkfile.old 55 | dkms.conf 56 | 57 | # IDE and editor private config/settings 58 | .vscode 59 | -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | language: c 2 | compiler: 3 | - clang 4 | - gcc 5 | dist: trusty 6 | sudo: false 7 | script: cd build && cmake .. && make && make test 8 | -------------------------------------------------------------------------------- /CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2018 Peter Nelson (peter@peterdn.com) 2 | # 3 | # Redistribution and use in source and binary forms, with or without 4 | # modification, are permitted provided that the following conditions are met: 5 | # 6 | # 1. Redistributions of source code must retain the above copyright notice, 7 | # this list of conditions and the following disclaimer. 8 | # 9 | # 2. Redistributions in binary form must reproduce the above copyright notice, 10 | # this list of conditions and the following disclaimer in the documentation 11 | # and/or other materials provided with the distribution. 12 | # 13 | # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 14 | # AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 15 | # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 16 | # ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE 17 | # LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 18 | # CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 19 | # SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 20 | # INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 21 | # CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 22 | # ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 23 | # POSSIBILITY OF SUCH DAMAGE. 24 | 25 | cmake_minimum_required(VERSION 3.0) 26 | project(example C) 27 | include(CTest) 28 | 29 | # Output directory structure configuration. 30 | set(EXECUTABLE_OUTPUT_PATH "${PROJECT_BINARY_DIR}/bin") 31 | set(LIBRARY_OUTPUT_PATH "${PROJECT_BINARY_DIR}/lib") 32 | set(TEST_OUTPUT_PATH "${EXECUTABLE_OUTPUT_PATH}/test") 33 | 34 | # Project-wide include directory configuration. 35 | include_directories("${PROJECT_SOURCE_DIR}/include") 36 | 37 | # Project library source lives in src/. 38 | add_subdirectory(src) 39 | 40 | # Project apps that may link to project libraries live in app/. 41 | add_subdirectory(app) 42 | 43 | # CTest sets BUILD_TESTING option to ON by default. 44 | # Test-related configuration goes here. 45 | if (BUILD_TESTING) 46 | enable_testing() 47 | add_subdirectory(test) 48 | endif() 49 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Copyright (c) 2018 Peter Nelson (peter@peterdn.com) 2 | 3 | Redistribution and use in source and binary forms, with or without 4 | modification, are permitted provided that the following conditions are met: 5 | 6 | 1. Redistributions of source code must retain the above copyright notice, 7 | this list of conditions and the following disclaimer. 8 | 9 | 2. Redistributions in binary form must reproduce the above copyright notice, 10 | this list of conditions and the following disclaimer in the documentation 11 | and/or other materials provided with the distribution. 12 | 13 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 14 | AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 15 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 16 | ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE 17 | LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 18 | CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 19 | SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 20 | INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 21 | CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 22 | ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 23 | POSSIBILITY OF SUCH DAMAGE. 24 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # C project template [![Build Status](https://travis-ci.org/peterdn/C-project-template.svg?branch=master)](https://travis-ci.org/peterdn/C-project-template) 2 | 3 | This is a C project template with the following features: 4 | 5 | - CMake build scripts for building libraries, applications, and tests. 6 | - Integrated with 7 | [Unity unit test framework](http://www.throwtheswitch.org/unity/). 8 | 9 | ## Usage 10 | 11 | Simply build with CMake: 12 | 13 | git clone git@github.com:peterdn/C-project-template.git my-project 14 | cd $_/build 15 | cmake .. 16 | make -j 17 | 18 | To run tests: 19 | 20 | make test 21 | 22 | ## Project directory structure 23 | 24 | - app/ -- Application source code. 25 | - include/ -- Library headers. 26 | - example/ -- Headers for an example library. 27 | - src/ -- Library source code. 28 | - test/ -- Test source code. 29 | - unity/ -- Unity test framework source. 30 | 31 | ## Build directory structure 32 | 33 | - bin/ -- Application binaries. 34 | - test/ -- Test binaries. 35 | - lib/ -- Libraries. 36 | 37 | ## License 38 | 39 | Distributed under the BSD-2-Clause license. See LICENSE for details. 40 | 41 | [Unity unit test framework](http://www.throwtheswitch.org/unity/) is 42 | distributed under the MIT license. See test/unity/license.txt for details. 43 | -------------------------------------------------------------------------------- /app/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2018 Peter Nelson (peter@peterdn.com) 2 | # 3 | # Redistribution and use in source and binary forms, with or without 4 | # modification, are permitted provided that the following conditions are met: 5 | # 6 | # 1. Redistributions of source code must retain the above copyright notice, 7 | # this list of conditions and the following disclaimer. 8 | # 9 | # 2. Redistributions in binary form must reproduce the above copyright notice, 10 | # this list of conditions and the following disclaimer in the documentation 11 | # and/or other materials provided with the distribution. 12 | # 13 | # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 14 | # AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 15 | # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 16 | # ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE 17 | # LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 18 | # CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 19 | # SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 20 | # INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 21 | # CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 22 | # ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 23 | # POSSIBILITY OF SUCH DAMAGE. 24 | 25 | ############################################################## 26 | # Configure an executable that links to the example library. # 27 | ############################################################## 28 | 29 | add_executable( 30 | example_app 31 | example_app.c 32 | ) 33 | 34 | target_link_libraries( 35 | example_app 36 | example 37 | ) 38 | -------------------------------------------------------------------------------- /app/example_app.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2018 Peter Nelson (peter@peterdn.com) 3 | * 4 | * Redistribution and use in source and binary forms, with or without 5 | * modification, are permitted provided that the following conditions are met: 6 | * 7 | * 1. Redistributions of source code must retain the above copyright notice, 8 | * this list of conditions and the following disclaimer. 9 | * 10 | * 2. Redistributions in binary form must reproduce the above copyright notice, 11 | * this list of conditions and the following disclaimer in the documentation 12 | * and/or other materials provided with the distribution. 13 | * 14 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 15 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 16 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 17 | * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE 18 | * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 19 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 20 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 21 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 22 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 23 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 24 | * POSSIBILITY OF SUCH DAMAGE. 25 | */ 26 | 27 | #include 28 | #include 29 | 30 | #include "example/example.h" 31 | 32 | int main(int argc, char *argv[]) { 33 | printf("Hello, example!\n"); 34 | 35 | example_t *example = example_new_with_cstr("test_key", "test_value"); 36 | example_print_cstr(example); 37 | example_free(example); 38 | 39 | return EXIT_SUCCESS; 40 | } 41 | -------------------------------------------------------------------------------- /build/.gitkeep: -------------------------------------------------------------------------------- 1 | # Empty file to force git to create build directory. 2 | -------------------------------------------------------------------------------- /include/example/example.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2018 Peter Nelson (peter@peterdn.com) 3 | * 4 | * Redistribution and use in source and binary forms, with or without 5 | * modification, are permitted provided that the following conditions are met: 6 | * 7 | * 1. Redistributions of source code must retain the above copyright notice, 8 | * this list of conditions and the following disclaimer. 9 | * 10 | * 2. Redistributions in binary form must reproduce the above copyright notice, 11 | * this list of conditions and the following disclaimer in the documentation 12 | * and/or other materials provided with the distribution. 13 | * 14 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 15 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 16 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 17 | * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE 18 | * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 19 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 20 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 21 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 22 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 23 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 24 | * POSSIBILITY OF SUCH DAMAGE. 25 | */ 26 | 27 | #ifndef __EXAMPLE_H__ 28 | #define __EXAMPLE_H__ 29 | 30 | #include 31 | 32 | typedef struct example_s { 33 | uint8_t *key; 34 | uint8_t *val; 35 | size_t key_length; 36 | size_t val_length; 37 | } example_t; 38 | 39 | example_t * example_new_with_cstr(char *key, char *val); 40 | 41 | void example_print_cstr(example_t *example); 42 | 43 | void example_free(example_t *example); 44 | 45 | #endif // __EXAMPLE_H__ 46 | -------------------------------------------------------------------------------- /src/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2018 Peter Nelson (peter@peterdn.com) 2 | # 3 | # Redistribution and use in source and binary forms, with or without 4 | # modification, are permitted provided that the following conditions are met: 5 | # 6 | # 1. Redistributions of source code must retain the above copyright notice, 7 | # this list of conditions and the following disclaimer. 8 | # 9 | # 2. Redistributions in binary form must reproduce the above copyright notice, 10 | # this list of conditions and the following disclaimer in the documentation 11 | # and/or other materials provided with the distribution. 12 | # 13 | # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 14 | # AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 15 | # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 16 | # ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE 17 | # LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 18 | # CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 19 | # SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 20 | # INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 21 | # CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 22 | # ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 23 | # POSSIBILITY OF SUCH DAMAGE. 24 | 25 | ######################################## 26 | # Configure an example shared library. # 27 | ######################################## 28 | 29 | add_library(example SHARED 30 | example.c 31 | ) 32 | -------------------------------------------------------------------------------- /src/example.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2018 Peter Nelson (peter@peterdn.com) 3 | * 4 | * Redistribution and use in source and binary forms, with or without 5 | * modification, are permitted provided that the following conditions are met: 6 | * 7 | * 1. Redistributions of source code must retain the above copyright notice, 8 | * this list of conditions and the following disclaimer. 9 | * 10 | * 2. Redistributions in binary form must reproduce the above copyright notice, 11 | * this list of conditions and the following disclaimer in the documentation 12 | * and/or other materials provided with the distribution. 13 | * 14 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 15 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 16 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 17 | * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE 18 | * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 19 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 20 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 21 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 22 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 23 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 24 | * POSSIBILITY OF SUCH DAMAGE. 25 | */ 26 | 27 | #include 28 | #include 29 | #include 30 | 31 | #include "example/example.h" 32 | 33 | example_t * example_new_with_cstr(char *key, char *val) { 34 | example_t *ret = (example_t *) calloc(1, sizeof(example_t)); 35 | if (!ret) { 36 | return NULL; 37 | } 38 | 39 | ret->key_length = strlen(key) + 1; 40 | ret->val_length = strlen(val) + 1; 41 | 42 | ret->key = (uint8_t *) calloc(ret->key_length, sizeof(char)); 43 | if (!ret->key) { 44 | goto cleanup_ret; 45 | } 46 | strncpy((char *)ret->key, key, ret->key_length); 47 | 48 | 49 | ret->val = (uint8_t *) calloc(ret->val_length, sizeof(char)); 50 | if (!ret->val) { 51 | goto cleanup_key; 52 | } 53 | strncpy((char *)ret->val, val, ret->val_length); 54 | 55 | return ret; 56 | 57 | cleanup_key: 58 | free(ret->key); 59 | cleanup_ret: 60 | free(ret); 61 | return NULL; 62 | } 63 | 64 | void example_print_cstr(example_t *example) { 65 | printf("key: %s (%lu bytes)\n", example->key, example->key_length); 66 | printf("val: %s (%lu bytes)\n", example->val, example->val_length); 67 | } 68 | 69 | void example_free(example_t *example) { 70 | if (example != NULL) { 71 | if (example->key != NULL) { 72 | free(example->key); 73 | } 74 | if (example->val != NULL) { 75 | free(example->val); 76 | } 77 | free(example); 78 | } 79 | } 80 | -------------------------------------------------------------------------------- /test/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2018 Peter Nelson (peter@peterdn.com) 2 | # 3 | # Redistribution and use in source and binary forms, with or without 4 | # modification, are permitted provided that the following conditions are met: 5 | # 6 | # 1. Redistributions of source code must retain the above copyright notice, 7 | # this list of conditions and the following disclaimer. 8 | # 9 | # 2. Redistributions in binary form must reproduce the above copyright notice, 10 | # this list of conditions and the following disclaimer in the documentation 11 | # and/or other materials provided with the distribution. 12 | # 13 | # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 14 | # AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 15 | # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 16 | # ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE 17 | # LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 18 | # CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 19 | # SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 20 | # INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 21 | # CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 22 | # ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 23 | # POSSIBILITY OF SUCH DAMAGE. 24 | 25 | # Include Unity test framework. 26 | add_subdirectory(unity) 27 | 28 | ##################################### 29 | # Configure an example test binary. # 30 | ##################################### 31 | 32 | add_executable( 33 | example_test 34 | example_test.c 35 | ) 36 | 37 | target_link_libraries( 38 | example_test 39 | unity 40 | example 41 | ) 42 | 43 | target_include_directories( 44 | example_test PUBLIC 45 | ${PROJECT_SOURCE_DIR}/test/unity 46 | ) 47 | 48 | set_target_properties( 49 | example_test 50 | PROPERTIES 51 | RUNTIME_OUTPUT_DIRECTORY "${TEST_OUTPUT_PATH}" 52 | ) 53 | 54 | add_test(example_test "${TEST_OUTPUT_PATH}/example_test") 55 | -------------------------------------------------------------------------------- /test/example_test.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2018 Peter Nelson (peter@peterdn.com) 3 | * 4 | * Redistribution and use in source and binary forms, with or without 5 | * modification, are permitted provided that the following conditions are met: 6 | * 7 | * 1. Redistributions of source code must retain the above copyright notice, 8 | * this list of conditions and the following disclaimer. 9 | * 10 | * 2. Redistributions in binary form must reproduce the above copyright notice, 11 | * this list of conditions and the following disclaimer in the documentation 12 | * and/or other materials provided with the distribution. 13 | * 14 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 15 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 16 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 17 | * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE 18 | * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 19 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 20 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 21 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 22 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 23 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 24 | * POSSIBILITY OF SUCH DAMAGE. 25 | */ 26 | 27 | #include 28 | #include 29 | 30 | #include "unity_fixture.h" 31 | 32 | #include "example/example.h" 33 | 34 | static char *key = "test_key"; 35 | static char *val = "test_val"; 36 | static example_t *example = NULL; 37 | 38 | TEST_GROUP(example); 39 | 40 | TEST_SETUP(example) { 41 | example = example_new_with_cstr(key, val); 42 | } 43 | 44 | TEST_TEAR_DOWN(example) { 45 | if (example) { 46 | example_free(example); 47 | } 48 | } 49 | 50 | TEST(example, test_example_new_with_cstr) { 51 | TEST_ASSERT_EQUAL_STRING(key, example->key); 52 | TEST_ASSERT_EQUAL_STRING(val, example->val); 53 | } 54 | 55 | TEST_GROUP_RUNNER(example) { 56 | RUN_TEST_CASE(example, test_example_new_with_cstr); 57 | } 58 | 59 | int main(void) { 60 | UNITY_BEGIN(); 61 | RUN_TEST_GROUP(example); 62 | return UNITY_END(); 63 | } 64 | -------------------------------------------------------------------------------- /test/unity/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2018 Peter Nelson (peter@peterdn.com) 2 | # 3 | # Redistribution and use in source and binary forms, with or without 4 | # modification, are permitted provided that the following conditions are met: 5 | # 6 | # 1. Redistributions of source code must retain the above copyright notice, 7 | # this list of conditions and the following disclaimer. 8 | # 9 | # 2. Redistributions in binary form must reproduce the above copyright notice, 10 | # this list of conditions and the following disclaimer in the documentation 11 | # and/or other materials provided with the distribution. 12 | # 13 | # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 14 | # AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 15 | # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 16 | # ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE 17 | # LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 18 | # CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 19 | # SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 20 | # INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 21 | # CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 22 | # ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 23 | # POSSIBILITY OF SUCH DAMAGE. 24 | 25 | ######################################## 26 | # Configure static Unity test library. # 27 | ######################################## 28 | 29 | add_library( 30 | unity STATIC 31 | unity.c 32 | unity_fixture.c 33 | ) 34 | -------------------------------------------------------------------------------- /test/unity/license.txt: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2007-14 Mike Karlesky, Mark VanderVoord, Greg Williams 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in 13 | all copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 21 | THE SOFTWARE. 22 | -------------------------------------------------------------------------------- /test/unity/unity.c: -------------------------------------------------------------------------------- 1 | /* ========================================================================= 2 | Unity Project - A Test Framework for C 3 | Copyright (c) 2007-14 Mike Karlesky, Mark VanderVoord, Greg Williams 4 | [Released under MIT License. Please refer to license.txt for details] 5 | ============================================================================ */ 6 | 7 | #define UNITY_INCLUDE_SETUP_STUBS 8 | #include "unity.h" 9 | #include 10 | 11 | /* If omitted from header, declare overrideable prototypes here so they're ready for use */ 12 | #ifdef UNITY_OMIT_OUTPUT_CHAR_HEADER_DECLARATION 13 | void UNITY_OUTPUT_CHAR(int); 14 | #endif 15 | 16 | /* Helpful macros for us to use here in Assert functions */ 17 | #define UNITY_FAIL_AND_BAIL { Unity.CurrentTestFailed = 1; TEST_ABORT(); } 18 | #define UNITY_IGNORE_AND_BAIL { Unity.CurrentTestIgnored = 1; TEST_ABORT(); } 19 | #define RETURN_IF_FAIL_OR_IGNORE if (Unity.CurrentTestFailed || Unity.CurrentTestIgnored) return 20 | 21 | struct UNITY_STORAGE_T Unity; 22 | 23 | #ifdef UNITY_OUTPUT_COLOR 24 | static const char UnityStrOk[] = "\033[42mOK\033[00m"; 25 | static const char UnityStrPass[] = "\033[42mPASS\033[00m"; 26 | static const char UnityStrFail[] = "\033[41mFAIL\033[00m"; 27 | static const char UnityStrIgnore[] = "\033[43mIGNORE\033[00m"; 28 | #else 29 | static const char UnityStrOk[] = "OK"; 30 | static const char UnityStrPass[] = "PASS"; 31 | static const char UnityStrFail[] = "FAIL"; 32 | static const char UnityStrIgnore[] = "IGNORE"; 33 | #endif 34 | static const char UnityStrNull[] = "NULL"; 35 | static const char UnityStrSpacer[] = ". "; 36 | static const char UnityStrExpected[] = " Expected "; 37 | static const char UnityStrWas[] = " Was "; 38 | static const char UnityStrGt[] = " to be greater than "; 39 | static const char UnityStrLt[] = " to be less than "; 40 | static const char UnityStrOrEqual[] = "or equal to "; 41 | static const char UnityStrElement[] = " Element "; 42 | static const char UnityStrByte[] = " Byte "; 43 | static const char UnityStrMemory[] = " Memory Mismatch."; 44 | static const char UnityStrDelta[] = " Values Not Within Delta "; 45 | static const char UnityStrPointless[] = " You Asked Me To Compare Nothing, Which Was Pointless."; 46 | static const char UnityStrNullPointerForExpected[] = " Expected pointer to be NULL"; 47 | static const char UnityStrNullPointerForActual[] = " Actual pointer was NULL"; 48 | #ifndef UNITY_EXCLUDE_FLOAT 49 | static const char UnityStrNot[] = "Not "; 50 | static const char UnityStrInf[] = "Infinity"; 51 | static const char UnityStrNegInf[] = "Negative Infinity"; 52 | static const char UnityStrNaN[] = "NaN"; 53 | static const char UnityStrDet[] = "Determinate"; 54 | static const char UnityStrInvalidFloatTrait[] = "Invalid Float Trait"; 55 | #endif 56 | const char UnityStrErrFloat[] = "Unity Floating Point Disabled"; 57 | const char UnityStrErrDouble[] = "Unity Double Precision Disabled"; 58 | const char UnityStrErr64[] = "Unity 64-bit Support Disabled"; 59 | static const char UnityStrBreaker[] = "-----------------------"; 60 | static const char UnityStrResultsTests[] = " Tests "; 61 | static const char UnityStrResultsFailures[] = " Failures "; 62 | static const char UnityStrResultsIgnored[] = " Ignored "; 63 | static const char UnityStrDetail1Name[] = UNITY_DETAIL1_NAME " "; 64 | static const char UnityStrDetail2Name[] = " " UNITY_DETAIL2_NAME " "; 65 | 66 | /*----------------------------------------------- 67 | * Pretty Printers & Test Result Output Handlers 68 | *-----------------------------------------------*/ 69 | 70 | void UnityPrint(const char* string) 71 | { 72 | const char* pch = string; 73 | 74 | if (pch != NULL) 75 | { 76 | while (*pch) 77 | { 78 | /* printable characters plus CR & LF are printed */ 79 | if ((*pch <= 126) && (*pch >= 32)) 80 | { 81 | UNITY_OUTPUT_CHAR(*pch); 82 | } 83 | /* write escaped carriage returns */ 84 | else if (*pch == 13) 85 | { 86 | UNITY_OUTPUT_CHAR('\\'); 87 | UNITY_OUTPUT_CHAR('r'); 88 | } 89 | /* write escaped line feeds */ 90 | else if (*pch == 10) 91 | { 92 | UNITY_OUTPUT_CHAR('\\'); 93 | UNITY_OUTPUT_CHAR('n'); 94 | } 95 | #ifdef UNITY_OUTPUT_COLOR 96 | /* print ANSI escape code */ 97 | else if (*pch == 27 && *(pch + 1) == '[') 98 | { 99 | while (*pch && *pch != 'm') 100 | { 101 | UNITY_OUTPUT_CHAR(*pch); 102 | pch++; 103 | } 104 | UNITY_OUTPUT_CHAR('m'); 105 | } 106 | #endif 107 | /* unprintable characters are shown as codes */ 108 | else 109 | { 110 | UNITY_OUTPUT_CHAR('\\'); 111 | UNITY_OUTPUT_CHAR('x'); 112 | UnityPrintNumberHex((UNITY_UINT)*pch, 2); 113 | } 114 | pch++; 115 | } 116 | } 117 | } 118 | 119 | void UnityPrintLen(const char* string, const UNITY_UINT32 length) 120 | { 121 | const char* pch = string; 122 | 123 | if (pch != NULL) 124 | { 125 | while (*pch && (UNITY_UINT32)(pch - string) < length) 126 | { 127 | /* printable characters plus CR & LF are printed */ 128 | if ((*pch <= 126) && (*pch >= 32)) 129 | { 130 | UNITY_OUTPUT_CHAR(*pch); 131 | } 132 | /* write escaped carriage returns */ 133 | else if (*pch == 13) 134 | { 135 | UNITY_OUTPUT_CHAR('\\'); 136 | UNITY_OUTPUT_CHAR('r'); 137 | } 138 | /* write escaped line feeds */ 139 | else if (*pch == 10) 140 | { 141 | UNITY_OUTPUT_CHAR('\\'); 142 | UNITY_OUTPUT_CHAR('n'); 143 | } 144 | /* unprintable characters are shown as codes */ 145 | else 146 | { 147 | UNITY_OUTPUT_CHAR('\\'); 148 | UNITY_OUTPUT_CHAR('x'); 149 | UnityPrintNumberHex((UNITY_UINT)*pch, 2); 150 | } 151 | pch++; 152 | } 153 | } 154 | } 155 | 156 | /*-----------------------------------------------*/ 157 | void UnityPrintNumberByStyle(const UNITY_INT number, const UNITY_DISPLAY_STYLE_T style) 158 | { 159 | if ((style & UNITY_DISPLAY_RANGE_INT) == UNITY_DISPLAY_RANGE_INT) 160 | { 161 | UnityPrintNumber(number); 162 | } 163 | else if ((style & UNITY_DISPLAY_RANGE_UINT) == UNITY_DISPLAY_RANGE_UINT) 164 | { 165 | UnityPrintNumberUnsigned((UNITY_UINT)number); 166 | } 167 | else 168 | { 169 | UNITY_OUTPUT_CHAR('0'); 170 | UNITY_OUTPUT_CHAR('x'); 171 | UnityPrintNumberHex((UNITY_UINT)number, (char)((style & 0xF) * 2)); 172 | } 173 | } 174 | 175 | /*-----------------------------------------------*/ 176 | void UnityPrintNumber(const UNITY_INT number_to_print) 177 | { 178 | UNITY_UINT number = (UNITY_UINT)number_to_print; 179 | 180 | if (number_to_print < 0) 181 | { 182 | /* A negative number, including MIN negative */ 183 | UNITY_OUTPUT_CHAR('-'); 184 | number = (UNITY_UINT)(-number_to_print); 185 | } 186 | UnityPrintNumberUnsigned(number); 187 | } 188 | 189 | /*----------------------------------------------- 190 | * basically do an itoa using as little ram as possible */ 191 | void UnityPrintNumberUnsigned(const UNITY_UINT number) 192 | { 193 | UNITY_UINT divisor = 1; 194 | 195 | /* figure out initial divisor */ 196 | while (number / divisor > 9) 197 | { 198 | divisor *= 10; 199 | } 200 | 201 | /* now mod and print, then divide divisor */ 202 | do 203 | { 204 | UNITY_OUTPUT_CHAR((char)('0' + (number / divisor % 10))); 205 | divisor /= 10; 206 | } while (divisor > 0); 207 | } 208 | 209 | /*-----------------------------------------------*/ 210 | void UnityPrintNumberHex(const UNITY_UINT number, const char nibbles_to_print) 211 | { 212 | int nibble; 213 | char nibbles = nibbles_to_print; 214 | if ((unsigned)nibbles > (2 * sizeof(number))) 215 | nibbles = 2 * sizeof(number); 216 | 217 | while (nibbles > 0) 218 | { 219 | nibbles--; 220 | nibble = (int)(number >> (nibbles * 4)) & 0x0F; 221 | if (nibble <= 9) 222 | { 223 | UNITY_OUTPUT_CHAR((char)('0' + nibble)); 224 | } 225 | else 226 | { 227 | UNITY_OUTPUT_CHAR((char)('A' - 10 + nibble)); 228 | } 229 | } 230 | } 231 | 232 | /*-----------------------------------------------*/ 233 | void UnityPrintMask(const UNITY_UINT mask, const UNITY_UINT number) 234 | { 235 | UNITY_UINT current_bit = (UNITY_UINT)1 << (UNITY_INT_WIDTH - 1); 236 | UNITY_INT32 i; 237 | 238 | for (i = 0; i < UNITY_INT_WIDTH; i++) 239 | { 240 | if (current_bit & mask) 241 | { 242 | if (current_bit & number) 243 | { 244 | UNITY_OUTPUT_CHAR('1'); 245 | } 246 | else 247 | { 248 | UNITY_OUTPUT_CHAR('0'); 249 | } 250 | } 251 | else 252 | { 253 | UNITY_OUTPUT_CHAR('X'); 254 | } 255 | current_bit = current_bit >> 1; 256 | } 257 | } 258 | 259 | /*-----------------------------------------------*/ 260 | #ifndef UNITY_EXCLUDE_FLOAT_PRINT 261 | /* This function prints a floating-point value in a format similar to 262 | * printf("%.6g"). It can work with either single- or double-precision, 263 | * but for simplicity, it prints only 6 significant digits in either case. 264 | * Printing more than 6 digits accurately is hard (at least in the single- 265 | * precision case) and isn't attempted here. */ 266 | void UnityPrintFloat(const UNITY_DOUBLE input_number) 267 | { 268 | UNITY_DOUBLE number = input_number; 269 | 270 | /* print minus sign (including for negative zero) */ 271 | if (number < 0.0f || (number == 0.0f && 1.0f / number < 0.0f)) 272 | { 273 | UNITY_OUTPUT_CHAR('-'); 274 | number = -number; 275 | } 276 | 277 | /* handle zero, NaN, and +/- infinity */ 278 | if (number == 0.0f) UnityPrint("0"); 279 | else if (isnan(number)) UnityPrint("nan"); 280 | else if (isinf(number)) UnityPrint("inf"); 281 | else 282 | { 283 | int exponent = 0; 284 | int decimals, digits; 285 | UNITY_INT32 n; 286 | char buf[16]; 287 | 288 | /* scale up or down by powers of 10 */ 289 | while (number < 100000.0f / 1e6f) { number *= 1e6f; exponent -= 6; } 290 | while (number < 100000.0f) { number *= 10.0f; exponent--; } 291 | while (number > 1000000.0f * 1e6f) { number /= 1e6f; exponent += 6; } 292 | while (number > 1000000.0f) { number /= 10.0f; exponent++; } 293 | 294 | /* round to nearest integer */ 295 | n = ((UNITY_INT32)(number + number) + 1) / 2; 296 | if (n > 999999) 297 | { 298 | n = 100000; 299 | exponent++; 300 | } 301 | 302 | /* determine where to place decimal point */ 303 | decimals = (exponent <= 0 && exponent >= -9) ? -exponent : 5; 304 | exponent += decimals; 305 | 306 | /* truncate trailing zeroes after decimal point */ 307 | while (decimals > 0 && n % 10 == 0) 308 | { 309 | n /= 10; 310 | decimals--; 311 | } 312 | 313 | /* build up buffer in reverse order */ 314 | digits = 0; 315 | while (n != 0 || digits < decimals + 1) 316 | { 317 | buf[digits++] = (char)('0' + n % 10); 318 | n /= 10; 319 | } 320 | while (digits > 0) 321 | { 322 | if(digits == decimals) UNITY_OUTPUT_CHAR('.'); 323 | UNITY_OUTPUT_CHAR(buf[--digits]); 324 | } 325 | 326 | /* print exponent if needed */ 327 | if (exponent != 0) 328 | { 329 | UNITY_OUTPUT_CHAR('e'); 330 | 331 | if(exponent < 0) 332 | { 333 | UNITY_OUTPUT_CHAR('-'); 334 | exponent = -exponent; 335 | } 336 | else 337 | { 338 | UNITY_OUTPUT_CHAR('+'); 339 | } 340 | 341 | digits = 0; 342 | while (exponent != 0 || digits < 2) 343 | { 344 | buf[digits++] = (char)('0' + exponent % 10); 345 | exponent /= 10; 346 | } 347 | while (digits > 0) 348 | { 349 | UNITY_OUTPUT_CHAR(buf[--digits]); 350 | } 351 | } 352 | } 353 | } 354 | #endif /* ! UNITY_EXCLUDE_FLOAT_PRINT */ 355 | 356 | /*-----------------------------------------------*/ 357 | static void UnityTestResultsBegin(const char* file, const UNITY_LINE_TYPE line) 358 | { 359 | UnityPrint(file); 360 | UNITY_OUTPUT_CHAR(':'); 361 | UnityPrintNumber((UNITY_INT)line); 362 | UNITY_OUTPUT_CHAR(':'); 363 | UnityPrint(Unity.CurrentTestName); 364 | UNITY_OUTPUT_CHAR(':'); 365 | } 366 | 367 | /*-----------------------------------------------*/ 368 | static void UnityTestResultsFailBegin(const UNITY_LINE_TYPE line) 369 | { 370 | UnityTestResultsBegin(Unity.TestFile, line); 371 | UnityPrint(UnityStrFail); 372 | UNITY_OUTPUT_CHAR(':'); 373 | } 374 | 375 | /*-----------------------------------------------*/ 376 | void UnityConcludeTest(void) 377 | { 378 | if (Unity.CurrentTestIgnored) 379 | { 380 | Unity.TestIgnores++; 381 | } 382 | else if (!Unity.CurrentTestFailed) 383 | { 384 | UnityTestResultsBegin(Unity.TestFile, Unity.CurrentTestLineNumber); 385 | UnityPrint(UnityStrPass); 386 | } 387 | else 388 | { 389 | Unity.TestFailures++; 390 | } 391 | 392 | Unity.CurrentTestFailed = 0; 393 | Unity.CurrentTestIgnored = 0; 394 | UNITY_PRINT_EOL(); 395 | UNITY_FLUSH_CALL(); 396 | } 397 | 398 | /*-----------------------------------------------*/ 399 | static void UnityAddMsgIfSpecified(const char* msg) 400 | { 401 | if (msg) 402 | { 403 | UnityPrint(UnityStrSpacer); 404 | #ifndef UNITY_EXCLUDE_DETAILS 405 | if (Unity.CurrentDetail1) 406 | { 407 | UnityPrint(UnityStrDetail1Name); 408 | UnityPrint(Unity.CurrentDetail1); 409 | if (Unity.CurrentDetail2) 410 | { 411 | UnityPrint(UnityStrDetail2Name); 412 | UnityPrint(Unity.CurrentDetail2); 413 | } 414 | UnityPrint(UnityStrSpacer); 415 | } 416 | #endif 417 | UnityPrint(msg); 418 | } 419 | } 420 | 421 | /*-----------------------------------------------*/ 422 | static void UnityPrintExpectedAndActualStrings(const char* expected, const char* actual) 423 | { 424 | UnityPrint(UnityStrExpected); 425 | if (expected != NULL) 426 | { 427 | UNITY_OUTPUT_CHAR('\''); 428 | UnityPrint(expected); 429 | UNITY_OUTPUT_CHAR('\''); 430 | } 431 | else 432 | { 433 | UnityPrint(UnityStrNull); 434 | } 435 | UnityPrint(UnityStrWas); 436 | if (actual != NULL) 437 | { 438 | UNITY_OUTPUT_CHAR('\''); 439 | UnityPrint(actual); 440 | UNITY_OUTPUT_CHAR('\''); 441 | } 442 | else 443 | { 444 | UnityPrint(UnityStrNull); 445 | } 446 | } 447 | 448 | /*-----------------------------------------------*/ 449 | static void UnityPrintExpectedAndActualStringsLen(const char* expected, 450 | const char* actual, 451 | const UNITY_UINT32 length) 452 | { 453 | UnityPrint(UnityStrExpected); 454 | if (expected != NULL) 455 | { 456 | UNITY_OUTPUT_CHAR('\''); 457 | UnityPrintLen(expected, length); 458 | UNITY_OUTPUT_CHAR('\''); 459 | } 460 | else 461 | { 462 | UnityPrint(UnityStrNull); 463 | } 464 | UnityPrint(UnityStrWas); 465 | if (actual != NULL) 466 | { 467 | UNITY_OUTPUT_CHAR('\''); 468 | UnityPrintLen(actual, length); 469 | UNITY_OUTPUT_CHAR('\''); 470 | } 471 | else 472 | { 473 | UnityPrint(UnityStrNull); 474 | } 475 | } 476 | 477 | /*----------------------------------------------- 478 | * Assertion & Control Helpers 479 | *-----------------------------------------------*/ 480 | 481 | static int UnityIsOneArrayNull(UNITY_INTERNAL_PTR expected, 482 | UNITY_INTERNAL_PTR actual, 483 | const UNITY_LINE_TYPE lineNumber, 484 | const char* msg) 485 | { 486 | if (expected == actual) return 0; /* Both are NULL or same pointer */ 487 | 488 | /* print and return true if just expected is NULL */ 489 | if (expected == NULL) 490 | { 491 | UnityTestResultsFailBegin(lineNumber); 492 | UnityPrint(UnityStrNullPointerForExpected); 493 | UnityAddMsgIfSpecified(msg); 494 | return 1; 495 | } 496 | 497 | /* print and return true if just actual is NULL */ 498 | if (actual == NULL) 499 | { 500 | UnityTestResultsFailBegin(lineNumber); 501 | UnityPrint(UnityStrNullPointerForActual); 502 | UnityAddMsgIfSpecified(msg); 503 | return 1; 504 | } 505 | 506 | return 0; /* return false if neither is NULL */ 507 | } 508 | 509 | /*----------------------------------------------- 510 | * Assertion Functions 511 | *-----------------------------------------------*/ 512 | 513 | void UnityAssertBits(const UNITY_INT mask, 514 | const UNITY_INT expected, 515 | const UNITY_INT actual, 516 | const char* msg, 517 | const UNITY_LINE_TYPE lineNumber) 518 | { 519 | RETURN_IF_FAIL_OR_IGNORE; 520 | 521 | if ((mask & expected) != (mask & actual)) 522 | { 523 | UnityTestResultsFailBegin(lineNumber); 524 | UnityPrint(UnityStrExpected); 525 | UnityPrintMask((UNITY_UINT)mask, (UNITY_UINT)expected); 526 | UnityPrint(UnityStrWas); 527 | UnityPrintMask((UNITY_UINT)mask, (UNITY_UINT)actual); 528 | UnityAddMsgIfSpecified(msg); 529 | UNITY_FAIL_AND_BAIL; 530 | } 531 | } 532 | 533 | /*-----------------------------------------------*/ 534 | void UnityAssertEqualNumber(const UNITY_INT expected, 535 | const UNITY_INT actual, 536 | const char* msg, 537 | const UNITY_LINE_TYPE lineNumber, 538 | const UNITY_DISPLAY_STYLE_T style) 539 | { 540 | RETURN_IF_FAIL_OR_IGNORE; 541 | 542 | if (expected != actual) 543 | { 544 | UnityTestResultsFailBegin(lineNumber); 545 | UnityPrint(UnityStrExpected); 546 | UnityPrintNumberByStyle(expected, style); 547 | UnityPrint(UnityStrWas); 548 | UnityPrintNumberByStyle(actual, style); 549 | UnityAddMsgIfSpecified(msg); 550 | UNITY_FAIL_AND_BAIL; 551 | } 552 | } 553 | 554 | /*-----------------------------------------------*/ 555 | void UnityAssertGreaterOrLessOrEqualNumber(const UNITY_INT threshold, 556 | const UNITY_INT actual, 557 | const UNITY_COMPARISON_T compare, 558 | const char *msg, 559 | const UNITY_LINE_TYPE lineNumber, 560 | const UNITY_DISPLAY_STYLE_T style) 561 | { 562 | int failed = 0; 563 | RETURN_IF_FAIL_OR_IGNORE; 564 | 565 | if (threshold == actual && compare & UNITY_EQUAL_TO) return; 566 | if (threshold == actual) failed = 1; 567 | 568 | if ((style & UNITY_DISPLAY_RANGE_INT) == UNITY_DISPLAY_RANGE_INT) 569 | { 570 | if (actual > threshold && compare & UNITY_SMALLER_THAN) failed = 1; 571 | if (actual < threshold && compare & UNITY_GREATER_THAN) failed = 1; 572 | } 573 | else /* UINT or HEX */ 574 | { 575 | if ((UNITY_UINT)actual > (UNITY_UINT)threshold && compare & UNITY_SMALLER_THAN) failed = 1; 576 | if ((UNITY_UINT)actual < (UNITY_UINT)threshold && compare & UNITY_GREATER_THAN) failed = 1; 577 | } 578 | 579 | if (failed) 580 | { 581 | UnityTestResultsFailBegin(lineNumber); 582 | UnityPrint(UnityStrExpected); 583 | UnityPrintNumberByStyle(actual, style); 584 | if (compare & UNITY_GREATER_THAN) UnityPrint(UnityStrGt); 585 | if (compare & UNITY_SMALLER_THAN) UnityPrint(UnityStrLt); 586 | if (compare & UNITY_EQUAL_TO) UnityPrint(UnityStrOrEqual); 587 | UnityPrintNumberByStyle(threshold, style); 588 | UnityAddMsgIfSpecified(msg); 589 | UNITY_FAIL_AND_BAIL; 590 | } 591 | } 592 | 593 | #define UnityPrintPointlessAndBail() \ 594 | { \ 595 | UnityTestResultsFailBegin(lineNumber); \ 596 | UnityPrint(UnityStrPointless); \ 597 | UnityAddMsgIfSpecified(msg); \ 598 | UNITY_FAIL_AND_BAIL; } 599 | 600 | /*-----------------------------------------------*/ 601 | void UnityAssertEqualIntArray(UNITY_INTERNAL_PTR expected, 602 | UNITY_INTERNAL_PTR actual, 603 | const UNITY_UINT32 num_elements, 604 | const char* msg, 605 | const UNITY_LINE_TYPE lineNumber, 606 | const UNITY_DISPLAY_STYLE_T style, 607 | const UNITY_FLAGS_T flags) 608 | { 609 | UNITY_UINT32 elements = num_elements; 610 | unsigned int length = style & 0xF; 611 | 612 | RETURN_IF_FAIL_OR_IGNORE; 613 | 614 | if (num_elements == 0) 615 | { 616 | UnityPrintPointlessAndBail(); 617 | } 618 | 619 | if (expected == actual) return; /* Both are NULL or same pointer */ 620 | if (UnityIsOneArrayNull(expected, actual, lineNumber, msg)) 621 | UNITY_FAIL_AND_BAIL; 622 | 623 | while ((elements > 0) && elements--) 624 | { 625 | UNITY_INT expect_val; 626 | UNITY_INT actual_val; 627 | switch (length) 628 | { 629 | case 1: 630 | expect_val = *(UNITY_PTR_ATTRIBUTE const UNITY_INT8*)expected; 631 | actual_val = *(UNITY_PTR_ATTRIBUTE const UNITY_INT8*)actual; 632 | break; 633 | case 2: 634 | expect_val = *(UNITY_PTR_ATTRIBUTE const UNITY_INT16*)expected; 635 | actual_val = *(UNITY_PTR_ATTRIBUTE const UNITY_INT16*)actual; 636 | break; 637 | #ifdef UNITY_SUPPORT_64 638 | case 8: 639 | expect_val = *(UNITY_PTR_ATTRIBUTE const UNITY_INT64*)expected; 640 | actual_val = *(UNITY_PTR_ATTRIBUTE const UNITY_INT64*)actual; 641 | break; 642 | #endif 643 | default: /* length 4 bytes */ 644 | expect_val = *(UNITY_PTR_ATTRIBUTE const UNITY_INT32*)expected; 645 | actual_val = *(UNITY_PTR_ATTRIBUTE const UNITY_INT32*)actual; 646 | length = 4; 647 | break; 648 | } 649 | 650 | if (expect_val != actual_val) 651 | { 652 | if (style & UNITY_DISPLAY_RANGE_UINT && length < sizeof(expect_val)) 653 | { /* For UINT, remove sign extension (padding 1's) from signed type casts above */ 654 | UNITY_INT mask = 1; 655 | mask = (mask << 8 * length) - 1; 656 | expect_val &= mask; 657 | actual_val &= mask; 658 | } 659 | UnityTestResultsFailBegin(lineNumber); 660 | UnityPrint(UnityStrElement); 661 | UnityPrintNumberUnsigned(num_elements - elements - 1); 662 | UnityPrint(UnityStrExpected); 663 | UnityPrintNumberByStyle(expect_val, style); 664 | UnityPrint(UnityStrWas); 665 | UnityPrintNumberByStyle(actual_val, style); 666 | UnityAddMsgIfSpecified(msg); 667 | UNITY_FAIL_AND_BAIL; 668 | } 669 | if (flags == UNITY_ARRAY_TO_ARRAY) 670 | { 671 | expected = (UNITY_INTERNAL_PTR)(length + (const char*)expected); 672 | } 673 | actual = (UNITY_INTERNAL_PTR)(length + (const char*)actual); 674 | } 675 | } 676 | 677 | /*-----------------------------------------------*/ 678 | #ifndef UNITY_EXCLUDE_FLOAT 679 | /* Wrap this define in a function with variable types as float or double */ 680 | #define UNITY_FLOAT_OR_DOUBLE_WITHIN(delta, expected, actual, diff) \ 681 | if (isinf(expected) && isinf(actual) && (((expected) < 0) == ((actual) < 0))) return 1; \ 682 | if (UNITY_NAN_CHECK) return 1; \ 683 | (diff) = (actual) - (expected); \ 684 | if ((diff) < 0) (diff) = -(diff); \ 685 | if ((delta) < 0) (delta) = -(delta); \ 686 | return !(isnan(diff) || isinf(diff) || ((diff) > (delta))) 687 | /* This first part of this condition will catch any NaN or Infinite values */ 688 | #ifndef UNITY_NAN_NOT_EQUAL_NAN 689 | #define UNITY_NAN_CHECK isnan(expected) && isnan(actual) 690 | #else 691 | #define UNITY_NAN_CHECK 0 692 | #endif 693 | 694 | #ifndef UNITY_EXCLUDE_FLOAT_PRINT 695 | #define UNITY_PRINT_EXPECTED_AND_ACTUAL_FLOAT(expected, actual) \ 696 | { \ 697 | UnityPrint(UnityStrExpected); \ 698 | UnityPrintFloat(expected); \ 699 | UnityPrint(UnityStrWas); \ 700 | UnityPrintFloat(actual); } 701 | #else 702 | #define UNITY_PRINT_EXPECTED_AND_ACTUAL_FLOAT(expected, actual) \ 703 | UnityPrint(UnityStrDelta) 704 | #endif /* UNITY_EXCLUDE_FLOAT_PRINT */ 705 | 706 | static int UnityFloatsWithin(UNITY_FLOAT delta, UNITY_FLOAT expected, UNITY_FLOAT actual) 707 | { 708 | UNITY_FLOAT diff; 709 | UNITY_FLOAT_OR_DOUBLE_WITHIN(delta, expected, actual, diff); 710 | } 711 | 712 | void UnityAssertEqualFloatArray(UNITY_PTR_ATTRIBUTE const UNITY_FLOAT* expected, 713 | UNITY_PTR_ATTRIBUTE const UNITY_FLOAT* actual, 714 | const UNITY_UINT32 num_elements, 715 | const char* msg, 716 | const UNITY_LINE_TYPE lineNumber, 717 | const UNITY_FLAGS_T flags) 718 | { 719 | UNITY_UINT32 elements = num_elements; 720 | UNITY_PTR_ATTRIBUTE const UNITY_FLOAT* ptr_expected = expected; 721 | UNITY_PTR_ATTRIBUTE const UNITY_FLOAT* ptr_actual = actual; 722 | 723 | RETURN_IF_FAIL_OR_IGNORE; 724 | 725 | if (elements == 0) 726 | { 727 | UnityPrintPointlessAndBail(); 728 | } 729 | 730 | if (expected == actual) return; /* Both are NULL or same pointer */ 731 | if (UnityIsOneArrayNull((UNITY_INTERNAL_PTR)expected, (UNITY_INTERNAL_PTR)actual, lineNumber, msg)) 732 | UNITY_FAIL_AND_BAIL; 733 | 734 | while (elements--) 735 | { 736 | if (!UnityFloatsWithin(*ptr_expected * UNITY_FLOAT_PRECISION, *ptr_expected, *ptr_actual)) 737 | { 738 | UnityTestResultsFailBegin(lineNumber); 739 | UnityPrint(UnityStrElement); 740 | UnityPrintNumberUnsigned(num_elements - elements - 1); 741 | UNITY_PRINT_EXPECTED_AND_ACTUAL_FLOAT((UNITY_DOUBLE)*ptr_expected, (UNITY_DOUBLE)*ptr_actual); 742 | UnityAddMsgIfSpecified(msg); 743 | UNITY_FAIL_AND_BAIL; 744 | } 745 | if (flags == UNITY_ARRAY_TO_ARRAY) 746 | { 747 | ptr_expected++; 748 | } 749 | ptr_actual++; 750 | } 751 | } 752 | 753 | /*-----------------------------------------------*/ 754 | void UnityAssertFloatsWithin(const UNITY_FLOAT delta, 755 | const UNITY_FLOAT expected, 756 | const UNITY_FLOAT actual, 757 | const char* msg, 758 | const UNITY_LINE_TYPE lineNumber) 759 | { 760 | RETURN_IF_FAIL_OR_IGNORE; 761 | 762 | 763 | if (!UnityFloatsWithin(delta, expected, actual)) 764 | { 765 | UnityTestResultsFailBegin(lineNumber); 766 | UNITY_PRINT_EXPECTED_AND_ACTUAL_FLOAT((UNITY_DOUBLE)expected, (UNITY_DOUBLE)actual); 767 | UnityAddMsgIfSpecified(msg); 768 | UNITY_FAIL_AND_BAIL; 769 | } 770 | } 771 | 772 | /*-----------------------------------------------*/ 773 | void UnityAssertFloatSpecial(const UNITY_FLOAT actual, 774 | const char* msg, 775 | const UNITY_LINE_TYPE lineNumber, 776 | const UNITY_FLOAT_TRAIT_T style) 777 | { 778 | const char* trait_names[] = {UnityStrInf, UnityStrNegInf, UnityStrNaN, UnityStrDet}; 779 | UNITY_INT should_be_trait = ((UNITY_INT)style & 1); 780 | UNITY_INT is_trait = !should_be_trait; 781 | UNITY_INT trait_index = (UNITY_INT)(style >> 1); 782 | 783 | RETURN_IF_FAIL_OR_IGNORE; 784 | 785 | switch (style) 786 | { 787 | case UNITY_FLOAT_IS_INF: 788 | case UNITY_FLOAT_IS_NOT_INF: 789 | is_trait = isinf(actual) && (actual > 0); 790 | break; 791 | case UNITY_FLOAT_IS_NEG_INF: 792 | case UNITY_FLOAT_IS_NOT_NEG_INF: 793 | is_trait = isinf(actual) && (actual < 0); 794 | break; 795 | 796 | case UNITY_FLOAT_IS_NAN: 797 | case UNITY_FLOAT_IS_NOT_NAN: 798 | is_trait = isnan(actual) ? 1 : 0; 799 | break; 800 | 801 | case UNITY_FLOAT_IS_DET: /* A determinate number is non infinite and not NaN. */ 802 | case UNITY_FLOAT_IS_NOT_DET: 803 | is_trait = !isinf(actual) && !isnan(actual); 804 | break; 805 | 806 | default: 807 | trait_index = 0; 808 | trait_names[0] = UnityStrInvalidFloatTrait; 809 | break; 810 | } 811 | 812 | if (is_trait != should_be_trait) 813 | { 814 | UnityTestResultsFailBegin(lineNumber); 815 | UnityPrint(UnityStrExpected); 816 | if (!should_be_trait) 817 | UnityPrint(UnityStrNot); 818 | UnityPrint(trait_names[trait_index]); 819 | UnityPrint(UnityStrWas); 820 | #ifndef UNITY_EXCLUDE_FLOAT_PRINT 821 | UnityPrintFloat((UNITY_DOUBLE)actual); 822 | #else 823 | if (should_be_trait) 824 | UnityPrint(UnityStrNot); 825 | UnityPrint(trait_names[trait_index]); 826 | #endif 827 | UnityAddMsgIfSpecified(msg); 828 | UNITY_FAIL_AND_BAIL; 829 | } 830 | } 831 | 832 | #endif /* not UNITY_EXCLUDE_FLOAT */ 833 | 834 | /*-----------------------------------------------*/ 835 | #ifndef UNITY_EXCLUDE_DOUBLE 836 | static int UnityDoublesWithin(UNITY_DOUBLE delta, UNITY_DOUBLE expected, UNITY_DOUBLE actual) 837 | { 838 | UNITY_DOUBLE diff; 839 | UNITY_FLOAT_OR_DOUBLE_WITHIN(delta, expected, actual, diff); 840 | } 841 | 842 | void UnityAssertEqualDoubleArray(UNITY_PTR_ATTRIBUTE const UNITY_DOUBLE* expected, 843 | UNITY_PTR_ATTRIBUTE const UNITY_DOUBLE* actual, 844 | const UNITY_UINT32 num_elements, 845 | const char* msg, 846 | const UNITY_LINE_TYPE lineNumber, 847 | const UNITY_FLAGS_T flags) 848 | { 849 | UNITY_UINT32 elements = num_elements; 850 | UNITY_PTR_ATTRIBUTE const UNITY_DOUBLE* ptr_expected = expected; 851 | UNITY_PTR_ATTRIBUTE const UNITY_DOUBLE* ptr_actual = actual; 852 | 853 | RETURN_IF_FAIL_OR_IGNORE; 854 | 855 | if (elements == 0) 856 | { 857 | UnityPrintPointlessAndBail(); 858 | } 859 | 860 | if (expected == actual) return; /* Both are NULL or same pointer */ 861 | if (UnityIsOneArrayNull((UNITY_INTERNAL_PTR)expected, (UNITY_INTERNAL_PTR)actual, lineNumber, msg)) 862 | UNITY_FAIL_AND_BAIL; 863 | 864 | while (elements--) 865 | { 866 | if (!UnityDoublesWithin(*ptr_expected * UNITY_DOUBLE_PRECISION, *ptr_expected, *ptr_actual)) 867 | { 868 | UnityTestResultsFailBegin(lineNumber); 869 | UnityPrint(UnityStrElement); 870 | UnityPrintNumberUnsigned(num_elements - elements - 1); 871 | UNITY_PRINT_EXPECTED_AND_ACTUAL_FLOAT(*ptr_expected, *ptr_actual); 872 | UnityAddMsgIfSpecified(msg); 873 | UNITY_FAIL_AND_BAIL; 874 | } 875 | if (flags == UNITY_ARRAY_TO_ARRAY) 876 | { 877 | ptr_expected++; 878 | } 879 | ptr_actual++; 880 | } 881 | } 882 | 883 | /*-----------------------------------------------*/ 884 | void UnityAssertDoublesWithin(const UNITY_DOUBLE delta, 885 | const UNITY_DOUBLE expected, 886 | const UNITY_DOUBLE actual, 887 | const char* msg, 888 | const UNITY_LINE_TYPE lineNumber) 889 | { 890 | RETURN_IF_FAIL_OR_IGNORE; 891 | 892 | if (!UnityDoublesWithin(delta, expected, actual)) 893 | { 894 | UnityTestResultsFailBegin(lineNumber); 895 | UNITY_PRINT_EXPECTED_AND_ACTUAL_FLOAT(expected, actual); 896 | UnityAddMsgIfSpecified(msg); 897 | UNITY_FAIL_AND_BAIL; 898 | } 899 | } 900 | 901 | /*-----------------------------------------------*/ 902 | 903 | void UnityAssertDoubleSpecial(const UNITY_DOUBLE actual, 904 | const char* msg, 905 | const UNITY_LINE_TYPE lineNumber, 906 | const UNITY_FLOAT_TRAIT_T style) 907 | { 908 | const char* trait_names[] = {UnityStrInf, UnityStrNegInf, UnityStrNaN, UnityStrDet}; 909 | UNITY_INT should_be_trait = ((UNITY_INT)style & 1); 910 | UNITY_INT is_trait = !should_be_trait; 911 | UNITY_INT trait_index = (UNITY_INT)(style >> 1); 912 | 913 | RETURN_IF_FAIL_OR_IGNORE; 914 | 915 | switch (style) 916 | { 917 | case UNITY_FLOAT_IS_INF: 918 | case UNITY_FLOAT_IS_NOT_INF: 919 | is_trait = isinf(actual) && (actual > 0); 920 | break; 921 | case UNITY_FLOAT_IS_NEG_INF: 922 | case UNITY_FLOAT_IS_NOT_NEG_INF: 923 | is_trait = isinf(actual) && (actual < 0); 924 | break; 925 | 926 | case UNITY_FLOAT_IS_NAN: 927 | case UNITY_FLOAT_IS_NOT_NAN: 928 | is_trait = isnan(actual) ? 1 : 0; 929 | break; 930 | 931 | case UNITY_FLOAT_IS_DET: /* A determinate number is non infinite and not NaN. */ 932 | case UNITY_FLOAT_IS_NOT_DET: 933 | is_trait = !isinf(actual) && !isnan(actual); 934 | break; 935 | 936 | default: 937 | trait_index = 0; 938 | trait_names[0] = UnityStrInvalidFloatTrait; 939 | break; 940 | } 941 | 942 | if (is_trait != should_be_trait) 943 | { 944 | UnityTestResultsFailBegin(lineNumber); 945 | UnityPrint(UnityStrExpected); 946 | if (!should_be_trait) 947 | UnityPrint(UnityStrNot); 948 | UnityPrint(trait_names[trait_index]); 949 | UnityPrint(UnityStrWas); 950 | #ifndef UNITY_EXCLUDE_FLOAT_PRINT 951 | UnityPrintFloat(actual); 952 | #else 953 | if (should_be_trait) 954 | UnityPrint(UnityStrNot); 955 | UnityPrint(trait_names[trait_index]); 956 | #endif 957 | UnityAddMsgIfSpecified(msg); 958 | UNITY_FAIL_AND_BAIL; 959 | } 960 | } 961 | 962 | #endif /* not UNITY_EXCLUDE_DOUBLE */ 963 | 964 | /*-----------------------------------------------*/ 965 | void UnityAssertNumbersWithin(const UNITY_UINT delta, 966 | const UNITY_INT expected, 967 | const UNITY_INT actual, 968 | const char* msg, 969 | const UNITY_LINE_TYPE lineNumber, 970 | const UNITY_DISPLAY_STYLE_T style) 971 | { 972 | RETURN_IF_FAIL_OR_IGNORE; 973 | 974 | if ((style & UNITY_DISPLAY_RANGE_INT) == UNITY_DISPLAY_RANGE_INT) 975 | { 976 | if (actual > expected) 977 | Unity.CurrentTestFailed = (UNITY_UINT)((UNITY_UINT)(actual - expected) > delta); 978 | else 979 | Unity.CurrentTestFailed = (UNITY_UINT)((UNITY_UINT)(expected - actual) > delta); 980 | } 981 | else 982 | { 983 | if ((UNITY_UINT)actual > (UNITY_UINT)expected) 984 | Unity.CurrentTestFailed = (UNITY_UINT)((UNITY_UINT)(actual - expected) > delta); 985 | else 986 | Unity.CurrentTestFailed = (UNITY_UINT)((UNITY_UINT)(expected - actual) > delta); 987 | } 988 | 989 | if (Unity.CurrentTestFailed) 990 | { 991 | UnityTestResultsFailBegin(lineNumber); 992 | UnityPrint(UnityStrDelta); 993 | UnityPrintNumberByStyle((UNITY_INT)delta, style); 994 | UnityPrint(UnityStrExpected); 995 | UnityPrintNumberByStyle(expected, style); 996 | UnityPrint(UnityStrWas); 997 | UnityPrintNumberByStyle(actual, style); 998 | UnityAddMsgIfSpecified(msg); 999 | UNITY_FAIL_AND_BAIL; 1000 | } 1001 | } 1002 | 1003 | /*-----------------------------------------------*/ 1004 | void UnityAssertEqualString(const char* expected, 1005 | const char* actual, 1006 | const char* msg, 1007 | const UNITY_LINE_TYPE lineNumber) 1008 | { 1009 | UNITY_UINT32 i; 1010 | 1011 | RETURN_IF_FAIL_OR_IGNORE; 1012 | 1013 | /* if both pointers not null compare the strings */ 1014 | if (expected && actual) 1015 | { 1016 | for (i = 0; expected[i] || actual[i]; i++) 1017 | { 1018 | if (expected[i] != actual[i]) 1019 | { 1020 | Unity.CurrentTestFailed = 1; 1021 | break; 1022 | } 1023 | } 1024 | } 1025 | else 1026 | { /* handle case of one pointers being null (if both null, test should pass) */ 1027 | if (expected != actual) 1028 | { 1029 | Unity.CurrentTestFailed = 1; 1030 | } 1031 | } 1032 | 1033 | if (Unity.CurrentTestFailed) 1034 | { 1035 | UnityTestResultsFailBegin(lineNumber); 1036 | UnityPrintExpectedAndActualStrings(expected, actual); 1037 | UnityAddMsgIfSpecified(msg); 1038 | UNITY_FAIL_AND_BAIL; 1039 | } 1040 | } 1041 | 1042 | /*-----------------------------------------------*/ 1043 | void UnityAssertEqualStringLen(const char* expected, 1044 | const char* actual, 1045 | const UNITY_UINT32 length, 1046 | const char* msg, 1047 | const UNITY_LINE_TYPE lineNumber) 1048 | { 1049 | UNITY_UINT32 i; 1050 | 1051 | RETURN_IF_FAIL_OR_IGNORE; 1052 | 1053 | /* if both pointers not null compare the strings */ 1054 | if (expected && actual) 1055 | { 1056 | for (i = 0; (i < length) && (expected[i] || actual[i]); i++) 1057 | { 1058 | if (expected[i] != actual[i]) 1059 | { 1060 | Unity.CurrentTestFailed = 1; 1061 | break; 1062 | } 1063 | } 1064 | } 1065 | else 1066 | { /* handle case of one pointers being null (if both null, test should pass) */ 1067 | if (expected != actual) 1068 | { 1069 | Unity.CurrentTestFailed = 1; 1070 | } 1071 | } 1072 | 1073 | if (Unity.CurrentTestFailed) 1074 | { 1075 | UnityTestResultsFailBegin(lineNumber); 1076 | UnityPrintExpectedAndActualStringsLen(expected, actual, length); 1077 | UnityAddMsgIfSpecified(msg); 1078 | UNITY_FAIL_AND_BAIL; 1079 | } 1080 | } 1081 | 1082 | /*-----------------------------------------------*/ 1083 | void UnityAssertEqualStringArray(UNITY_INTERNAL_PTR expected, 1084 | const char** actual, 1085 | const UNITY_UINT32 num_elements, 1086 | const char* msg, 1087 | const UNITY_LINE_TYPE lineNumber, 1088 | const UNITY_FLAGS_T flags) 1089 | { 1090 | UNITY_UINT32 i = 0; 1091 | UNITY_UINT32 j = 0; 1092 | const char* expd = NULL; 1093 | const char* act = NULL; 1094 | 1095 | RETURN_IF_FAIL_OR_IGNORE; 1096 | 1097 | /* if no elements, it's an error */ 1098 | if (num_elements == 0) 1099 | { 1100 | UnityPrintPointlessAndBail(); 1101 | } 1102 | 1103 | if ((const void*)expected == (const void*)actual) 1104 | { 1105 | return; /* Both are NULL or same pointer */ 1106 | } 1107 | 1108 | if (UnityIsOneArrayNull((UNITY_INTERNAL_PTR)expected, (UNITY_INTERNAL_PTR)actual, lineNumber, msg)) 1109 | { 1110 | UNITY_FAIL_AND_BAIL; 1111 | } 1112 | 1113 | if (flags != UNITY_ARRAY_TO_ARRAY) 1114 | { 1115 | expd = (const char*)expected; 1116 | } 1117 | 1118 | do 1119 | { 1120 | act = actual[j]; 1121 | if (flags == UNITY_ARRAY_TO_ARRAY) 1122 | { 1123 | expd = ((const char* const*)expected)[j]; 1124 | } 1125 | 1126 | /* if both pointers not null compare the strings */ 1127 | if (expd && act) 1128 | { 1129 | for (i = 0; expd[i] || act[i]; i++) 1130 | { 1131 | if (expd[i] != act[i]) 1132 | { 1133 | Unity.CurrentTestFailed = 1; 1134 | break; 1135 | } 1136 | } 1137 | } 1138 | else 1139 | { /* handle case of one pointers being null (if both null, test should pass) */ 1140 | if (expd != act) 1141 | { 1142 | Unity.CurrentTestFailed = 1; 1143 | } 1144 | } 1145 | 1146 | if (Unity.CurrentTestFailed) 1147 | { 1148 | UnityTestResultsFailBegin(lineNumber); 1149 | if (num_elements > 1) 1150 | { 1151 | UnityPrint(UnityStrElement); 1152 | UnityPrintNumberUnsigned(j); 1153 | } 1154 | UnityPrintExpectedAndActualStrings(expd, act); 1155 | UnityAddMsgIfSpecified(msg); 1156 | UNITY_FAIL_AND_BAIL; 1157 | } 1158 | } while (++j < num_elements); 1159 | } 1160 | 1161 | /*-----------------------------------------------*/ 1162 | void UnityAssertEqualMemory(UNITY_INTERNAL_PTR expected, 1163 | UNITY_INTERNAL_PTR actual, 1164 | const UNITY_UINT32 length, 1165 | const UNITY_UINT32 num_elements, 1166 | const char* msg, 1167 | const UNITY_LINE_TYPE lineNumber, 1168 | const UNITY_FLAGS_T flags) 1169 | { 1170 | UNITY_PTR_ATTRIBUTE const unsigned char* ptr_exp = (UNITY_PTR_ATTRIBUTE const unsigned char*)expected; 1171 | UNITY_PTR_ATTRIBUTE const unsigned char* ptr_act = (UNITY_PTR_ATTRIBUTE const unsigned char*)actual; 1172 | UNITY_UINT32 elements = num_elements; 1173 | UNITY_UINT32 bytes; 1174 | 1175 | RETURN_IF_FAIL_OR_IGNORE; 1176 | 1177 | if ((elements == 0) || (length == 0)) 1178 | { 1179 | UnityPrintPointlessAndBail(); 1180 | } 1181 | 1182 | if (expected == actual) return; /* Both are NULL or same pointer */ 1183 | if (UnityIsOneArrayNull(expected, actual, lineNumber, msg)) 1184 | UNITY_FAIL_AND_BAIL; 1185 | 1186 | while (elements--) 1187 | { 1188 | bytes = length; 1189 | while (bytes--) 1190 | { 1191 | if (*ptr_exp != *ptr_act) 1192 | { 1193 | UnityTestResultsFailBegin(lineNumber); 1194 | UnityPrint(UnityStrMemory); 1195 | if (num_elements > 1) 1196 | { 1197 | UnityPrint(UnityStrElement); 1198 | UnityPrintNumberUnsigned(num_elements - elements - 1); 1199 | } 1200 | UnityPrint(UnityStrByte); 1201 | UnityPrintNumberUnsigned(length - bytes - 1); 1202 | UnityPrint(UnityStrExpected); 1203 | UnityPrintNumberByStyle(*ptr_exp, UNITY_DISPLAY_STYLE_HEX8); 1204 | UnityPrint(UnityStrWas); 1205 | UnityPrintNumberByStyle(*ptr_act, UNITY_DISPLAY_STYLE_HEX8); 1206 | UnityAddMsgIfSpecified(msg); 1207 | UNITY_FAIL_AND_BAIL; 1208 | } 1209 | ptr_exp++; 1210 | ptr_act++; 1211 | } 1212 | if (flags == UNITY_ARRAY_TO_VAL) 1213 | { 1214 | ptr_exp = (UNITY_PTR_ATTRIBUTE const unsigned char*)expected; 1215 | } 1216 | } 1217 | } 1218 | 1219 | /*-----------------------------------------------*/ 1220 | 1221 | static union 1222 | { 1223 | UNITY_INT8 i8; 1224 | UNITY_INT16 i16; 1225 | UNITY_INT32 i32; 1226 | #ifdef UNITY_SUPPORT_64 1227 | UNITY_INT64 i64; 1228 | #endif 1229 | #ifndef UNITY_EXCLUDE_FLOAT 1230 | float f; 1231 | #endif 1232 | #ifndef UNITY_EXCLUDE_DOUBLE 1233 | double d; 1234 | #endif 1235 | } UnityQuickCompare; 1236 | 1237 | UNITY_INTERNAL_PTR UnityNumToPtr(const UNITY_INT num, const UNITY_UINT8 size) 1238 | { 1239 | switch(size) 1240 | { 1241 | case 1: 1242 | UnityQuickCompare.i8 = (UNITY_INT8)num; 1243 | return (UNITY_INTERNAL_PTR)(&UnityQuickCompare.i8); 1244 | 1245 | case 2: 1246 | UnityQuickCompare.i16 = (UNITY_INT16)num; 1247 | return (UNITY_INTERNAL_PTR)(&UnityQuickCompare.i16); 1248 | 1249 | #ifdef UNITY_SUPPORT_64 1250 | case 8: 1251 | UnityQuickCompare.i64 = (UNITY_INT64)num; 1252 | return (UNITY_INTERNAL_PTR)(&UnityQuickCompare.i64); 1253 | #endif 1254 | default: /* 4 bytes */ 1255 | UnityQuickCompare.i32 = (UNITY_INT32)num; 1256 | return (UNITY_INTERNAL_PTR)(&UnityQuickCompare.i32); 1257 | } 1258 | } 1259 | 1260 | #ifndef UNITY_EXCLUDE_FLOAT 1261 | UNITY_INTERNAL_PTR UnityFloatToPtr(const float num) 1262 | { 1263 | UnityQuickCompare.f = num; 1264 | return (UNITY_INTERNAL_PTR)(&UnityQuickCompare.f); 1265 | } 1266 | #endif 1267 | 1268 | #ifndef UNITY_EXCLUDE_DOUBLE 1269 | UNITY_INTERNAL_PTR UnityDoubleToPtr(const double num) 1270 | { 1271 | UnityQuickCompare.d = num; 1272 | return (UNITY_INTERNAL_PTR)(&UnityQuickCompare.d); 1273 | } 1274 | #endif 1275 | 1276 | /*----------------------------------------------- 1277 | * Control Functions 1278 | *-----------------------------------------------*/ 1279 | 1280 | void UnityFail(const char* msg, const UNITY_LINE_TYPE line) 1281 | { 1282 | RETURN_IF_FAIL_OR_IGNORE; 1283 | 1284 | UnityTestResultsBegin(Unity.TestFile, line); 1285 | UnityPrint(UnityStrFail); 1286 | if (msg != NULL) 1287 | { 1288 | UNITY_OUTPUT_CHAR(':'); 1289 | 1290 | #ifndef UNITY_EXCLUDE_DETAILS 1291 | if (Unity.CurrentDetail1) 1292 | { 1293 | UnityPrint(UnityStrDetail1Name); 1294 | UnityPrint(Unity.CurrentDetail1); 1295 | if (Unity.CurrentDetail2) 1296 | { 1297 | UnityPrint(UnityStrDetail2Name); 1298 | UnityPrint(Unity.CurrentDetail2); 1299 | } 1300 | UnityPrint(UnityStrSpacer); 1301 | } 1302 | #endif 1303 | if (msg[0] != ' ') 1304 | { 1305 | UNITY_OUTPUT_CHAR(' '); 1306 | } 1307 | UnityPrint(msg); 1308 | } 1309 | 1310 | UNITY_FAIL_AND_BAIL; 1311 | } 1312 | 1313 | /*-----------------------------------------------*/ 1314 | void UnityIgnore(const char* msg, const UNITY_LINE_TYPE line) 1315 | { 1316 | RETURN_IF_FAIL_OR_IGNORE; 1317 | 1318 | UnityTestResultsBegin(Unity.TestFile, line); 1319 | UnityPrint(UnityStrIgnore); 1320 | if (msg != NULL) 1321 | { 1322 | UNITY_OUTPUT_CHAR(':'); 1323 | UNITY_OUTPUT_CHAR(' '); 1324 | UnityPrint(msg); 1325 | } 1326 | UNITY_IGNORE_AND_BAIL; 1327 | } 1328 | 1329 | /*-----------------------------------------------*/ 1330 | void UnityDefaultTestRun(UnityTestFunction Func, const char* FuncName, const int FuncLineNum) 1331 | { 1332 | Unity.CurrentTestName = FuncName; 1333 | Unity.CurrentTestLineNumber = (UNITY_LINE_TYPE)FuncLineNum; 1334 | Unity.NumberOfTests++; 1335 | UNITY_CLR_DETAILS(); 1336 | if (TEST_PROTECT()) 1337 | { 1338 | setUp(); 1339 | Func(); 1340 | } 1341 | if (TEST_PROTECT()) 1342 | { 1343 | tearDown(); 1344 | } 1345 | UnityConcludeTest(); 1346 | } 1347 | 1348 | /*-----------------------------------------------*/ 1349 | void UnityBegin(const char* filename) 1350 | { 1351 | Unity.TestFile = filename; 1352 | Unity.CurrentTestName = NULL; 1353 | Unity.CurrentTestLineNumber = 0; 1354 | Unity.NumberOfTests = 0; 1355 | Unity.TestFailures = 0; 1356 | Unity.TestIgnores = 0; 1357 | Unity.CurrentTestFailed = 0; 1358 | Unity.CurrentTestIgnored = 0; 1359 | 1360 | UNITY_CLR_DETAILS(); 1361 | UNITY_OUTPUT_START(); 1362 | } 1363 | 1364 | /*-----------------------------------------------*/ 1365 | int UnityEnd(void) 1366 | { 1367 | UNITY_PRINT_EOL(); 1368 | UnityPrint(UnityStrBreaker); 1369 | UNITY_PRINT_EOL(); 1370 | UnityPrintNumber((UNITY_INT)(Unity.NumberOfTests)); 1371 | UnityPrint(UnityStrResultsTests); 1372 | UnityPrintNumber((UNITY_INT)(Unity.TestFailures)); 1373 | UnityPrint(UnityStrResultsFailures); 1374 | UnityPrintNumber((UNITY_INT)(Unity.TestIgnores)); 1375 | UnityPrint(UnityStrResultsIgnored); 1376 | UNITY_PRINT_EOL(); 1377 | if (Unity.TestFailures == 0U) 1378 | { 1379 | UnityPrint(UnityStrOk); 1380 | } 1381 | else 1382 | { 1383 | UnityPrint(UnityStrFail); 1384 | #ifdef UNITY_DIFFERENTIATE_FINAL_FAIL 1385 | UNITY_OUTPUT_CHAR('E'); UNITY_OUTPUT_CHAR('D'); 1386 | #endif 1387 | } 1388 | UNITY_PRINT_EOL(); 1389 | UNITY_FLUSH_CALL(); 1390 | UNITY_OUTPUT_COMPLETE(); 1391 | return (int)(Unity.TestFailures); 1392 | } 1393 | 1394 | /*----------------------------------------------- 1395 | * Command Line Argument Support 1396 | *-----------------------------------------------*/ 1397 | #ifdef UNITY_USE_COMMAND_LINE_ARGS 1398 | 1399 | char* UnityOptionIncludeNamed = NULL; 1400 | char* UnityOptionExcludeNamed = NULL; 1401 | int UnityVerbosity = 1; 1402 | 1403 | int UnityParseOptions(int argc, char** argv) 1404 | { 1405 | UnityOptionIncludeNamed = NULL; 1406 | UnityOptionExcludeNamed = NULL; 1407 | 1408 | for (int i = 1; i < argc; i++) 1409 | { 1410 | if (argv[i][0] == '-') 1411 | { 1412 | switch (argv[i][1]) 1413 | { 1414 | case 'l': /* list tests */ 1415 | return -1; 1416 | case 'n': /* include tests with name including this string */ 1417 | case 'f': /* an alias for -n */ 1418 | if (argv[i][2] == '=') 1419 | UnityOptionIncludeNamed = &argv[i][3]; 1420 | else if (++i < argc) 1421 | UnityOptionIncludeNamed = argv[i]; 1422 | else 1423 | { 1424 | UnityPrint("ERROR: No Test String to Include Matches For"); 1425 | UNITY_PRINT_EOL(); 1426 | return 1; 1427 | } 1428 | break; 1429 | case 'q': /* quiet */ 1430 | UnityVerbosity = 0; 1431 | break; 1432 | case 'v': /* verbose */ 1433 | UnityVerbosity = 2; 1434 | break; 1435 | case 'x': /* exclude tests with name including this string */ 1436 | if (argv[i][2] == '=') 1437 | UnityOptionExcludeNamed = &argv[i][3]; 1438 | else if (++i < argc) 1439 | UnityOptionExcludeNamed = argv[i]; 1440 | else 1441 | { 1442 | UnityPrint("ERROR: No Test String to Exclude Matches For"); 1443 | UNITY_PRINT_EOL(); 1444 | return 1; 1445 | } 1446 | break; 1447 | default: 1448 | UnityPrint("ERROR: Unknown Option "); 1449 | UNITY_OUTPUT_CHAR(argv[i][1]); 1450 | UNITY_PRINT_EOL(); 1451 | return 1; 1452 | } 1453 | } 1454 | } 1455 | 1456 | return 0; 1457 | } 1458 | 1459 | int IsStringInBiggerString(const char* longstring, const char* shortstring) 1460 | { 1461 | const char* lptr = longstring; 1462 | const char* sptr = shortstring; 1463 | const char* lnext = lptr; 1464 | 1465 | if (*sptr == '*') 1466 | return 1; 1467 | 1468 | while (*lptr) 1469 | { 1470 | lnext = lptr + 1; 1471 | 1472 | /* If they current bytes match, go on to the next bytes */ 1473 | while (*lptr && *sptr && (*lptr == *sptr)) 1474 | { 1475 | lptr++; 1476 | sptr++; 1477 | 1478 | /* We're done if we match the entire string or up to a wildcard */ 1479 | if (*sptr == '*') 1480 | return 1; 1481 | if (*sptr == ',') 1482 | return 1; 1483 | if (*sptr == '"') 1484 | return 1; 1485 | if (*sptr == '\'') 1486 | return 1; 1487 | if (*sptr == ':') 1488 | return 2; 1489 | if (*sptr == 0) 1490 | return 1; 1491 | } 1492 | 1493 | /* Otherwise we start in the long pointer 1 character further and try again */ 1494 | lptr = lnext; 1495 | sptr = shortstring; 1496 | } 1497 | return 0; 1498 | } 1499 | 1500 | int UnityStringArgumentMatches(const char* str) 1501 | { 1502 | int retval; 1503 | const char* ptr1; 1504 | const char* ptr2; 1505 | const char* ptrf; 1506 | 1507 | /* Go through the options and get the substrings for matching one at a time */ 1508 | ptr1 = str; 1509 | while (ptr1[0] != 0) 1510 | { 1511 | if ((ptr1[0] == '"') || (ptr1[0] == '\'')) 1512 | ptr1++; 1513 | 1514 | /* look for the start of the next partial */ 1515 | ptr2 = ptr1; 1516 | ptrf = 0; 1517 | do 1518 | { 1519 | ptr2++; 1520 | if ((ptr2[0] == ':') && (ptr2[1] != 0) && (ptr2[0] != '\'') && (ptr2[0] != '"') && (ptr2[0] != ',')) 1521 | ptrf = &ptr2[1]; 1522 | } while ((ptr2[0] != 0) && (ptr2[0] != '\'') && (ptr2[0] != '"') && (ptr2[0] != ',')); 1523 | while ((ptr2[0] != 0) && ((ptr2[0] == ':') || (ptr2[0] == '\'') || (ptr2[0] == '"') || (ptr2[0] == ','))) 1524 | ptr2++; 1525 | 1526 | /* done if complete filename match */ 1527 | retval = IsStringInBiggerString(Unity.TestFile, ptr1); 1528 | if (retval == 1) 1529 | return retval; 1530 | 1531 | /* done if testname match after filename partial match */ 1532 | if ((retval == 2) && (ptrf != 0)) 1533 | { 1534 | if (IsStringInBiggerString(Unity.CurrentTestName, ptrf)) 1535 | return 1; 1536 | } 1537 | 1538 | /* done if complete testname match */ 1539 | if (IsStringInBiggerString(Unity.CurrentTestName, ptr1) == 1) 1540 | return 1; 1541 | 1542 | ptr1 = ptr2; 1543 | } 1544 | 1545 | /* we couldn't find a match for any substrings */ 1546 | return 0; 1547 | } 1548 | 1549 | int UnityTestMatches(void) 1550 | { 1551 | /* Check if this test name matches the included test pattern */ 1552 | int retval; 1553 | if (UnityOptionIncludeNamed) 1554 | { 1555 | retval = UnityStringArgumentMatches(UnityOptionIncludeNamed); 1556 | } 1557 | else 1558 | retval = 1; 1559 | 1560 | /* Check if this test name matches the excluded test pattern */ 1561 | if (UnityOptionExcludeNamed) 1562 | { 1563 | if (UnityStringArgumentMatches(UnityOptionExcludeNamed)) 1564 | retval = 0; 1565 | } 1566 | return retval; 1567 | } 1568 | 1569 | #endif /* UNITY_USE_COMMAND_LINE_ARGS */ 1570 | /*-----------------------------------------------*/ 1571 | -------------------------------------------------------------------------------- /test/unity/unity.h: -------------------------------------------------------------------------------- 1 | /* ========================================== 2 | Unity Project - A Test Framework for C 3 | Copyright (c) 2007-14 Mike Karlesky, Mark VanderVoord, Greg Williams 4 | [Released under MIT License. Please refer to license.txt for details] 5 | ========================================== */ 6 | 7 | #ifndef UNITY_FRAMEWORK_H 8 | #define UNITY_FRAMEWORK_H 9 | #define UNITY 10 | 11 | #ifdef __cplusplus 12 | extern "C" 13 | { 14 | #endif 15 | 16 | #include "unity_internals.h" 17 | 18 | /*------------------------------------------------------- 19 | * Test Setup / Teardown 20 | *-------------------------------------------------------*/ 21 | 22 | /* These functions are intended to be called before and after each test. */ 23 | void setUp(void); 24 | void tearDown(void); 25 | 26 | /* These functions are intended to be called at the beginning and end of an 27 | * entire test suite. suiteTearDown() is passed the number of tests that 28 | * failed, and its return value becomes the exit code of main(). */ 29 | void suiteSetUp(void); 30 | int suiteTearDown(int num_failures); 31 | 32 | /* If the compiler supports it, the following block provides stub 33 | * implementations of the above functions as weak symbols. Note that on 34 | * some platforms (MinGW for example), weak function implementations need 35 | * to be in the same translation unit they are called from. This can be 36 | * achieved by defining UNITY_INCLUDE_SETUP_STUBS before including unity.h. */ 37 | #ifdef UNITY_INCLUDE_SETUP_STUBS 38 | #ifdef UNITY_WEAK_ATTRIBUTE 39 | UNITY_WEAK_ATTRIBUTE void setUp(void) { } 40 | UNITY_WEAK_ATTRIBUTE void tearDown(void) { } 41 | UNITY_WEAK_ATTRIBUTE void suiteSetUp(void) { } 42 | UNITY_WEAK_ATTRIBUTE int suiteTearDown(int num_failures) { return num_failures; } 43 | #elif defined(UNITY_WEAK_PRAGMA) 44 | #pragma weak setUp 45 | void setUp(void) { } 46 | #pragma weak tearDown 47 | void tearDown(void) { } 48 | #pragma weak suiteSetUp 49 | void suiteSetUp(void) { } 50 | #pragma weak suiteTearDown 51 | int suiteTearDown(int num_failures) { return num_failures; } 52 | #endif 53 | #endif 54 | 55 | /*------------------------------------------------------- 56 | * Configuration Options 57 | *------------------------------------------------------- 58 | * All options described below should be passed as a compiler flag to all files using Unity. If you must add #defines, place them BEFORE the #include above. 59 | 60 | * Integers/longs/pointers 61 | * - Unity attempts to automatically discover your integer sizes 62 | * - define UNITY_EXCLUDE_STDINT_H to stop attempting to look in 63 | * - define UNITY_EXCLUDE_LIMITS_H to stop attempting to look in 64 | * - If you cannot use the automatic methods above, you can force Unity by using these options: 65 | * - define UNITY_SUPPORT_64 66 | * - set UNITY_INT_WIDTH 67 | * - set UNITY_LONG_WIDTH 68 | * - set UNITY_POINTER_WIDTH 69 | 70 | * Floats 71 | * - define UNITY_EXCLUDE_FLOAT to disallow floating point comparisons 72 | * - define UNITY_FLOAT_PRECISION to specify the precision to use when doing TEST_ASSERT_EQUAL_FLOAT 73 | * - define UNITY_FLOAT_TYPE to specify doubles instead of single precision floats 74 | * - define UNITY_INCLUDE_DOUBLE to allow double floating point comparisons 75 | * - define UNITY_EXCLUDE_DOUBLE to disallow double floating point comparisons (default) 76 | * - define UNITY_DOUBLE_PRECISION to specify the precision to use when doing TEST_ASSERT_EQUAL_DOUBLE 77 | * - define UNITY_DOUBLE_TYPE to specify something other than double 78 | * - define UNITY_EXCLUDE_FLOAT_PRINT to trim binary size, won't print floating point values in errors 79 | 80 | * Output 81 | * - by default, Unity prints to standard out with putchar. define UNITY_OUTPUT_CHAR(a) with a different function if desired 82 | * - define UNITY_DIFFERENTIATE_FINAL_FAIL to print FAILED (vs. FAIL) at test end summary - for automated search for failure 83 | 84 | * Optimization 85 | * - by default, line numbers are stored in unsigned shorts. Define UNITY_LINE_TYPE with a different type if your files are huge 86 | * - by default, test and failure counters are unsigned shorts. Define UNITY_COUNTER_TYPE with a different type if you want to save space or have more than 65535 Tests. 87 | 88 | * Test Cases 89 | * - define UNITY_SUPPORT_TEST_CASES to include the TEST_CASE macro, though really it's mostly about the runner generator script 90 | 91 | * Parameterized Tests 92 | * - you'll want to create a define of TEST_CASE(...) which basically evaluates to nothing 93 | 94 | * Tests with Arguments 95 | * - you'll want to define UNITY_USE_COMMAND_LINE_ARGS if you have the test runner passing arguments to Unity 96 | 97 | *------------------------------------------------------- 98 | * Basic Fail and Ignore 99 | *-------------------------------------------------------*/ 100 | 101 | #define TEST_FAIL_MESSAGE(message) UNITY_TEST_FAIL(__LINE__, (message)) 102 | #define TEST_FAIL() UNITY_TEST_FAIL(__LINE__, NULL) 103 | #define TEST_IGNORE_MESSAGE(message) UNITY_TEST_IGNORE(__LINE__, (message)) 104 | #define TEST_IGNORE() UNITY_TEST_IGNORE(__LINE__, NULL) 105 | #define TEST_ONLY() 106 | 107 | /* It is not necessary for you to call PASS. A PASS condition is assumed if nothing fails. 108 | * This method allows you to abort a test immediately with a PASS state, ignoring the remainder of the test. */ 109 | #define TEST_PASS() TEST_ABORT() 110 | 111 | /* This macro does nothing, but it is useful for build tools (like Ceedling) to make use of this to figure out 112 | * which files should be linked to in order to perform a test. Use it like TEST_FILE("sandwiches.c") */ 113 | #define TEST_FILE(a) 114 | 115 | /*------------------------------------------------------- 116 | * Test Asserts (simple) 117 | *-------------------------------------------------------*/ 118 | 119 | /* Boolean */ 120 | #define TEST_ASSERT(condition) UNITY_TEST_ASSERT( (condition), __LINE__, " Expression Evaluated To FALSE") 121 | #define TEST_ASSERT_TRUE(condition) UNITY_TEST_ASSERT( (condition), __LINE__, " Expected TRUE Was FALSE") 122 | #define TEST_ASSERT_UNLESS(condition) UNITY_TEST_ASSERT( !(condition), __LINE__, " Expression Evaluated To TRUE") 123 | #define TEST_ASSERT_FALSE(condition) UNITY_TEST_ASSERT( !(condition), __LINE__, " Expected FALSE Was TRUE") 124 | #define TEST_ASSERT_NULL(pointer) UNITY_TEST_ASSERT_NULL( (pointer), __LINE__, " Expected NULL") 125 | #define TEST_ASSERT_NOT_NULL(pointer) UNITY_TEST_ASSERT_NOT_NULL((pointer), __LINE__, " Expected Non-NULL") 126 | 127 | /* Integers (of all sizes) */ 128 | #define TEST_ASSERT_EQUAL_INT(expected, actual) UNITY_TEST_ASSERT_EQUAL_INT((expected), (actual), __LINE__, NULL) 129 | #define TEST_ASSERT_EQUAL_INT8(expected, actual) UNITY_TEST_ASSERT_EQUAL_INT8((expected), (actual), __LINE__, NULL) 130 | #define TEST_ASSERT_EQUAL_INT16(expected, actual) UNITY_TEST_ASSERT_EQUAL_INT16((expected), (actual), __LINE__, NULL) 131 | #define TEST_ASSERT_EQUAL_INT32(expected, actual) UNITY_TEST_ASSERT_EQUAL_INT32((expected), (actual), __LINE__, NULL) 132 | #define TEST_ASSERT_EQUAL_INT64(expected, actual) UNITY_TEST_ASSERT_EQUAL_INT64((expected), (actual), __LINE__, NULL) 133 | #define TEST_ASSERT_EQUAL(expected, actual) UNITY_TEST_ASSERT_EQUAL_INT((expected), (actual), __LINE__, NULL) 134 | #define TEST_ASSERT_NOT_EQUAL(expected, actual) UNITY_TEST_ASSERT(((expected) != (actual)), __LINE__, " Expected Not-Equal") 135 | #define TEST_ASSERT_EQUAL_UINT(expected, actual) UNITY_TEST_ASSERT_EQUAL_UINT( (expected), (actual), __LINE__, NULL) 136 | #define TEST_ASSERT_EQUAL_UINT8(expected, actual) UNITY_TEST_ASSERT_EQUAL_UINT8( (expected), (actual), __LINE__, NULL) 137 | #define TEST_ASSERT_EQUAL_UINT16(expected, actual) UNITY_TEST_ASSERT_EQUAL_UINT16( (expected), (actual), __LINE__, NULL) 138 | #define TEST_ASSERT_EQUAL_UINT32(expected, actual) UNITY_TEST_ASSERT_EQUAL_UINT32( (expected), (actual), __LINE__, NULL) 139 | #define TEST_ASSERT_EQUAL_UINT64(expected, actual) UNITY_TEST_ASSERT_EQUAL_UINT64( (expected), (actual), __LINE__, NULL) 140 | #define TEST_ASSERT_EQUAL_HEX(expected, actual) UNITY_TEST_ASSERT_EQUAL_HEX32((expected), (actual), __LINE__, NULL) 141 | #define TEST_ASSERT_EQUAL_HEX8(expected, actual) UNITY_TEST_ASSERT_EQUAL_HEX8( (expected), (actual), __LINE__, NULL) 142 | #define TEST_ASSERT_EQUAL_HEX16(expected, actual) UNITY_TEST_ASSERT_EQUAL_HEX16((expected), (actual), __LINE__, NULL) 143 | #define TEST_ASSERT_EQUAL_HEX32(expected, actual) UNITY_TEST_ASSERT_EQUAL_HEX32((expected), (actual), __LINE__, NULL) 144 | #define TEST_ASSERT_EQUAL_HEX64(expected, actual) UNITY_TEST_ASSERT_EQUAL_HEX64((expected), (actual), __LINE__, NULL) 145 | #define TEST_ASSERT_BITS(mask, expected, actual) UNITY_TEST_ASSERT_BITS((mask), (expected), (actual), __LINE__, NULL) 146 | #define TEST_ASSERT_BITS_HIGH(mask, actual) UNITY_TEST_ASSERT_BITS((mask), (UNITY_UINT32)(-1), (actual), __LINE__, NULL) 147 | #define TEST_ASSERT_BITS_LOW(mask, actual) UNITY_TEST_ASSERT_BITS((mask), (UNITY_UINT32)(0), (actual), __LINE__, NULL) 148 | #define TEST_ASSERT_BIT_HIGH(bit, actual) UNITY_TEST_ASSERT_BITS(((UNITY_UINT32)1 << (bit)), (UNITY_UINT32)(-1), (actual), __LINE__, NULL) 149 | #define TEST_ASSERT_BIT_LOW(bit, actual) UNITY_TEST_ASSERT_BITS(((UNITY_UINT32)1 << (bit)), (UNITY_UINT32)(0), (actual), __LINE__, NULL) 150 | 151 | /* Integer Greater Than/ Less Than (of all sizes) */ 152 | #define TEST_ASSERT_GREATER_THAN(threshold, actual) UNITY_TEST_ASSERT_GREATER_THAN_INT((threshold), (actual), __LINE__, NULL) 153 | #define TEST_ASSERT_GREATER_THAN_INT(threshold, actual) UNITY_TEST_ASSERT_GREATER_THAN_INT((threshold), (actual), __LINE__, NULL) 154 | #define TEST_ASSERT_GREATER_THAN_INT8(threshold, actual) UNITY_TEST_ASSERT_GREATER_THAN_INT8((threshold), (actual), __LINE__, NULL) 155 | #define TEST_ASSERT_GREATER_THAN_INT16(threshold, actual) UNITY_TEST_ASSERT_GREATER_THAN_INT16((threshold), (actual), __LINE__, NULL) 156 | #define TEST_ASSERT_GREATER_THAN_INT32(threshold, actual) UNITY_TEST_ASSERT_GREATER_THAN_INT32((threshold), (actual), __LINE__, NULL) 157 | #define TEST_ASSERT_GREATER_THAN_INT64(threshold, actual) UNITY_TEST_ASSERT_GREATER_THAN_INT64((threshold), (actual), __LINE__, NULL) 158 | #define TEST_ASSERT_GREATER_THAN_UINT(threshold, actual) UNITY_TEST_ASSERT_GREATER_THAN_UINT((threshold), (actual), __LINE__, NULL) 159 | #define TEST_ASSERT_GREATER_THAN_UINT8(threshold, actual) UNITY_TEST_ASSERT_GREATER_THAN_UINT8((threshold), (actual), __LINE__, NULL) 160 | #define TEST_ASSERT_GREATER_THAN_UINT16(threshold, actual) UNITY_TEST_ASSERT_GREATER_THAN_UINT16((threshold), (actual), __LINE__, NULL) 161 | #define TEST_ASSERT_GREATER_THAN_UINT32(threshold, actual) UNITY_TEST_ASSERT_GREATER_THAN_UINT32((threshold), (actual), __LINE__, NULL) 162 | #define TEST_ASSERT_GREATER_THAN_UINT64(threshold, actual) UNITY_TEST_ASSERT_GREATER_THAN_UINT64((threshold), (actual), __LINE__, NULL) 163 | #define TEST_ASSERT_GREATER_THAN_HEX8(threshold, actual) UNITY_TEST_ASSERT_GREATER_THAN_HEX8((threshold), (actual), __LINE__, NULL) 164 | #define TEST_ASSERT_GREATER_THAN_HEX16(threshold, actual) UNITY_TEST_ASSERT_GREATER_THAN_HEX16((threshold), (actual), __LINE__, NULL) 165 | #define TEST_ASSERT_GREATER_THAN_HEX32(threshold, actual) UNITY_TEST_ASSERT_GREATER_THAN_HEX32((threshold), (actual), __LINE__, NULL) 166 | #define TEST_ASSERT_GREATER_THAN_HEX64(threshold, actual) UNITY_TEST_ASSERT_GREATER_THAN_HEX64((threshold), (actual), __LINE__, NULL) 167 | 168 | #define TEST_ASSERT_LESS_THAN(threshold, actual) UNITY_TEST_ASSERT_SMALLER_THAN_INT((threshold), (actual), __LINE__, NULL) 169 | #define TEST_ASSERT_LESS_THAN_INT(threshold, actual) UNITY_TEST_ASSERT_SMALLER_THAN_INT((threshold), (actual), __LINE__, NULL) 170 | #define TEST_ASSERT_LESS_THAN_INT8(threshold, actual) UNITY_TEST_ASSERT_SMALLER_THAN_INT8((threshold), (actual), __LINE__, NULL) 171 | #define TEST_ASSERT_LESS_THAN_INT16(threshold, actual) UNITY_TEST_ASSERT_SMALLER_THAN_INT16((threshold), (actual), __LINE__, NULL) 172 | #define TEST_ASSERT_LESS_THAN_INT32(threshold, actual) UNITY_TEST_ASSERT_SMALLER_THAN_INT32((threshold), (actual), __LINE__, NULL) 173 | #define TEST_ASSERT_LESS_THAN_INT64(threshold, actual) UNITY_TEST_ASSERT_SMALLER_THAN_INT64((threshold), (actual), __LINE__, NULL) 174 | #define TEST_ASSERT_LESS_THAN_UINT(threshold, actual) UNITY_TEST_ASSERT_SMALLER_THAN_UINT((threshold), (actual), __LINE__, NULL) 175 | #define TEST_ASSERT_LESS_THAN_UINT8(threshold, actual) UNITY_TEST_ASSERT_SMALLER_THAN_UINT8((threshold), (actual), __LINE__, NULL) 176 | #define TEST_ASSERT_LESS_THAN_UINT16(threshold, actual) UNITY_TEST_ASSERT_SMALLER_THAN_UINT16((threshold), (actual), __LINE__, NULL) 177 | #define TEST_ASSERT_LESS_THAN_UINT32(threshold, actual) UNITY_TEST_ASSERT_SMALLER_THAN_UINT32((threshold), (actual), __LINE__, NULL) 178 | #define TEST_ASSERT_LESS_THAN_UINT64(threshold, actual) UNITY_TEST_ASSERT_SMALLER_THAN_UINT64((threshold), (actual), __LINE__, NULL) 179 | #define TEST_ASSERT_LESS_THAN_HEX8(threshold, actual) UNITY_TEST_ASSERT_SMALLER_THAN_HEX8((threshold), (actual), __LINE__, NULL) 180 | #define TEST_ASSERT_LESS_THAN_HEX16(threshold, actual) UNITY_TEST_ASSERT_SMALLER_THAN_HEX16((threshold), (actual), __LINE__, NULL) 181 | #define TEST_ASSERT_LESS_THAN_HEX32(threshold, actual) UNITY_TEST_ASSERT_SMALLER_THAN_HEX32((threshold), (actual), __LINE__, NULL) 182 | #define TEST_ASSERT_LESS_THAN_HEX64(threshold, actual) UNITY_TEST_ASSERT_SMALLER_THAN_HEX64((threshold), (actual), __LINE__, NULL) 183 | 184 | #define TEST_ASSERT_GREATER_OR_EQUAL(threshold, actual) UNITY_TEST_ASSERT_GREATER_OR_EQUAL_INT((threshold), (actual), __LINE__, NULL) 185 | #define TEST_ASSERT_GREATER_OR_EQUAL_INT(threshold, actual) UNITY_TEST_ASSERT_GREATER_OR_EQUAL_INT((threshold), (actual), __LINE__, NULL) 186 | #define TEST_ASSERT_GREATER_OR_EQUAL_INT8(threshold, actual) UNITY_TEST_ASSERT_GREATER_OR_EQUAL_INT8((threshold), (actual), __LINE__, NULL) 187 | #define TEST_ASSERT_GREATER_OR_EQUAL_INT16(threshold, actual) UNITY_TEST_ASSERT_GREATER_OR_EQUAL_INT16((threshold), (actual), __LINE__, NULL) 188 | #define TEST_ASSERT_GREATER_OR_EQUAL_INT32(threshold, actual) UNITY_TEST_ASSERT_GREATER_OR_EQUAL_INT32((threshold), (actual), __LINE__, NULL) 189 | #define TEST_ASSERT_GREATER_OR_EQUAL_INT64(threshold, actual) UNITY_TEST_ASSERT_GREATER_OR_EQUAL_INT64((threshold), (actual), __LINE__, NULL) 190 | #define TEST_ASSERT_GREATER_OR_EQUAL_UINT(threshold, actual) UNITY_TEST_ASSERT_GREATER_OR_EQUAL_UINT((threshold), (actual), __LINE__, NULL) 191 | #define TEST_ASSERT_GREATER_OR_EQUAL_UINT8(threshold, actual) UNITY_TEST_ASSERT_GREATER_OR_EQUAL_UINT8((threshold), (actual), __LINE__, NULL) 192 | #define TEST_ASSERT_GREATER_OR_EQUAL_UINT16(threshold, actual) UNITY_TEST_ASSERT_GREATER_OR_EQUAL_UINT16((threshold), (actual), __LINE__, NULL) 193 | #define TEST_ASSERT_GREATER_OR_EQUAL_UINT32(threshold, actual) UNITY_TEST_ASSERT_GREATER_OR_EQUAL_UINT32((threshold), (actual), __LINE__, NULL) 194 | #define TEST_ASSERT_GREATER_OR_EQUAL_UINT64(threshold, actual) UNITY_TEST_ASSERT_GREATER_OR_EQUAL_UINT64((threshold), (actual), __LINE__, NULL) 195 | #define TEST_ASSERT_GREATER_OR_EQUAL_HEX8(threshold, actual) UNITY_TEST_ASSERT_GREATER_OR_EQUAL_HEX8((threshold), (actual), __LINE__, NULL) 196 | #define TEST_ASSERT_GREATER_OR_EQUAL_HEX16(threshold, actual) UNITY_TEST_ASSERT_GREATER_OR_EQUAL_HEX16((threshold), (actual), __LINE__, NULL) 197 | #define TEST_ASSERT_GREATER_OR_EQUAL_HEX32(threshold, actual) UNITY_TEST_ASSERT_GREATER_OR_EQUAL_HEX32((threshold), (actual), __LINE__, NULL) 198 | #define TEST_ASSERT_GREATER_OR_EQUAL_HEX64(threshold, actual) UNITY_TEST_ASSERT_GREATER_OR_EQUAL_HEX64((threshold), (actual), __LINE__, NULL) 199 | 200 | #define TEST_ASSERT_LESS_OR_EQUAL(threshold, actual) UNITY_TEST_ASSERT_SMALLER_OR_EQUAL_INT((threshold), (actual), __LINE__, NULL) 201 | #define TEST_ASSERT_LESS_OR_EQUAL_INT(threshold, actual) UNITY_TEST_ASSERT_SMALLER_OR_EQUAL_INT((threshold), (actual), __LINE__, NULL) 202 | #define TEST_ASSERT_LESS_OR_EQUAL_INT8(threshold, actual) UNITY_TEST_ASSERT_SMALLER_OR_EQUAL_INT8((threshold), (actual), __LINE__, NULL) 203 | #define TEST_ASSERT_LESS_OR_EQUAL_INT16(threshold, actual) UNITY_TEST_ASSERT_SMALLER_OR_EQUAL_INT16((threshold), (actual), __LINE__, NULL) 204 | #define TEST_ASSERT_LESS_OR_EQUAL_INT32(threshold, actual) UNITY_TEST_ASSERT_SMALLER_OR_EQUAL_INT32((threshold), (actual), __LINE__, NULL) 205 | #define TEST_ASSERT_LESS_OR_EQUAL_INT64(threshold, actual) UNITY_TEST_ASSERT_SMALLER_OR_EQUAL_INT64((threshold), (actual), __LINE__, NULL) 206 | #define TEST_ASSERT_LESS_OR_EQUAL_UINT(threshold, actual) UNITY_TEST_ASSERT_SMALLER_OR_EQUAL_UINT((threshold), (actual), __LINE__, NULL) 207 | #define TEST_ASSERT_LESS_OR_EQUAL_UINT8(threshold, actual) UNITY_TEST_ASSERT_SMALLER_OR_EQUAL_UINT8((threshold), (actual), __LINE__, NULL) 208 | #define TEST_ASSERT_LESS_OR_EQUAL_UINT16(threshold, actual) UNITY_TEST_ASSERT_SMALLER_OR_EQUAL_UINT16((threshold), (actual), __LINE__, NULL) 209 | #define TEST_ASSERT_LESS_OR_EQUAL_UINT32(threshold, actual) UNITY_TEST_ASSERT_SMALLER_OR_EQUAL_UINT32((threshold), (actual), __LINE__, NULL) 210 | #define TEST_ASSERT_LESS_OR_EQUAL_UINT64(threshold, actual) UNITY_TEST_ASSERT_SMALLER_OR_EQUAL_UINT64((threshold), (actual), __LINE__, NULL) 211 | #define TEST_ASSERT_LESS_OR_EQUAL_HEX8(threshold, actual) UNITY_TEST_ASSERT_SMALLER_OR_EQUAL_HEX8((threshold), (actual), __LINE__, NULL) 212 | #define TEST_ASSERT_LESS_OR_EQUAL_HEX16(threshold, actual) UNITY_TEST_ASSERT_SMALLER_OR_EQUAL_HEX16((threshold), (actual), __LINE__, NULL) 213 | #define TEST_ASSERT_LESS_OR_EQUAL_HEX32(threshold, actual) UNITY_TEST_ASSERT_SMALLER_OR_EQUAL_HEX32((threshold), (actual), __LINE__, NULL) 214 | #define TEST_ASSERT_LESS_OR_EQUAL_HEX64(threshold, actual) UNITY_TEST_ASSERT_SMALLER_OR_EQUAL_HEX64((threshold), (actual), __LINE__, NULL) 215 | 216 | /* Integer Ranges (of all sizes) */ 217 | #define TEST_ASSERT_INT_WITHIN(delta, expected, actual) UNITY_TEST_ASSERT_INT_WITHIN((delta), (expected), (actual), __LINE__, NULL) 218 | #define TEST_ASSERT_INT8_WITHIN(delta, expected, actual) UNITY_TEST_ASSERT_INT8_WITHIN((delta), (expected), (actual), __LINE__, NULL) 219 | #define TEST_ASSERT_INT16_WITHIN(delta, expected, actual) UNITY_TEST_ASSERT_INT16_WITHIN((delta), (expected), (actual), __LINE__, NULL) 220 | #define TEST_ASSERT_INT32_WITHIN(delta, expected, actual) UNITY_TEST_ASSERT_INT32_WITHIN((delta), (expected), (actual), __LINE__, NULL) 221 | #define TEST_ASSERT_INT64_WITHIN(delta, expected, actual) UNITY_TEST_ASSERT_INT64_WITHIN((delta), (expected), (actual), __LINE__, NULL) 222 | #define TEST_ASSERT_UINT_WITHIN(delta, expected, actual) UNITY_TEST_ASSERT_UINT_WITHIN((delta), (expected), (actual), __LINE__, NULL) 223 | #define TEST_ASSERT_UINT8_WITHIN(delta, expected, actual) UNITY_TEST_ASSERT_UINT8_WITHIN((delta), (expected), (actual), __LINE__, NULL) 224 | #define TEST_ASSERT_UINT16_WITHIN(delta, expected, actual) UNITY_TEST_ASSERT_UINT16_WITHIN((delta), (expected), (actual), __LINE__, NULL) 225 | #define TEST_ASSERT_UINT32_WITHIN(delta, expected, actual) UNITY_TEST_ASSERT_UINT32_WITHIN((delta), (expected), (actual), __LINE__, NULL) 226 | #define TEST_ASSERT_UINT64_WITHIN(delta, expected, actual) UNITY_TEST_ASSERT_UINT64_WITHIN((delta), (expected), (actual), __LINE__, NULL) 227 | #define TEST_ASSERT_HEX_WITHIN(delta, expected, actual) UNITY_TEST_ASSERT_HEX32_WITHIN((delta), (expected), (actual), __LINE__, NULL) 228 | #define TEST_ASSERT_HEX8_WITHIN(delta, expected, actual) UNITY_TEST_ASSERT_HEX8_WITHIN((delta), (expected), (actual), __LINE__, NULL) 229 | #define TEST_ASSERT_HEX16_WITHIN(delta, expected, actual) UNITY_TEST_ASSERT_HEX16_WITHIN((delta), (expected), (actual), __LINE__, NULL) 230 | #define TEST_ASSERT_HEX32_WITHIN(delta, expected, actual) UNITY_TEST_ASSERT_HEX32_WITHIN((delta), (expected), (actual), __LINE__, NULL) 231 | #define TEST_ASSERT_HEX64_WITHIN(delta, expected, actual) UNITY_TEST_ASSERT_HEX64_WITHIN((delta), (expected), (actual), __LINE__, NULL) 232 | 233 | /* Structs and Strings */ 234 | #define TEST_ASSERT_EQUAL_PTR(expected, actual) UNITY_TEST_ASSERT_EQUAL_PTR((expected), (actual), __LINE__, NULL) 235 | #define TEST_ASSERT_EQUAL_STRING(expected, actual) UNITY_TEST_ASSERT_EQUAL_STRING((expected), (actual), __LINE__, NULL) 236 | #define TEST_ASSERT_EQUAL_STRING_LEN(expected, actual, len) UNITY_TEST_ASSERT_EQUAL_STRING_LEN((expected), (actual), (len), __LINE__, NULL) 237 | #define TEST_ASSERT_EQUAL_MEMORY(expected, actual, len) UNITY_TEST_ASSERT_EQUAL_MEMORY((expected), (actual), (len), __LINE__, NULL) 238 | 239 | /* Arrays */ 240 | #define TEST_ASSERT_EQUAL_INT_ARRAY(expected, actual, num_elements) UNITY_TEST_ASSERT_EQUAL_INT_ARRAY((expected), (actual), (num_elements), __LINE__, NULL) 241 | #define TEST_ASSERT_EQUAL_INT8_ARRAY(expected, actual, num_elements) UNITY_TEST_ASSERT_EQUAL_INT8_ARRAY((expected), (actual), (num_elements), __LINE__, NULL) 242 | #define TEST_ASSERT_EQUAL_INT16_ARRAY(expected, actual, num_elements) UNITY_TEST_ASSERT_EQUAL_INT16_ARRAY((expected), (actual), (num_elements), __LINE__, NULL) 243 | #define TEST_ASSERT_EQUAL_INT32_ARRAY(expected, actual, num_elements) UNITY_TEST_ASSERT_EQUAL_INT32_ARRAY((expected), (actual), (num_elements), __LINE__, NULL) 244 | #define TEST_ASSERT_EQUAL_INT64_ARRAY(expected, actual, num_elements) UNITY_TEST_ASSERT_EQUAL_INT64_ARRAY((expected), (actual), (num_elements), __LINE__, NULL) 245 | #define TEST_ASSERT_EQUAL_UINT_ARRAY(expected, actual, num_elements) UNITY_TEST_ASSERT_EQUAL_UINT_ARRAY((expected), (actual), (num_elements), __LINE__, NULL) 246 | #define TEST_ASSERT_EQUAL_UINT8_ARRAY(expected, actual, num_elements) UNITY_TEST_ASSERT_EQUAL_UINT8_ARRAY((expected), (actual), (num_elements), __LINE__, NULL) 247 | #define TEST_ASSERT_EQUAL_UINT16_ARRAY(expected, actual, num_elements) UNITY_TEST_ASSERT_EQUAL_UINT16_ARRAY((expected), (actual), (num_elements), __LINE__, NULL) 248 | #define TEST_ASSERT_EQUAL_UINT32_ARRAY(expected, actual, num_elements) UNITY_TEST_ASSERT_EQUAL_UINT32_ARRAY((expected), (actual), (num_elements), __LINE__, NULL) 249 | #define TEST_ASSERT_EQUAL_UINT64_ARRAY(expected, actual, num_elements) UNITY_TEST_ASSERT_EQUAL_UINT64_ARRAY((expected), (actual), (num_elements), __LINE__, NULL) 250 | #define TEST_ASSERT_EQUAL_HEX_ARRAY(expected, actual, num_elements) UNITY_TEST_ASSERT_EQUAL_HEX32_ARRAY((expected), (actual), (num_elements), __LINE__, NULL) 251 | #define TEST_ASSERT_EQUAL_HEX8_ARRAY(expected, actual, num_elements) UNITY_TEST_ASSERT_EQUAL_HEX8_ARRAY((expected), (actual), (num_elements), __LINE__, NULL) 252 | #define TEST_ASSERT_EQUAL_HEX16_ARRAY(expected, actual, num_elements) UNITY_TEST_ASSERT_EQUAL_HEX16_ARRAY((expected), (actual), (num_elements), __LINE__, NULL) 253 | #define TEST_ASSERT_EQUAL_HEX32_ARRAY(expected, actual, num_elements) UNITY_TEST_ASSERT_EQUAL_HEX32_ARRAY((expected), (actual), (num_elements), __LINE__, NULL) 254 | #define TEST_ASSERT_EQUAL_HEX64_ARRAY(expected, actual, num_elements) UNITY_TEST_ASSERT_EQUAL_HEX64_ARRAY((expected), (actual), (num_elements), __LINE__, NULL) 255 | #define TEST_ASSERT_EQUAL_PTR_ARRAY(expected, actual, num_elements) UNITY_TEST_ASSERT_EQUAL_PTR_ARRAY((expected), (actual), (num_elements), __LINE__, NULL) 256 | #define TEST_ASSERT_EQUAL_STRING_ARRAY(expected, actual, num_elements) UNITY_TEST_ASSERT_EQUAL_STRING_ARRAY((expected), (actual), (num_elements), __LINE__, NULL) 257 | #define TEST_ASSERT_EQUAL_MEMORY_ARRAY(expected, actual, len, num_elements) UNITY_TEST_ASSERT_EQUAL_MEMORY_ARRAY((expected), (actual), (len), (num_elements), __LINE__, NULL) 258 | 259 | /* Arrays Compared To Single Value */ 260 | #define TEST_ASSERT_EACH_EQUAL_INT(expected, actual, num_elements) UNITY_TEST_ASSERT_EACH_EQUAL_INT((expected), (actual), (num_elements), __LINE__, NULL) 261 | #define TEST_ASSERT_EACH_EQUAL_INT8(expected, actual, num_elements) UNITY_TEST_ASSERT_EACH_EQUAL_INT8((expected), (actual), (num_elements), __LINE__, NULL) 262 | #define TEST_ASSERT_EACH_EQUAL_INT16(expected, actual, num_elements) UNITY_TEST_ASSERT_EACH_EQUAL_INT16((expected), (actual), (num_elements), __LINE__, NULL) 263 | #define TEST_ASSERT_EACH_EQUAL_INT32(expected, actual, num_elements) UNITY_TEST_ASSERT_EACH_EQUAL_INT32((expected), (actual), (num_elements), __LINE__, NULL) 264 | #define TEST_ASSERT_EACH_EQUAL_INT64(expected, actual, num_elements) UNITY_TEST_ASSERT_EACH_EQUAL_INT64((expected), (actual), (num_elements), __LINE__, NULL) 265 | #define TEST_ASSERT_EACH_EQUAL_UINT(expected, actual, num_elements) UNITY_TEST_ASSERT_EACH_EQUAL_UINT((expected), (actual), (num_elements), __LINE__, NULL) 266 | #define TEST_ASSERT_EACH_EQUAL_UINT8(expected, actual, num_elements) UNITY_TEST_ASSERT_EACH_EQUAL_UINT8((expected), (actual), (num_elements), __LINE__, NULL) 267 | #define TEST_ASSERT_EACH_EQUAL_UINT16(expected, actual, num_elements) UNITY_TEST_ASSERT_EACH_EQUAL_UINT16((expected), (actual), (num_elements), __LINE__, NULL) 268 | #define TEST_ASSERT_EACH_EQUAL_UINT32(expected, actual, num_elements) UNITY_TEST_ASSERT_EACH_EQUAL_UINT32((expected), (actual), (num_elements), __LINE__, NULL) 269 | #define TEST_ASSERT_EACH_EQUAL_UINT64(expected, actual, num_elements) UNITY_TEST_ASSERT_EACH_EQUAL_UINT64((expected), (actual), (num_elements), __LINE__, NULL) 270 | #define TEST_ASSERT_EACH_EQUAL_HEX(expected, actual, num_elements) UNITY_TEST_ASSERT_EACH_EQUAL_HEX32((expected), (actual), (num_elements), __LINE__, NULL) 271 | #define TEST_ASSERT_EACH_EQUAL_HEX8(expected, actual, num_elements) UNITY_TEST_ASSERT_EACH_EQUAL_HEX8((expected), (actual), (num_elements), __LINE__, NULL) 272 | #define TEST_ASSERT_EACH_EQUAL_HEX16(expected, actual, num_elements) UNITY_TEST_ASSERT_EACH_EQUAL_HEX16((expected), (actual), (num_elements), __LINE__, NULL) 273 | #define TEST_ASSERT_EACH_EQUAL_HEX32(expected, actual, num_elements) UNITY_TEST_ASSERT_EACH_EQUAL_HEX32((expected), (actual), (num_elements), __LINE__, NULL) 274 | #define TEST_ASSERT_EACH_EQUAL_HEX64(expected, actual, num_elements) UNITY_TEST_ASSERT_EACH_EQUAL_HEX64((expected), (actual), (num_elements), __LINE__, NULL) 275 | #define TEST_ASSERT_EACH_EQUAL_PTR(expected, actual, num_elements) UNITY_TEST_ASSERT_EACH_EQUAL_PTR((expected), (actual), (num_elements), __LINE__, NULL) 276 | #define TEST_ASSERT_EACH_EQUAL_STRING(expected, actual, num_elements) UNITY_TEST_ASSERT_EACH_EQUAL_STRING((expected), (actual), (num_elements), __LINE__, NULL) 277 | #define TEST_ASSERT_EACH_EQUAL_MEMORY(expected, actual, len, num_elements) UNITY_TEST_ASSERT_EACH_EQUAL_MEMORY((expected), (actual), (len), (num_elements), __LINE__, NULL) 278 | 279 | /* Floating Point (If Enabled) */ 280 | #define TEST_ASSERT_FLOAT_WITHIN(delta, expected, actual) UNITY_TEST_ASSERT_FLOAT_WITHIN((delta), (expected), (actual), __LINE__, NULL) 281 | #define TEST_ASSERT_EQUAL_FLOAT(expected, actual) UNITY_TEST_ASSERT_EQUAL_FLOAT((expected), (actual), __LINE__, NULL) 282 | #define TEST_ASSERT_EQUAL_FLOAT_ARRAY(expected, actual, num_elements) UNITY_TEST_ASSERT_EQUAL_FLOAT_ARRAY((expected), (actual), (num_elements), __LINE__, NULL) 283 | #define TEST_ASSERT_EACH_EQUAL_FLOAT(expected, actual, num_elements) UNITY_TEST_ASSERT_EACH_EQUAL_FLOAT((expected), (actual), (num_elements), __LINE__, NULL) 284 | #define TEST_ASSERT_FLOAT_IS_INF(actual) UNITY_TEST_ASSERT_FLOAT_IS_INF((actual), __LINE__, NULL) 285 | #define TEST_ASSERT_FLOAT_IS_NEG_INF(actual) UNITY_TEST_ASSERT_FLOAT_IS_NEG_INF((actual), __LINE__, NULL) 286 | #define TEST_ASSERT_FLOAT_IS_NAN(actual) UNITY_TEST_ASSERT_FLOAT_IS_NAN((actual), __LINE__, NULL) 287 | #define TEST_ASSERT_FLOAT_IS_DETERMINATE(actual) UNITY_TEST_ASSERT_FLOAT_IS_DETERMINATE((actual), __LINE__, NULL) 288 | #define TEST_ASSERT_FLOAT_IS_NOT_INF(actual) UNITY_TEST_ASSERT_FLOAT_IS_NOT_INF((actual), __LINE__, NULL) 289 | #define TEST_ASSERT_FLOAT_IS_NOT_NEG_INF(actual) UNITY_TEST_ASSERT_FLOAT_IS_NOT_NEG_INF((actual), __LINE__, NULL) 290 | #define TEST_ASSERT_FLOAT_IS_NOT_NAN(actual) UNITY_TEST_ASSERT_FLOAT_IS_NOT_NAN((actual), __LINE__, NULL) 291 | #define TEST_ASSERT_FLOAT_IS_NOT_DETERMINATE(actual) UNITY_TEST_ASSERT_FLOAT_IS_NOT_DETERMINATE((actual), __LINE__, NULL) 292 | 293 | /* Double (If Enabled) */ 294 | #define TEST_ASSERT_DOUBLE_WITHIN(delta, expected, actual) UNITY_TEST_ASSERT_DOUBLE_WITHIN((delta), (expected), (actual), __LINE__, NULL) 295 | #define TEST_ASSERT_EQUAL_DOUBLE(expected, actual) UNITY_TEST_ASSERT_EQUAL_DOUBLE((expected), (actual), __LINE__, NULL) 296 | #define TEST_ASSERT_EQUAL_DOUBLE_ARRAY(expected, actual, num_elements) UNITY_TEST_ASSERT_EQUAL_DOUBLE_ARRAY((expected), (actual), (num_elements), __LINE__, NULL) 297 | #define TEST_ASSERT_EACH_EQUAL_DOUBLE(expected, actual, num_elements) UNITY_TEST_ASSERT_EACH_EQUAL_DOUBLE((expected), (actual), (num_elements), __LINE__, NULL) 298 | #define TEST_ASSERT_DOUBLE_IS_INF(actual) UNITY_TEST_ASSERT_DOUBLE_IS_INF((actual), __LINE__, NULL) 299 | #define TEST_ASSERT_DOUBLE_IS_NEG_INF(actual) UNITY_TEST_ASSERT_DOUBLE_IS_NEG_INF((actual), __LINE__, NULL) 300 | #define TEST_ASSERT_DOUBLE_IS_NAN(actual) UNITY_TEST_ASSERT_DOUBLE_IS_NAN((actual), __LINE__, NULL) 301 | #define TEST_ASSERT_DOUBLE_IS_DETERMINATE(actual) UNITY_TEST_ASSERT_DOUBLE_IS_DETERMINATE((actual), __LINE__, NULL) 302 | #define TEST_ASSERT_DOUBLE_IS_NOT_INF(actual) UNITY_TEST_ASSERT_DOUBLE_IS_NOT_INF((actual), __LINE__, NULL) 303 | #define TEST_ASSERT_DOUBLE_IS_NOT_NEG_INF(actual) UNITY_TEST_ASSERT_DOUBLE_IS_NOT_NEG_INF((actual), __LINE__, NULL) 304 | #define TEST_ASSERT_DOUBLE_IS_NOT_NAN(actual) UNITY_TEST_ASSERT_DOUBLE_IS_NOT_NAN((actual), __LINE__, NULL) 305 | #define TEST_ASSERT_DOUBLE_IS_NOT_DETERMINATE(actual) UNITY_TEST_ASSERT_DOUBLE_IS_NOT_DETERMINATE((actual), __LINE__, NULL) 306 | 307 | /*------------------------------------------------------- 308 | * Test Asserts (with additional messages) 309 | *-------------------------------------------------------*/ 310 | 311 | /* Boolean */ 312 | #define TEST_ASSERT_MESSAGE(condition, message) UNITY_TEST_ASSERT( (condition), __LINE__, (message)) 313 | #define TEST_ASSERT_TRUE_MESSAGE(condition, message) UNITY_TEST_ASSERT( (condition), __LINE__, (message)) 314 | #define TEST_ASSERT_UNLESS_MESSAGE(condition, message) UNITY_TEST_ASSERT( !(condition), __LINE__, (message)) 315 | #define TEST_ASSERT_FALSE_MESSAGE(condition, message) UNITY_TEST_ASSERT( !(condition), __LINE__, (message)) 316 | #define TEST_ASSERT_NULL_MESSAGE(pointer, message) UNITY_TEST_ASSERT_NULL( (pointer), __LINE__, (message)) 317 | #define TEST_ASSERT_NOT_NULL_MESSAGE(pointer, message) UNITY_TEST_ASSERT_NOT_NULL((pointer), __LINE__, (message)) 318 | 319 | /* Integers (of all sizes) */ 320 | #define TEST_ASSERT_EQUAL_INT_MESSAGE(expected, actual, message) UNITY_TEST_ASSERT_EQUAL_INT((expected), (actual), __LINE__, (message)) 321 | #define TEST_ASSERT_EQUAL_INT8_MESSAGE(expected, actual, message) UNITY_TEST_ASSERT_EQUAL_INT8((expected), (actual), __LINE__, (message)) 322 | #define TEST_ASSERT_EQUAL_INT16_MESSAGE(expected, actual, message) UNITY_TEST_ASSERT_EQUAL_INT16((expected), (actual), __LINE__, (message)) 323 | #define TEST_ASSERT_EQUAL_INT32_MESSAGE(expected, actual, message) UNITY_TEST_ASSERT_EQUAL_INT32((expected), (actual), __LINE__, (message)) 324 | #define TEST_ASSERT_EQUAL_INT64_MESSAGE(expected, actual, message) UNITY_TEST_ASSERT_EQUAL_INT64((expected), (actual), __LINE__, (message)) 325 | #define TEST_ASSERT_EQUAL_MESSAGE(expected, actual, message) UNITY_TEST_ASSERT_EQUAL_INT((expected), (actual), __LINE__, (message)) 326 | #define TEST_ASSERT_NOT_EQUAL_MESSAGE(expected, actual, message) UNITY_TEST_ASSERT(((expected) != (actual)), __LINE__, (message)) 327 | #define TEST_ASSERT_EQUAL_UINT_MESSAGE(expected, actual, message) UNITY_TEST_ASSERT_EQUAL_UINT( (expected), (actual), __LINE__, (message)) 328 | #define TEST_ASSERT_EQUAL_UINT8_MESSAGE(expected, actual, message) UNITY_TEST_ASSERT_EQUAL_UINT8( (expected), (actual), __LINE__, (message)) 329 | #define TEST_ASSERT_EQUAL_UINT16_MESSAGE(expected, actual, message) UNITY_TEST_ASSERT_EQUAL_UINT16( (expected), (actual), __LINE__, (message)) 330 | #define TEST_ASSERT_EQUAL_UINT32_MESSAGE(expected, actual, message) UNITY_TEST_ASSERT_EQUAL_UINT32( (expected), (actual), __LINE__, (message)) 331 | #define TEST_ASSERT_EQUAL_UINT64_MESSAGE(expected, actual, message) UNITY_TEST_ASSERT_EQUAL_UINT64( (expected), (actual), __LINE__, (message)) 332 | #define TEST_ASSERT_EQUAL_HEX_MESSAGE(expected, actual, message) UNITY_TEST_ASSERT_EQUAL_HEX32((expected), (actual), __LINE__, (message)) 333 | #define TEST_ASSERT_EQUAL_HEX8_MESSAGE(expected, actual, message) UNITY_TEST_ASSERT_EQUAL_HEX8( (expected), (actual), __LINE__, (message)) 334 | #define TEST_ASSERT_EQUAL_HEX16_MESSAGE(expected, actual, message) UNITY_TEST_ASSERT_EQUAL_HEX16((expected), (actual), __LINE__, (message)) 335 | #define TEST_ASSERT_EQUAL_HEX32_MESSAGE(expected, actual, message) UNITY_TEST_ASSERT_EQUAL_HEX32((expected), (actual), __LINE__, (message)) 336 | #define TEST_ASSERT_EQUAL_HEX64_MESSAGE(expected, actual, message) UNITY_TEST_ASSERT_EQUAL_HEX64((expected), (actual), __LINE__, (message)) 337 | #define TEST_ASSERT_BITS_MESSAGE(mask, expected, actual, message) UNITY_TEST_ASSERT_BITS((mask), (expected), (actual), __LINE__, (message)) 338 | #define TEST_ASSERT_BITS_HIGH_MESSAGE(mask, actual, message) UNITY_TEST_ASSERT_BITS((mask), (UNITY_UINT32)(-1), (actual), __LINE__, (message)) 339 | #define TEST_ASSERT_BITS_LOW_MESSAGE(mask, actual, message) UNITY_TEST_ASSERT_BITS((mask), (UNITY_UINT32)(0), (actual), __LINE__, (message)) 340 | #define TEST_ASSERT_BIT_HIGH_MESSAGE(bit, actual, message) UNITY_TEST_ASSERT_BITS(((UNITY_UINT32)1 << (bit)), (UNITY_UINT32)(-1), (actual), __LINE__, (message)) 341 | #define TEST_ASSERT_BIT_LOW_MESSAGE(bit, actual, message) UNITY_TEST_ASSERT_BITS(((UNITY_UINT32)1 << (bit)), (UNITY_UINT32)(0), (actual), __LINE__, (message)) 342 | 343 | /* Integer Greater Than/ Less Than (of all sizes) */ 344 | #define TEST_ASSERT_GREATER_THAN_MESSAGE(threshold, actual, message) UNITY_TEST_ASSERT_GREATER_THAN_INT((threshold), (actual), __LINE__, (message)) 345 | #define TEST_ASSERT_GREATER_THAN_INT_MESSAGE(threshold, actual, message) UNITY_TEST_ASSERT_GREATER_THAN_INT((threshold), (actual), __LINE__, (message)) 346 | #define TEST_ASSERT_GREATER_THAN_INT8_MESSAGE(threshold, actual, message) UNITY_TEST_ASSERT_GREATER_THAN_INT8((threshold), (actual), __LINE__, (message)) 347 | #define TEST_ASSERT_GREATER_THAN_INT16_MESSAGE(threshold, actual, message) UNITY_TEST_ASSERT_GREATER_THAN_INT16((threshold), (actual), __LINE__, (message)) 348 | #define TEST_ASSERT_GREATER_THAN_INT32_MESSAGE(threshold, actual, message) UNITY_TEST_ASSERT_GREATER_THAN_INT32((threshold), (actual), __LINE__, (message)) 349 | #define TEST_ASSERT_GREATER_THAN_INT64_MESSAGE(threshold, actual, message) UNITY_TEST_ASSERT_GREATER_THAN_INT64((threshold), (actual), __LINE__, (message)) 350 | #define TEST_ASSERT_GREATER_THAN_UINT_MESSAGE(threshold, actual, message) UNITY_TEST_ASSERT_GREATER_THAN_UINT((threshold), (actual), __LINE__, (message)) 351 | #define TEST_ASSERT_GREATER_THAN_UINT8_MESSAGE(threshold, actual, message) UNITY_TEST_ASSERT_GREATER_THAN_UINT8((threshold), (actual), __LINE__, (message)) 352 | #define TEST_ASSERT_GREATER_THAN_UINT16_MESSAGE(threshold, actual, message) UNITY_TEST_ASSERT_GREATER_THAN_UINT16((threshold), (actual), __LINE__, (message)) 353 | #define TEST_ASSERT_GREATER_THAN_UINT32_MESSAGE(threshold, actual, message) UNITY_TEST_ASSERT_GREATER_THAN_UINT32((threshold), (actual), __LINE__, (message)) 354 | #define TEST_ASSERT_GREATER_THAN_UINT64_MESSAGE(threshold, actual, message) UNITY_TEST_ASSERT_GREATER_THAN_UINT64((threshold), (actual), __LINE__, (message)) 355 | #define TEST_ASSERT_GREATER_THAN_HEX8_MESSAGE(threshold, actual, message) UNITY_TEST_ASSERT_GREATER_THAN_HEX8((threshold), (actual), __LINE__, (message)) 356 | #define TEST_ASSERT_GREATER_THAN_HEX16_MESSAGE(threshold, actual, message) UNITY_TEST_ASSERT_GREATER_THAN_HEX16((threshold), (actual), __LINE__, (message)) 357 | #define TEST_ASSERT_GREATER_THAN_HEX32_MESSAGE(threshold, actual, message) UNITY_TEST_ASSERT_GREATER_THAN_HEX32((threshold), (actual), __LINE__, (message)) 358 | #define TEST_ASSERT_GREATER_THAN_HEX64_MESSAGE(threshold, actual, message) UNITY_TEST_ASSERT_GREATER_THAN_HEX64((threshold), (actual), __LINE__, (message)) 359 | 360 | #define TEST_ASSERT_LESS_THAN_MESSAGE(threshold, actual, message) UNITY_TEST_ASSERT_SMALLER_THAN_INT((threshold), (actual), __LINE__, (message)) 361 | #define TEST_ASSERT_LESS_THAN_INT_MESSAGE(threshold, actual, message) UNITY_TEST_ASSERT_SMALLER_THAN_INT((threshold), (actual), __LINE__, (message)) 362 | #define TEST_ASSERT_LESS_THAN_INT8_MESSAGE(threshold, actual, message) UNITY_TEST_ASSERT_SMALLER_THAN_INT8((threshold), (actual), __LINE__, (message)) 363 | #define TEST_ASSERT_LESS_THAN_INT16_MESSAGE(threshold, actual, message) UNITY_TEST_ASSERT_SMALLER_THAN_INT16((threshold), (actual), __LINE__, (message)) 364 | #define TEST_ASSERT_LESS_THAN_INT32_MESSAGE(threshold, actual, message) UNITY_TEST_ASSERT_SMALLER_THAN_INT32((threshold), (actual), __LINE__, (message)) 365 | #define TEST_ASSERT_LESS_THAN_INT64_MESSAGE(threshold, actual, message) UNITY_TEST_ASSERT_SMALLER_THAN_INT64((threshold), (actual), __LINE__, (message)) 366 | #define TEST_ASSERT_LESS_THAN_UINT_MESSAGE(threshold, actual, message) UNITY_TEST_ASSERT_SMALLER_THAN_UINT((threshold), (actual), __LINE__, (message)) 367 | #define TEST_ASSERT_LESS_THAN_UINT8_MESSAGE(threshold, actual, message) UNITY_TEST_ASSERT_SMALLER_THAN_UINT8((threshold), (actual), __LINE__, (message)) 368 | #define TEST_ASSERT_LESS_THAN_UINT16_MESSAGE(threshold, actual, message) UNITY_TEST_ASSERT_SMALLER_THAN_UINT16((threshold), (actual), __LINE__, (message)) 369 | #define TEST_ASSERT_LESS_THAN_UINT32_MESSAGE(threshold, actual, message) UNITY_TEST_ASSERT_SMALLER_THAN_UINT32((threshold), (actual), __LINE__, (message)) 370 | #define TEST_ASSERT_LESS_THAN_UINT64_MESSAGE(threshold, actual, message) UNITY_TEST_ASSERT_SMALLER_THAN_UINT64((threshold), (actual), __LINE__, (message)) 371 | #define TEST_ASSERT_LESS_THAN_HEX8_MESSAGE(threshold, actual, message) UNITY_TEST_ASSERT_SMALLER_THAN_HEX8((threshold), (actual), __LINE__, (message)) 372 | #define TEST_ASSERT_LESS_THAN_HEX16_MESSAGE(threshold, actual, message) UNITY_TEST_ASSERT_SMALLER_THAN_HEX16((threshold), (actual), __LINE__, (message)) 373 | #define TEST_ASSERT_LESS_THAN_HEX32_MESSAGE(threshold, actual, message) UNITY_TEST_ASSERT_SMALLER_THAN_HEX32((threshold), (actual), __LINE__, (message)) 374 | #define TEST_ASSERT_LESS_THAN_HEX64_MESSAGE(threshold, actual, message) UNITY_TEST_ASSERT_SMALLER_THAN_HEX64((threshold), (actual), __LINE__, (message)) 375 | 376 | #define TEST_ASSERT_GREATER_OR_EQUAL_MESSAGE(threshold, actual, message) UNITY_TEST_ASSERT_GREATER_OR_EQUAL_INT((threshold), (actual), __LINE__, (message)) 377 | #define TEST_ASSERT_GREATER_OR_EQUAL_INT_MESSAGE(threshold, actual, message) UNITY_TEST_ASSERT_GREATER_OR_EQUAL_INT((threshold), (actual), __LINE__, (message)) 378 | #define TEST_ASSERT_GREATER_OR_EQUAL_INT8_MESSAGE(threshold, actual, message) UNITY_TEST_ASSERT_GREATER_OR_EQUAL_INT8((threshold), (actual), __LINE__, (message)) 379 | #define TEST_ASSERT_GREATER_OR_EQUAL_INT16_MESSAGE(threshold, actual, message) UNITY_TEST_ASSERT_GREATER_OR_EQUAL_INT16((threshold), (actual), __LINE__, (message)) 380 | #define TEST_ASSERT_GREATER_OR_EQUAL_INT32_MESSAGE(threshold, actual, message) UNITY_TEST_ASSERT_GREATER_OR_EQUAL_INT32((threshold), (actual), __LINE__, (message)) 381 | #define TEST_ASSERT_GREATER_OR_EQUAL_INT64_MESSAGE(threshold, actual, message) UNITY_TEST_ASSERT_GREATER_OR_EQUAL_INT64((threshold), (actual), __LINE__, (message)) 382 | #define TEST_ASSERT_GREATER_OR_EQUAL_UINT_MESSAGE(threshold, actual, message) UNITY_TEST_ASSERT_GREATER_OR_EQUAL_UINT((threshold), (actual), __LINE__, (message)) 383 | #define TEST_ASSERT_GREATER_OR_EQUAL_UINT8_MESSAGE(threshold, actual, message) UNITY_TEST_ASSERT_GREATER_OR_EQUAL_UINT8((threshold), (actual), __LINE__, (message)) 384 | #define TEST_ASSERT_GREATER_OR_EQUAL_UINT16_MESSAGE(threshold, actual, message) UNITY_TEST_ASSERT_GREATER_OR_EQUAL_UINT16((threshold), (actual), __LINE__, (message)) 385 | #define TEST_ASSERT_GREATER_OR_EQUAL_UINT32_MESSAGE(threshold, actual, message) UNITY_TEST_ASSERT_GREATER_OR_EQUAL_UINT32((threshold), (actual), __LINE__, (message)) 386 | #define TEST_ASSERT_GREATER_OR_EQUAL_UINT64_MESSAGE(threshold, actual, message) UNITY_TEST_ASSERT_GREATER_OR_EQUAL_UINT64((threshold), (actual), __LINE__, (message)) 387 | #define TEST_ASSERT_GREATER_OR_EQUAL_HEX8_MESSAGE(threshold, actual, message) UNITY_TEST_ASSERT_GREATER_OR_EQUAL_HEX8((threshold), (actual), __LINE__, (message)) 388 | #define TEST_ASSERT_GREATER_OR_EQUAL_HEX16_MESSAGE(threshold, actual, message) UNITY_TEST_ASSERT_GREATER_OR_EQUAL_HEX16((threshold), (actual), __LINE__, (message)) 389 | #define TEST_ASSERT_GREATER_OR_EQUAL_HEX32_MESSAGE(threshold, actual, message) UNITY_TEST_ASSERT_GREATER_OR_EQUAL_HEX32((threshold), (actual), __LINE__, (message)) 390 | #define TEST_ASSERT_GREATER_OR_EQUAL_HEX64_MESSAGE(threshold, actual, message) UNITY_TEST_ASSERT_GREATER_OR_EQUAL_HEX64((threshold), (actual), __LINE__, (message)) 391 | 392 | #define TEST_ASSERT_LESS_OR_EQUAL_MESSAGE(threshold, actual, message) UNITY_TEST_ASSERT_SMALLER_OR_EQUAL_INT((threshold), (actual), __LINE__, (message)) 393 | #define TEST_ASSERT_LESS_OR_EQUAL_INT_MESSAGE(threshold, actual, message) UNITY_TEST_ASSERT_SMALLER_OR_EQUAL_INT((threshold), (actual), __LINE__, (message)) 394 | #define TEST_ASSERT_LESS_OR_EQUAL_INT8_MESSAGE(threshold, actual, message) UNITY_TEST_ASSERT_SMALLER_OR_EQUAL_INT8((threshold), (actual), __LINE__, (message)) 395 | #define TEST_ASSERT_LESS_OR_EQUAL_INT16_MESSAGE(threshold, actual, message) UNITY_TEST_ASSERT_SMALLER_OR_EQUAL_INT16((threshold), (actual), __LINE__, (message)) 396 | #define TEST_ASSERT_LESS_OR_EQUAL_INT32_MESSAGE(threshold, actual, message) UNITY_TEST_ASSERT_SMALLER_OR_EQUAL_INT32((threshold), (actual), __LINE__, (message)) 397 | #define TEST_ASSERT_LESS_OR_EQUAL_INT64_MESSAGE(threshold, actual, message) UNITY_TEST_ASSERT_SMALLER_OR_EQUAL_INT64((threshold), (actual), __LINE__, (message)) 398 | #define TEST_ASSERT_LESS_OR_EQUAL_UINT_MESSAGE(threshold, actual, message) UNITY_TEST_ASSERT_SMALLER_OR_EQUAL_UINT((threshold), (actual), __LINE__, (message)) 399 | #define TEST_ASSERT_LESS_OR_EQUAL_UINT8_MESSAGE(threshold, actual, message) UNITY_TEST_ASSERT_SMALLER_OR_EQUAL_UINT8((threshold), (actual), __LINE__, (message)) 400 | #define TEST_ASSERT_LESS_OR_EQUAL_UINT16_MESSAGE(threshold, actual, message) UNITY_TEST_ASSERT_SMALLER_OR_EQUAL_UINT16((threshold), (actual), __LINE__, (message)) 401 | #define TEST_ASSERT_LESS_OR_EQUAL_UINT32_MESSAGE(threshold, actual, message) UNITY_TEST_ASSERT_SMALLER_OR_EQUAL_UINT32((threshold), (actual), __LINE__, (message)) 402 | #define TEST_ASSERT_LESS_OR_EQUAL_UINT64_MESSAGE(threshold, actual, message) UNITY_TEST_ASSERT_SMALLER_OR_EQUAL_UINT64((threshold), (actual), __LINE__, (message)) 403 | #define TEST_ASSERT_LESS_OR_EQUAL_HEX8_MESSAGE(threshold, actual, message) UNITY_TEST_ASSERT_SMALLER_OR_EQUAL_HEX8((threshold), (actual), __LINE__, (message)) 404 | #define TEST_ASSERT_LESS_OR_EQUAL_HEX16_MESSAGE(threshold, actual, message) UNITY_TEST_ASSERT_SMALLER_OR_EQUAL_HEX16((threshold), (actual), __LINE__, (message)) 405 | #define TEST_ASSERT_LESS_OR_EQUAL_HEX32_MESSAGE(threshold, actual, message) UNITY_TEST_ASSERT_SMALLER_THAN_HEX32((threshold), (actual), __LINE__, (message)) 406 | #define TEST_ASSERT_LESS_OR_EQUAL_HEX64_MESSAGE(threshold, actual, message) UNITY_TEST_ASSERT_SMALLER_THAN_HEX64((threshold), (actual), __LINE__, (message)) 407 | 408 | /* Integer Ranges (of all sizes) */ 409 | #define TEST_ASSERT_INT_WITHIN_MESSAGE(delta, expected, actual, message) UNITY_TEST_ASSERT_INT_WITHIN((delta), (expected), (actual), __LINE__, (message)) 410 | #define TEST_ASSERT_INT8_WITHIN_MESSAGE(delta, expected, actual, message) UNITY_TEST_ASSERT_INT8_WITHIN((delta), (expected), (actual), __LINE__, (message)) 411 | #define TEST_ASSERT_INT16_WITHIN_MESSAGE(delta, expected, actual, message) UNITY_TEST_ASSERT_INT16_WITHIN((delta), (expected), (actual), __LINE__, (message)) 412 | #define TEST_ASSERT_INT32_WITHIN_MESSAGE(delta, expected, actual, message) UNITY_TEST_ASSERT_INT32_WITHIN((delta), (expected), (actual), __LINE__, (message)) 413 | #define TEST_ASSERT_INT64_WITHIN_MESSAGE(delta, expected, actual, message) UNITY_TEST_ASSERT_INT64_WITHIN((delta), (expected), (actual), __LINE__, (message)) 414 | #define TEST_ASSERT_UINT_WITHIN_MESSAGE(delta, expected, actual, message) UNITY_TEST_ASSERT_UINT_WITHIN((delta), (expected), (actual), __LINE__, (message)) 415 | #define TEST_ASSERT_UINT8_WITHIN_MESSAGE(delta, expected, actual, message) UNITY_TEST_ASSERT_UINT8_WITHIN((delta), (expected), (actual), __LINE__, (message)) 416 | #define TEST_ASSERT_UINT16_WITHIN_MESSAGE(delta, expected, actual, message) UNITY_TEST_ASSERT_UINT16_WITHIN((delta), (expected), (actual), __LINE__, (message)) 417 | #define TEST_ASSERT_UINT32_WITHIN_MESSAGE(delta, expected, actual, message) UNITY_TEST_ASSERT_UINT32_WITHIN((delta), (expected), (actual), __LINE__, (message)) 418 | #define TEST_ASSERT_UINT64_WITHIN_MESSAGE(delta, expected, actual, message) UNITY_TEST_ASSERT_UINT64_WITHIN((delta), (expected), (actual), __LINE__, (message)) 419 | #define TEST_ASSERT_HEX_WITHIN_MESSAGE(delta, expected, actual, message) UNITY_TEST_ASSERT_HEX32_WITHIN((delta), (expected), (actual), __LINE__, (message)) 420 | #define TEST_ASSERT_HEX8_WITHIN_MESSAGE(delta, expected, actual, message) UNITY_TEST_ASSERT_HEX8_WITHIN((delta), (expected), (actual), __LINE__, (message)) 421 | #define TEST_ASSERT_HEX16_WITHIN_MESSAGE(delta, expected, actual, message) UNITY_TEST_ASSERT_HEX16_WITHIN((delta), (expected), (actual), __LINE__, (message)) 422 | #define TEST_ASSERT_HEX32_WITHIN_MESSAGE(delta, expected, actual, message) UNITY_TEST_ASSERT_HEX32_WITHIN((delta), (expected), (actual), __LINE__, (message)) 423 | #define TEST_ASSERT_HEX64_WITHIN_MESSAGE(delta, expected, actual, message) UNITY_TEST_ASSERT_HEX64_WITHIN((delta), (expected), (actual), __LINE__, (message)) 424 | 425 | /* Structs and Strings */ 426 | #define TEST_ASSERT_EQUAL_PTR_MESSAGE(expected, actual, message) UNITY_TEST_ASSERT_EQUAL_PTR((expected), (actual), __LINE__, (message)) 427 | #define TEST_ASSERT_EQUAL_STRING_MESSAGE(expected, actual, message) UNITY_TEST_ASSERT_EQUAL_STRING((expected), (actual), __LINE__, (message)) 428 | #define TEST_ASSERT_EQUAL_STRING_LEN_MESSAGE(expected, actual, len, message) UNITY_TEST_ASSERT_EQUAL_STRING_LEN((expected), (actual), (len), __LINE__, (message)) 429 | #define TEST_ASSERT_EQUAL_MEMORY_MESSAGE(expected, actual, len, message) UNITY_TEST_ASSERT_EQUAL_MEMORY((expected), (actual), (len), __LINE__, (message)) 430 | 431 | /* Arrays */ 432 | #define TEST_ASSERT_EQUAL_INT_ARRAY_MESSAGE(expected, actual, num_elements, message) UNITY_TEST_ASSERT_EQUAL_INT_ARRAY((expected), (actual), (num_elements), __LINE__, (message)) 433 | #define TEST_ASSERT_EQUAL_INT8_ARRAY_MESSAGE(expected, actual, num_elements, message) UNITY_TEST_ASSERT_EQUAL_INT8_ARRAY((expected), (actual), (num_elements), __LINE__, (message)) 434 | #define TEST_ASSERT_EQUAL_INT16_ARRAY_MESSAGE(expected, actual, num_elements, message) UNITY_TEST_ASSERT_EQUAL_INT16_ARRAY((expected), (actual), (num_elements), __LINE__, (message)) 435 | #define TEST_ASSERT_EQUAL_INT32_ARRAY_MESSAGE(expected, actual, num_elements, message) UNITY_TEST_ASSERT_EQUAL_INT32_ARRAY((expected), (actual), (num_elements), __LINE__, (message)) 436 | #define TEST_ASSERT_EQUAL_INT64_ARRAY_MESSAGE(expected, actual, num_elements, message) UNITY_TEST_ASSERT_EQUAL_INT64_ARRAY((expected), (actual), (num_elements), __LINE__, (message)) 437 | #define TEST_ASSERT_EQUAL_UINT_ARRAY_MESSAGE(expected, actual, num_elements, message) UNITY_TEST_ASSERT_EQUAL_UINT_ARRAY((expected), (actual), (num_elements), __LINE__, (message)) 438 | #define TEST_ASSERT_EQUAL_UINT8_ARRAY_MESSAGE(expected, actual, num_elements, message) UNITY_TEST_ASSERT_EQUAL_UINT8_ARRAY((expected), (actual), (num_elements), __LINE__, (message)) 439 | #define TEST_ASSERT_EQUAL_UINT16_ARRAY_MESSAGE(expected, actual, num_elements, message) UNITY_TEST_ASSERT_EQUAL_UINT16_ARRAY((expected), (actual), (num_elements), __LINE__, (message)) 440 | #define TEST_ASSERT_EQUAL_UINT32_ARRAY_MESSAGE(expected, actual, num_elements, message) UNITY_TEST_ASSERT_EQUAL_UINT32_ARRAY((expected), (actual), (num_elements), __LINE__, (message)) 441 | #define TEST_ASSERT_EQUAL_UINT64_ARRAY_MESSAGE(expected, actual, num_elements, message) UNITY_TEST_ASSERT_EQUAL_UINT64_ARRAY((expected), (actual), (num_elements), __LINE__, (message)) 442 | #define TEST_ASSERT_EQUAL_HEX_ARRAY_MESSAGE(expected, actual, num_elements, message) UNITY_TEST_ASSERT_EQUAL_HEX32_ARRAY((expected), (actual), (num_elements), __LINE__, (message)) 443 | #define TEST_ASSERT_EQUAL_HEX8_ARRAY_MESSAGE(expected, actual, num_elements, message) UNITY_TEST_ASSERT_EQUAL_HEX8_ARRAY((expected), (actual), (num_elements), __LINE__, (message)) 444 | #define TEST_ASSERT_EQUAL_HEX16_ARRAY_MESSAGE(expected, actual, num_elements, message) UNITY_TEST_ASSERT_EQUAL_HEX16_ARRAY((expected), (actual), (num_elements), __LINE__, (message)) 445 | #define TEST_ASSERT_EQUAL_HEX32_ARRAY_MESSAGE(expected, actual, num_elements, message) UNITY_TEST_ASSERT_EQUAL_HEX32_ARRAY((expected), (actual), (num_elements), __LINE__, (message)) 446 | #define TEST_ASSERT_EQUAL_HEX64_ARRAY_MESSAGE(expected, actual, num_elements, message) UNITY_TEST_ASSERT_EQUAL_HEX64_ARRAY((expected), (actual), (num_elements), __LINE__, (message)) 447 | #define TEST_ASSERT_EQUAL_PTR_ARRAY_MESSAGE(expected, actual, num_elements, message) UNITY_TEST_ASSERT_EQUAL_PTR_ARRAY((expected), (actual), (num_elements), __LINE__, (message)) 448 | #define TEST_ASSERT_EQUAL_STRING_ARRAY_MESSAGE(expected, actual, num_elements, message) UNITY_TEST_ASSERT_EQUAL_STRING_ARRAY((expected), (actual), (num_elements), __LINE__, (message)) 449 | #define TEST_ASSERT_EQUAL_MEMORY_ARRAY_MESSAGE(expected, actual, len, num_elements, message) UNITY_TEST_ASSERT_EQUAL_MEMORY_ARRAY((expected), (actual), (len), (num_elements), __LINE__, (message)) 450 | 451 | /* Arrays Compared To Single Value*/ 452 | #define TEST_ASSERT_EACH_EQUAL_INT_MESSAGE(expected, actual, num_elements, message) UNITY_TEST_ASSERT_EACH_EQUAL_INT((expected), (actual), (num_elements), __LINE__, (message)) 453 | #define TEST_ASSERT_EACH_EQUAL_INT8_MESSAGE(expected, actual, num_elements, message) UNITY_TEST_ASSERT_EACH_EQUAL_INT8((expected), (actual), (num_elements), __LINE__, (message)) 454 | #define TEST_ASSERT_EACH_EQUAL_INT16_MESSAGE(expected, actual, num_elements, message) UNITY_TEST_ASSERT_EACH_EQUAL_INT16((expected), (actual), (num_elements), __LINE__, (message)) 455 | #define TEST_ASSERT_EACH_EQUAL_INT32_MESSAGE(expected, actual, num_elements, message) UNITY_TEST_ASSERT_EACH_EQUAL_INT32((expected), (actual), (num_elements), __LINE__, (message)) 456 | #define TEST_ASSERT_EACH_EQUAL_INT64_MESSAGE(expected, actual, num_elements, message) UNITY_TEST_ASSERT_EACH_EQUAL_INT64((expected), (actual), (num_elements), __LINE__, (message)) 457 | #define TEST_ASSERT_EACH_EQUAL_UINT_MESSAGE(expected, actual, num_elements, message) UNITY_TEST_ASSERT_EACH_EQUAL_UINT((expected), (actual), (num_elements), __LINE__, (message)) 458 | #define TEST_ASSERT_EACH_EQUAL_UINT8_MESSAGE(expected, actual, num_elements, message) UNITY_TEST_ASSERT_EACH_EQUAL_UINT8((expected), (actual), (num_elements), __LINE__, (message)) 459 | #define TEST_ASSERT_EACH_EQUAL_UINT16_MESSAGE(expected, actual, num_elements, message) UNITY_TEST_ASSERT_EACH_EQUAL_UINT16((expected), (actual), (num_elements), __LINE__, (message)) 460 | #define TEST_ASSERT_EACH_EQUAL_UINT32_MESSAGE(expected, actual, num_elements, message) UNITY_TEST_ASSERT_EACH_EQUAL_UINT32((expected), (actual), (num_elements), __LINE__, (message)) 461 | #define TEST_ASSERT_EACH_EQUAL_UINT64_MESSAGE(expected, actual, num_elements, message) UNITY_TEST_ASSERT_EACH_EQUAL_UINT64((expected), (actual), (num_elements), __LINE__, (message)) 462 | #define TEST_ASSERT_EACH_EQUAL_HEX_MESSAGE(expected, actual, num_elements, message) UNITY_TEST_ASSERT_EACH_EQUAL_HEX32((expected), (actual), (num_elements), __LINE__, (message)) 463 | #define TEST_ASSERT_EACH_EQUAL_HEX8_MESSAGE(expected, actual, num_elements, message) UNITY_TEST_ASSERT_EACH_EQUAL_HEX8((expected), (actual), (num_elements), __LINE__, (message)) 464 | #define TEST_ASSERT_EACH_EQUAL_HEX16_MESSAGE(expected, actual, num_elements, message) UNITY_TEST_ASSERT_EACH_EQUAL_HEX16((expected), (actual), (num_elements), __LINE__, (message)) 465 | #define TEST_ASSERT_EACH_EQUAL_HEX32_MESSAGE(expected, actual, num_elements, message) UNITY_TEST_ASSERT_EACH_EQUAL_HEX32((expected), (actual), (num_elements), __LINE__, (message)) 466 | #define TEST_ASSERT_EACH_EQUAL_HEX64_MESSAGE(expected, actual, num_elements, message) UNITY_TEST_ASSERT_EACH_EQUAL_HEX64((expected), (actual), (num_elements), __LINE__, (message)) 467 | #define TEST_ASSERT_EACH_EQUAL_PTR_MESSAGE(expected, actual, num_elements, message) UNITY_TEST_ASSERT_EACH_EQUAL_PTR((expected), (actual), (num_elements), __LINE__, (message)) 468 | #define TEST_ASSERT_EACH_EQUAL_STRING_MESSAGE(expected, actual, num_elements, message) UNITY_TEST_ASSERT_EACH_EQUAL_STRING((expected), (actual), (num_elements), __LINE__, (message)) 469 | #define TEST_ASSERT_EACH_EQUAL_MEMORY_MESSAGE(expected, actual, len, num_elements, message) UNITY_TEST_ASSERT_EACH_EQUAL_MEMORY((expected), (actual), (len), (num_elements), __LINE__, (message)) 470 | 471 | /* Floating Point (If Enabled) */ 472 | #define TEST_ASSERT_FLOAT_WITHIN_MESSAGE(delta, expected, actual, message) UNITY_TEST_ASSERT_FLOAT_WITHIN((delta), (expected), (actual), __LINE__, (message)) 473 | #define TEST_ASSERT_EQUAL_FLOAT_MESSAGE(expected, actual, message) UNITY_TEST_ASSERT_EQUAL_FLOAT((expected), (actual), __LINE__, (message)) 474 | #define TEST_ASSERT_EQUAL_FLOAT_ARRAY_MESSAGE(expected, actual, num_elements, message) UNITY_TEST_ASSERT_EQUAL_FLOAT_ARRAY((expected), (actual), (num_elements), __LINE__, (message)) 475 | #define TEST_ASSERT_EACH_EQUAL_FLOAT_MESSAGE(expected, actual, num_elements, message) UNITY_TEST_ASSERT_EACH_EQUAL_FLOAT((expected), (actual), (num_elements), __LINE__, (message)) 476 | #define TEST_ASSERT_FLOAT_IS_INF_MESSAGE(actual, message) UNITY_TEST_ASSERT_FLOAT_IS_INF((actual), __LINE__, (message)) 477 | #define TEST_ASSERT_FLOAT_IS_NEG_INF_MESSAGE(actual, message) UNITY_TEST_ASSERT_FLOAT_IS_NEG_INF((actual), __LINE__, (message)) 478 | #define TEST_ASSERT_FLOAT_IS_NAN_MESSAGE(actual, message) UNITY_TEST_ASSERT_FLOAT_IS_NAN((actual), __LINE__, (message)) 479 | #define TEST_ASSERT_FLOAT_IS_DETERMINATE_MESSAGE(actual, message) UNITY_TEST_ASSERT_FLOAT_IS_DETERMINATE((actual), __LINE__, (message)) 480 | #define TEST_ASSERT_FLOAT_IS_NOT_INF_MESSAGE(actual, message) UNITY_TEST_ASSERT_FLOAT_IS_NOT_INF((actual), __LINE__, (message)) 481 | #define TEST_ASSERT_FLOAT_IS_NOT_NEG_INF_MESSAGE(actual, message) UNITY_TEST_ASSERT_FLOAT_IS_NOT_NEG_INF((actual), __LINE__, (message)) 482 | #define TEST_ASSERT_FLOAT_IS_NOT_NAN_MESSAGE(actual, message) UNITY_TEST_ASSERT_FLOAT_IS_NOT_NAN((actual), __LINE__, (message)) 483 | #define TEST_ASSERT_FLOAT_IS_NOT_DETERMINATE_MESSAGE(actual, message) UNITY_TEST_ASSERT_FLOAT_IS_NOT_DETERMINATE((actual), __LINE__, (message)) 484 | 485 | /* Double (If Enabled) */ 486 | #define TEST_ASSERT_DOUBLE_WITHIN_MESSAGE(delta, expected, actual, message) UNITY_TEST_ASSERT_DOUBLE_WITHIN((delta), (expected), (actual), __LINE__, (message)) 487 | #define TEST_ASSERT_EQUAL_DOUBLE_MESSAGE(expected, actual, message) UNITY_TEST_ASSERT_EQUAL_DOUBLE((expected), (actual), __LINE__, (message)) 488 | #define TEST_ASSERT_EQUAL_DOUBLE_ARRAY_MESSAGE(expected, actual, num_elements, message) UNITY_TEST_ASSERT_EQUAL_DOUBLE_ARRAY((expected), (actual), (num_elements), __LINE__, (message)) 489 | #define TEST_ASSERT_EACH_EQUAL_DOUBLE_MESSAGE(expected, actual, num_elements, message) UNITY_TEST_ASSERT_EACH_EQUAL_DOUBLE((expected), (actual), (num_elements), __LINE__, (message)) 490 | #define TEST_ASSERT_DOUBLE_IS_INF_MESSAGE(actual, message) UNITY_TEST_ASSERT_DOUBLE_IS_INF((actual), __LINE__, (message)) 491 | #define TEST_ASSERT_DOUBLE_IS_NEG_INF_MESSAGE(actual, message) UNITY_TEST_ASSERT_DOUBLE_IS_NEG_INF((actual), __LINE__, (message)) 492 | #define TEST_ASSERT_DOUBLE_IS_NAN_MESSAGE(actual, message) UNITY_TEST_ASSERT_DOUBLE_IS_NAN((actual), __LINE__, (message)) 493 | #define TEST_ASSERT_DOUBLE_IS_DETERMINATE_MESSAGE(actual, message) UNITY_TEST_ASSERT_DOUBLE_IS_DETERMINATE((actual), __LINE__, (message)) 494 | #define TEST_ASSERT_DOUBLE_IS_NOT_INF_MESSAGE(actual, message) UNITY_TEST_ASSERT_DOUBLE_IS_NOT_INF((actual), __LINE__, (message)) 495 | #define TEST_ASSERT_DOUBLE_IS_NOT_NEG_INF_MESSAGE(actual, message) UNITY_TEST_ASSERT_DOUBLE_IS_NOT_NEG_INF((actual), __LINE__, (message)) 496 | #define TEST_ASSERT_DOUBLE_IS_NOT_NAN_MESSAGE(actual, message) UNITY_TEST_ASSERT_DOUBLE_IS_NOT_NAN((actual), __LINE__, (message)) 497 | #define TEST_ASSERT_DOUBLE_IS_NOT_DETERMINATE_MESSAGE(actual, message) UNITY_TEST_ASSERT_DOUBLE_IS_NOT_DETERMINATE((actual), __LINE__, (message)) 498 | 499 | /* end of UNITY_FRAMEWORK_H */ 500 | #ifdef __cplusplus 501 | } 502 | #endif 503 | #endif 504 | -------------------------------------------------------------------------------- /test/unity/unity_fixture.c: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2010 James Grenning and Contributed to Unity Project 2 | * ========================================== 3 | * Unity Project - A Test Framework for C 4 | * Copyright (c) 2007 Mike Karlesky, Mark VanderVoord, Greg Williams 5 | * [Released under MIT License. Please refer to license.txt for details] 6 | * ========================================== */ 7 | 8 | #include "unity_fixture.h" 9 | #include "unity_internals.h" 10 | #include 11 | 12 | struct UNITY_FIXTURE_T UnityFixture; 13 | 14 | /* If you decide to use the function pointer approach. 15 | * Build with -D UNITY_OUTPUT_CHAR=outputChar and include 16 | * int (*outputChar)(int) = putchar; */ 17 | 18 | #if !defined(UNITY_WEAK_ATTRIBUTE) && !defined(UNITY_WEAK_PRAGMA) 19 | void setUp(void) { /*does nothing*/ } 20 | void tearDown(void) { /*does nothing*/ } 21 | #endif 22 | 23 | static void announceTestRun(unsigned int runNumber) 24 | { 25 | UnityPrint("Unity test run "); 26 | UnityPrintNumberUnsigned(runNumber+1); 27 | UnityPrint(" of "); 28 | UnityPrintNumberUnsigned(UnityFixture.RepeatCount); 29 | UNITY_PRINT_EOL(); 30 | } 31 | 32 | int UnityMain(int argc, const char* argv[], void (*runAllTests)(void)) 33 | { 34 | int result = UnityGetCommandLineOptions(argc, argv); 35 | unsigned int r; 36 | if (result != 0) 37 | return result; 38 | 39 | for (r = 0; r < UnityFixture.RepeatCount; r++) 40 | { 41 | UnityBegin(argv[0]); 42 | announceTestRun(r); 43 | runAllTests(); 44 | if (!UnityFixture.Verbose) UNITY_PRINT_EOL(); 45 | UnityEnd(); 46 | } 47 | 48 | return (int)Unity.TestFailures; 49 | } 50 | 51 | static int selected(const char* filter, const char* name) 52 | { 53 | if (filter == 0) 54 | return 1; 55 | return strstr(name, filter) ? 1 : 0; 56 | } 57 | 58 | static int testSelected(const char* test) 59 | { 60 | return selected(UnityFixture.NameFilter, test); 61 | } 62 | 63 | static int groupSelected(const char* group) 64 | { 65 | return selected(UnityFixture.GroupFilter, group); 66 | } 67 | 68 | void UnityTestRunner(unityfunction* setup, 69 | unityfunction* testBody, 70 | unityfunction* teardown, 71 | const char* printableName, 72 | const char* group, 73 | const char* name, 74 | const char* file, 75 | unsigned int line) 76 | { 77 | if (testSelected(name) && groupSelected(group)) 78 | { 79 | Unity.TestFile = file; 80 | Unity.CurrentTestName = printableName; 81 | Unity.CurrentTestLineNumber = line; 82 | if (!UnityFixture.Verbose) 83 | UNITY_OUTPUT_CHAR('.'); 84 | else 85 | { 86 | UnityPrint(printableName); 87 | #ifndef UNITY_REPEAT_TEST_NAME 88 | Unity.CurrentTestName = NULL; 89 | #endif 90 | } 91 | 92 | Unity.NumberOfTests++; 93 | UnityMalloc_StartTest(); 94 | UnityPointer_Init(); 95 | 96 | if (TEST_PROTECT()) 97 | { 98 | setup(); 99 | testBody(); 100 | } 101 | if (TEST_PROTECT()) 102 | { 103 | teardown(); 104 | } 105 | if (TEST_PROTECT()) 106 | { 107 | UnityPointer_UndoAllSets(); 108 | if (!Unity.CurrentTestFailed) 109 | UnityMalloc_EndTest(); 110 | } 111 | UnityConcludeFixtureTest(); 112 | } 113 | } 114 | 115 | void UnityIgnoreTest(const char* printableName, const char* group, const char* name) 116 | { 117 | if (testSelected(name) && groupSelected(group)) 118 | { 119 | Unity.NumberOfTests++; 120 | Unity.TestIgnores++; 121 | if (!UnityFixture.Verbose) 122 | UNITY_OUTPUT_CHAR('!'); 123 | else 124 | { 125 | UnityPrint(printableName); 126 | UNITY_PRINT_EOL(); 127 | } 128 | } 129 | } 130 | 131 | 132 | /*------------------------------------------------- */ 133 | /* Malloc and free stuff */ 134 | #define MALLOC_DONT_FAIL -1 135 | static int malloc_count; 136 | static int malloc_fail_countdown = MALLOC_DONT_FAIL; 137 | 138 | void UnityMalloc_StartTest(void) 139 | { 140 | malloc_count = 0; 141 | malloc_fail_countdown = MALLOC_DONT_FAIL; 142 | } 143 | 144 | void UnityMalloc_EndTest(void) 145 | { 146 | malloc_fail_countdown = MALLOC_DONT_FAIL; 147 | if (malloc_count != 0) 148 | { 149 | UNITY_TEST_FAIL(Unity.CurrentTestLineNumber, "This test leaks!"); 150 | } 151 | } 152 | 153 | void UnityMalloc_MakeMallocFailAfterCount(int countdown) 154 | { 155 | malloc_fail_countdown = countdown; 156 | } 157 | 158 | /* These definitions are always included from unity_fixture_malloc_overrides.h */ 159 | /* We undef to use them or avoid conflict with per the C standard */ 160 | #undef malloc 161 | #undef free 162 | #undef calloc 163 | #undef realloc 164 | 165 | #ifdef UNITY_EXCLUDE_STDLIB_MALLOC 166 | static unsigned char unity_heap[UNITY_INTERNAL_HEAP_SIZE_BYTES]; 167 | static size_t heap_index; 168 | #else 169 | #include 170 | #endif 171 | 172 | typedef struct GuardBytes 173 | { 174 | size_t size; 175 | size_t guard_space; 176 | } Guard; 177 | 178 | 179 | static const char end[] = "END"; 180 | 181 | void* unity_malloc(size_t size) 182 | { 183 | char* mem; 184 | Guard* guard; 185 | size_t total_size = size + sizeof(Guard) + sizeof(end); 186 | 187 | if (malloc_fail_countdown != MALLOC_DONT_FAIL) 188 | { 189 | if (malloc_fail_countdown == 0) 190 | return NULL; 191 | malloc_fail_countdown--; 192 | } 193 | 194 | if (size == 0) return NULL; 195 | #ifdef UNITY_EXCLUDE_STDLIB_MALLOC 196 | if (heap_index + total_size > UNITY_INTERNAL_HEAP_SIZE_BYTES) 197 | { 198 | guard = NULL; 199 | } 200 | else 201 | { 202 | guard = (Guard*)&unity_heap[heap_index]; 203 | heap_index += total_size; 204 | } 205 | #else 206 | guard = (Guard*)UNITY_FIXTURE_MALLOC(total_size); 207 | #endif 208 | if (guard == NULL) return NULL; 209 | malloc_count++; 210 | guard->size = size; 211 | guard->guard_space = 0; 212 | mem = (char*)&(guard[1]); 213 | memcpy(&mem[size], end, sizeof(end)); 214 | 215 | return (void*)mem; 216 | } 217 | 218 | static int isOverrun(void* mem) 219 | { 220 | Guard* guard = (Guard*)mem; 221 | char* memAsChar = (char*)mem; 222 | guard--; 223 | 224 | return guard->guard_space != 0 || strcmp(&memAsChar[guard->size], end) != 0; 225 | } 226 | 227 | static void release_memory(void* mem) 228 | { 229 | Guard* guard = (Guard*)mem; 230 | guard--; 231 | 232 | malloc_count--; 233 | #ifdef UNITY_EXCLUDE_STDLIB_MALLOC 234 | if (mem == unity_heap + heap_index - guard->size - sizeof(end)) 235 | { 236 | heap_index -= (guard->size + sizeof(Guard) + sizeof(end)); 237 | } 238 | #else 239 | UNITY_FIXTURE_FREE(guard); 240 | #endif 241 | } 242 | 243 | void unity_free(void* mem) 244 | { 245 | int overrun; 246 | 247 | if (mem == NULL) 248 | { 249 | return; 250 | } 251 | 252 | overrun = isOverrun(mem); 253 | release_memory(mem); 254 | if (overrun) 255 | { 256 | UNITY_TEST_FAIL(Unity.CurrentTestLineNumber, "Buffer overrun detected during free()"); 257 | } 258 | } 259 | 260 | void* unity_calloc(size_t num, size_t size) 261 | { 262 | void* mem = unity_malloc(num * size); 263 | if (mem == NULL) return NULL; 264 | memset(mem, 0, num * size); 265 | return mem; 266 | } 267 | 268 | void* unity_realloc(void* oldMem, size_t size) 269 | { 270 | Guard* guard = (Guard*)oldMem; 271 | void* newMem; 272 | 273 | if (oldMem == NULL) return unity_malloc(size); 274 | 275 | guard--; 276 | if (isOverrun(oldMem)) 277 | { 278 | release_memory(oldMem); 279 | UNITY_TEST_FAIL(Unity.CurrentTestLineNumber, "Buffer overrun detected during realloc()"); 280 | } 281 | 282 | if (size == 0) 283 | { 284 | release_memory(oldMem); 285 | return NULL; 286 | } 287 | 288 | if (guard->size >= size) return oldMem; 289 | 290 | #ifdef UNITY_EXCLUDE_STDLIB_MALLOC /* Optimization if memory is expandable */ 291 | if (oldMem == unity_heap + heap_index - guard->size - sizeof(end) && 292 | heap_index + size - guard->size <= UNITY_INTERNAL_HEAP_SIZE_BYTES) 293 | { 294 | release_memory(oldMem); /* Not thread-safe, like unity_heap generally */ 295 | return unity_malloc(size); /* No memcpy since data is in place */ 296 | } 297 | #endif 298 | newMem = unity_malloc(size); 299 | if (newMem == NULL) return NULL; /* Do not release old memory */ 300 | memcpy(newMem, oldMem, guard->size); 301 | release_memory(oldMem); 302 | return newMem; 303 | } 304 | 305 | 306 | /*-------------------------------------------------------- */ 307 | /*Automatic pointer restoration functions */ 308 | struct PointerPair 309 | { 310 | void** pointer; 311 | void* old_value; 312 | }; 313 | 314 | static struct PointerPair pointer_store[UNITY_MAX_POINTERS]; 315 | static int pointer_index = 0; 316 | 317 | void UnityPointer_Init(void) 318 | { 319 | pointer_index = 0; 320 | } 321 | 322 | void UnityPointer_Set(void** pointer, void* newValue, UNITY_LINE_TYPE line) 323 | { 324 | if (pointer_index >= UNITY_MAX_POINTERS) 325 | { 326 | UNITY_TEST_FAIL(line, "Too many pointers set"); 327 | } 328 | else 329 | { 330 | pointer_store[pointer_index].pointer = pointer; 331 | pointer_store[pointer_index].old_value = *pointer; 332 | *pointer = newValue; 333 | pointer_index++; 334 | } 335 | } 336 | 337 | void UnityPointer_UndoAllSets(void) 338 | { 339 | while (pointer_index > 0) 340 | { 341 | pointer_index--; 342 | *(pointer_store[pointer_index].pointer) = 343 | pointer_store[pointer_index].old_value; 344 | } 345 | } 346 | 347 | int UnityGetCommandLineOptions(int argc, const char* argv[]) 348 | { 349 | int i; 350 | UnityFixture.Verbose = 0; 351 | UnityFixture.GroupFilter = 0; 352 | UnityFixture.NameFilter = 0; 353 | UnityFixture.RepeatCount = 1; 354 | 355 | if (argc == 1) 356 | return 0; 357 | 358 | for (i = 1; i < argc; ) 359 | { 360 | if (strcmp(argv[i], "-v") == 0) 361 | { 362 | UnityFixture.Verbose = 1; 363 | i++; 364 | } 365 | else if (strcmp(argv[i], "-g") == 0) 366 | { 367 | i++; 368 | if (i >= argc) 369 | return 1; 370 | UnityFixture.GroupFilter = argv[i]; 371 | i++; 372 | } 373 | else if (strcmp(argv[i], "-n") == 0) 374 | { 375 | i++; 376 | if (i >= argc) 377 | return 1; 378 | UnityFixture.NameFilter = argv[i]; 379 | i++; 380 | } 381 | else if (strcmp(argv[i], "-r") == 0) 382 | { 383 | UnityFixture.RepeatCount = 2; 384 | i++; 385 | if (i < argc) 386 | { 387 | if (*(argv[i]) >= '0' && *(argv[i]) <= '9') 388 | { 389 | unsigned int digit = 0; 390 | UnityFixture.RepeatCount = 0; 391 | while (argv[i][digit] >= '0' && argv[i][digit] <= '9') 392 | { 393 | UnityFixture.RepeatCount *= 10; 394 | UnityFixture.RepeatCount += (unsigned int)argv[i][digit++] - '0'; 395 | } 396 | i++; 397 | } 398 | } 399 | } 400 | else 401 | { 402 | /* ignore unknown parameter */ 403 | i++; 404 | } 405 | } 406 | return 0; 407 | } 408 | 409 | void UnityConcludeFixtureTest(void) 410 | { 411 | if (Unity.CurrentTestIgnored) 412 | { 413 | Unity.TestIgnores++; 414 | UNITY_PRINT_EOL(); 415 | } 416 | else if (!Unity.CurrentTestFailed) 417 | { 418 | if (UnityFixture.Verbose) 419 | { 420 | UnityPrint(" PASS"); 421 | UNITY_PRINT_EOL(); 422 | } 423 | } 424 | else /* Unity.CurrentTestFailed */ 425 | { 426 | Unity.TestFailures++; 427 | UNITY_PRINT_EOL(); 428 | } 429 | 430 | Unity.CurrentTestFailed = 0; 431 | Unity.CurrentTestIgnored = 0; 432 | } 433 | -------------------------------------------------------------------------------- /test/unity/unity_fixture.h: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2010 James Grenning and Contributed to Unity Project 2 | * ========================================== 3 | * Unity Project - A Test Framework for C 4 | * Copyright (c) 2007 Mike Karlesky, Mark VanderVoord, Greg Williams 5 | * [Released under MIT License. Please refer to license.txt for details] 6 | * ========================================== */ 7 | 8 | #ifndef UNITY_FIXTURE_H_ 9 | #define UNITY_FIXTURE_H_ 10 | 11 | #include "unity.h" 12 | #include "unity_internals.h" 13 | #include "unity_fixture_malloc_overrides.h" 14 | #include "unity_fixture_internals.h" 15 | 16 | int UnityMain(int argc, const char* argv[], void (*runAllTests)(void)); 17 | 18 | 19 | #define TEST_GROUP(group)\ 20 | static const char* TEST_GROUP_##group = #group 21 | 22 | #define TEST_SETUP(group) void TEST_##group##_SETUP(void);\ 23 | void TEST_##group##_SETUP(void) 24 | 25 | #define TEST_TEAR_DOWN(group) void TEST_##group##_TEAR_DOWN(void);\ 26 | void TEST_##group##_TEAR_DOWN(void) 27 | 28 | 29 | #define TEST(group, name) \ 30 | void TEST_##group##_##name##_(void);\ 31 | void TEST_##group##_##name##_run(void);\ 32 | void TEST_##group##_##name##_run(void)\ 33 | {\ 34 | UnityTestRunner(TEST_##group##_SETUP,\ 35 | TEST_##group##_##name##_,\ 36 | TEST_##group##_TEAR_DOWN,\ 37 | "TEST(" #group ", " #name ")",\ 38 | TEST_GROUP_##group, #name,\ 39 | __FILE__, __LINE__);\ 40 | }\ 41 | void TEST_##group##_##name##_(void) 42 | 43 | #define IGNORE_TEST(group, name) \ 44 | void TEST_##group##_##name##_(void);\ 45 | void TEST_##group##_##name##_run(void);\ 46 | void TEST_##group##_##name##_run(void)\ 47 | {\ 48 | UnityIgnoreTest("IGNORE_TEST(" #group ", " #name ")", TEST_GROUP_##group, #name);\ 49 | }\ 50 | void TEST_##group##_##name##_(void) 51 | 52 | /* Call this for each test, insider the group runner */ 53 | #define RUN_TEST_CASE(group, name) \ 54 | { void TEST_##group##_##name##_run(void);\ 55 | TEST_##group##_##name##_run(); } 56 | 57 | /* This goes at the bottom of each test file or in a separate c file */ 58 | #define TEST_GROUP_RUNNER(group)\ 59 | void TEST_##group##_GROUP_RUNNER(void);\ 60 | void TEST_##group##_GROUP_RUNNER(void) 61 | 62 | /* Call this from main */ 63 | #define RUN_TEST_GROUP(group)\ 64 | { void TEST_##group##_GROUP_RUNNER(void);\ 65 | TEST_##group##_GROUP_RUNNER(); } 66 | 67 | /* CppUTest Compatibility Macros */ 68 | #ifndef UNITY_EXCLUDE_CPPUTEST_ASSERTS 69 | /* Sets a pointer and automatically restores it to its old value after teardown */ 70 | #define UT_PTR_SET(ptr, newPointerValue) UnityPointer_Set((void**)&(ptr), (void*)(newPointerValue), __LINE__) 71 | #define TEST_ASSERT_POINTERS_EQUAL(expected, actual) TEST_ASSERT_EQUAL_PTR((expected), (actual)) 72 | #define TEST_ASSERT_BYTES_EQUAL(expected, actual) TEST_ASSERT_EQUAL_HEX8(0xff & (expected), 0xff & (actual)) 73 | #define FAIL(message) TEST_FAIL_MESSAGE((message)) 74 | #define CHECK(condition) TEST_ASSERT_TRUE((condition)) 75 | #define LONGS_EQUAL(expected, actual) TEST_ASSERT_EQUAL_INT((expected), (actual)) 76 | #define STRCMP_EQUAL(expected, actual) TEST_ASSERT_EQUAL_STRING((expected), (actual)) 77 | #define DOUBLES_EQUAL(expected, actual, delta) TEST_ASSERT_DOUBLE_WITHIN((delta), (expected), (actual)) 78 | #endif 79 | 80 | /* You must compile with malloc replacement, as defined in unity_fixture_malloc_overrides.h */ 81 | void UnityMalloc_MakeMallocFailAfterCount(int countdown); 82 | 83 | #endif /* UNITY_FIXTURE_H_ */ 84 | -------------------------------------------------------------------------------- /test/unity/unity_fixture_internals.h: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2010 James Grenning and Contributed to Unity Project 2 | * ========================================== 3 | * Unity Project - A Test Framework for C 4 | * Copyright (c) 2007 Mike Karlesky, Mark VanderVoord, Greg Williams 5 | * [Released under MIT License. Please refer to license.txt for details] 6 | * ========================================== */ 7 | 8 | #ifndef UNITY_FIXTURE_INTERNALS_H_ 9 | #define UNITY_FIXTURE_INTERNALS_H_ 10 | 11 | #ifdef __cplusplus 12 | extern "C" 13 | { 14 | #endif 15 | 16 | struct UNITY_FIXTURE_T 17 | { 18 | int Verbose; 19 | unsigned int RepeatCount; 20 | const char* NameFilter; 21 | const char* GroupFilter; 22 | }; 23 | extern struct UNITY_FIXTURE_T UnityFixture; 24 | 25 | typedef void unityfunction(void); 26 | void UnityTestRunner(unityfunction* setup, 27 | unityfunction* testBody, 28 | unityfunction* teardown, 29 | const char* printableName, 30 | const char* group, 31 | const char* name, 32 | const char* file, unsigned int line); 33 | 34 | void UnityIgnoreTest(const char* printableName, const char* group, const char* name); 35 | void UnityMalloc_StartTest(void); 36 | void UnityMalloc_EndTest(void); 37 | int UnityGetCommandLineOptions(int argc, const char* argv[]); 38 | void UnityConcludeFixtureTest(void); 39 | 40 | void UnityPointer_Set(void** pointer, void* newValue, UNITY_LINE_TYPE line); 41 | void UnityPointer_UndoAllSets(void); 42 | void UnityPointer_Init(void); 43 | #ifndef UNITY_MAX_POINTERS 44 | #define UNITY_MAX_POINTERS 5 45 | #endif 46 | 47 | #ifdef __cplusplus 48 | } 49 | #endif 50 | 51 | #endif /* UNITY_FIXTURE_INTERNALS_H_ */ 52 | -------------------------------------------------------------------------------- /test/unity/unity_fixture_malloc_overrides.h: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2010 James Grenning and Contributed to Unity Project 2 | * ========================================== 3 | * Unity Project - A Test Framework for C 4 | * Copyright (c) 2007 Mike Karlesky, Mark VanderVoord, Greg Williams 5 | * [Released under MIT License. Please refer to license.txt for details] 6 | * ========================================== */ 7 | 8 | #ifndef UNITY_FIXTURE_MALLOC_OVERRIDES_H_ 9 | #define UNITY_FIXTURE_MALLOC_OVERRIDES_H_ 10 | 11 | #include 12 | 13 | #ifdef UNITY_EXCLUDE_STDLIB_MALLOC 14 | /* Define this macro to remove the use of stdlib.h, malloc, and free. 15 | * Many embedded systems do not have a heap or malloc/free by default. 16 | * This internal unity_malloc() provides allocated memory deterministically from 17 | * the end of an array only, unity_free() only releases from end-of-array, 18 | * blocks are not coalesced, and memory not freed in LIFO order is stranded. */ 19 | #ifndef UNITY_INTERNAL_HEAP_SIZE_BYTES 20 | #define UNITY_INTERNAL_HEAP_SIZE_BYTES 256 21 | #endif 22 | #endif 23 | 24 | /* These functions are used by the Unity Fixture to allocate and release memory 25 | * on the heap and can be overridden with platform-specific implementations. 26 | * For example, when using FreeRTOS UNITY_FIXTURE_MALLOC becomes pvPortMalloc() 27 | * and UNITY_FIXTURE_FREE becomes vPortFree(). */ 28 | #if !defined(UNITY_FIXTURE_MALLOC) || !defined(UNITY_FIXTURE_FREE) 29 | #include 30 | #define UNITY_FIXTURE_MALLOC(size) malloc(size) 31 | #define UNITY_FIXTURE_FREE(ptr) free(ptr) 32 | #else 33 | extern void* UNITY_FIXTURE_MALLOC(size_t size); 34 | extern void UNITY_FIXTURE_FREE(void* ptr); 35 | #endif 36 | 37 | #define malloc unity_malloc 38 | #define calloc unity_calloc 39 | #define realloc unity_realloc 40 | #define free unity_free 41 | 42 | void* unity_malloc(size_t size); 43 | void* unity_calloc(size_t num, size_t size); 44 | void* unity_realloc(void * oldMem, size_t size); 45 | void unity_free(void * mem); 46 | 47 | #endif /* UNITY_FIXTURE_MALLOC_OVERRIDES_H_ */ 48 | --------------------------------------------------------------------------------