diff options
| author | Charles <sircharlesaze@gmail.com> | 2020-01-31 08:08:59 +0100 |
|---|---|---|
| committer | Charles <sircharlesaze@gmail.com> | 2020-01-31 08:48:42 +0100 |
| commit | 9db52bc5ef545a3fa9973002e9a28a2ece68d029 (patch) | |
| tree | 0a1f36d989c6c3cb74e3bc5d5997c6a4c3f058b9 | |
| parent | 3b884e3836c70b1a19eb7778308fadbc608b0384 (diff) | |
| download | libft-9db52bc5ef545a3fa9973002e9a28a2ece68d029.tar.gz libft-9db52bc5ef545a3fa9973002e9a28a2ece68d029.tar.bz2 libft-9db52bc5ef545a3fa9973002e9a28a2ece68d029.zip | |
Setup unit test with unity
| -rw-r--r-- | .gitignore | 1 | ||||
| -rw-r--r-- | .travis.yml | 2 | ||||
| -rw-r--r-- | Makefile | 34 | ||||
| -rwxr-xr-x | script/find_src.sh | 2 | ||||
| -rw-r--r-- | script/generate_rendu_makefile.sh | 5 | ||||
| -rw-r--r-- | script/template.makefile | 38 | ||||
| -rw-r--r-- | test/Makefile | 48 | ||||
| -rw-r--r-- | test/include/libft_test.h | 8 | ||||
| -rwxr-xr-x | test/libft_test | bin | 0 -> 34012 bytes | |||
| -rw-r--r-- | test/src/runner/test_ft_strlen_runner.c | 6 | ||||
| -rw-r--r-- | test/src/str/test_ft_strlen.c | 14 | ||||
| -rw-r--r-- | vendor/_unity/LICENSE.txt | 21 | ||||
| -rw-r--r-- | vendor/_unity/Makefile | 41 | ||||
| -rw-r--r-- | vendor/_unity/README.md | 191 | ||||
| -rw-r--r-- | vendor/_unity/include/unity.h | 617 | ||||
| -rw-r--r-- | vendor/_unity/include/unity_fixture.h | 83 | ||||
| -rw-r--r-- | vendor/_unity/include/unity_fixture_internals.h | 50 | ||||
| -rw-r--r-- | vendor/_unity/include/unity_internals.h | 1007 | ||||
| -rw-r--r-- | vendor/_unity/include/unity_memory.h | 60 | ||||
| -rw-r--r-- | vendor/_unity/src/unity.c | 2088 | ||||
| -rw-r--r-- | vendor/_unity/src/unity_fixture.c | 310 | ||||
| -rw-r--r-- | vendor/_unity/src/unity_memory.c | 202 |
22 files changed, 4816 insertions, 12 deletions
@@ -6,3 +6,4 @@ a.out test_libft main.c obj/* +rendu.makefile diff --git a/.travis.yml b/.travis.yml index 49462fd..94e4879 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,4 +1,4 @@ language: c compiler: gcc -script: make all +script: make all && make test @@ -6,21 +6,24 @@ # By: cacharle <marvin@42.fr> +#+ +:+ +#+ # # +#+#+#+#+#+ +#+ # # Created: 2019/10/08 15:45:53 by cacharle #+# #+# # -# Updated: 2020/01/17 10:51:24 by cacharle ### ########.fr # +# Updated: 2020/01/31 08:26:39 by cacharle ### ########.fr # # # # **************************************************************************** # LIB = ar rcs RM = rm -f +NORM = norminette +MAKE = make MAKE_ARGS = --no-print-directory -CC = gcc -CCFLAGS = -I$(INCLUDE_DIR) -Wall -Wextra -Werror - SRC_DIR = src INCLUDE_DIR = include OBJ_DIR = obj SCRIPT_DIR = script +TEST_DIR = test + +CC = gcc +CCFLAGS = -I$(INCLUDE_DIR) -Wall -Wextra -Werror IGNORE_FILE = .libftignore IGNORE_DEFAULT = ft_printf @@ -30,19 +33,30 @@ NAME = libft.a SRC = $(shell sh $(SCRIPT_DIR)/find_src.sh $(IGNORE_FILE)) OBJ = $(SRC:$(SRC_DIR)/%.c=$(OBJ_DIR)/%.o) -HEADER = $(shell find $(INCLUDE_DIR) -name "*.h") +INCLUDE = $(shell find $(INCLUDE_DIR) -name "*.h") all: prebuild $(NAME) +.PHONY: test +test: all + @echo "Testing" + @$(MAKE) $(MAKE_ARGS) -C $(TEST_DIR) run + +norm: + @if [ `command -v $(NORM)` ]; \ + then echo "Running norminette"; \ + $(NORM) $(SRC) $(INCLUDE); \ + else echo "$(NORM) not installed"; fi + prebuild: - @for dir in $$(find $(SRC_DIR)/* $(FIND_ARGS) -type d | \ - sed 's_$(SRC_DIR)/_$(OBJ_DIR)/_g'); \ - do \ - if [ ! -d "$$dir" ]; then \ + @for dir in $$(find $(SRC_DIR)/* $(FIND_ARGS) -type d | \ + sed 's_$(SRC_DIR)/_$(OBJ_DIR)/_g'); \ + do \ + if [ ! -d "$$dir" ]; then \ mkdir -p $$dir; echo "Making build dir: $$dir"; fi \ done -$(NAME): $(OBJ) $(HEADER) +$(NAME): $(OBJ) $(INCLUDE) @echo "Linking: $@" @$(LIB) $@ $(OBJ) diff --git a/script/find_src.sh b/script/find_src.sh index 1d645a1..3773fc9 100755 --- a/script/find_src.sh +++ b/script/find_src.sh @@ -14,7 +14,7 @@ fi SRC_DIR=src -IGNORE_FIND_ARGS=`sed 's/.*/-not -path "&"/' $IGNORE_FILE | paste -sd " "` +IGNORE_FIND_ARGS=`sed 's/.*/-not -path "&"/' $IGNORE_FILE | paste -sd " " -` IGNORE_FIND_ARGS="$IGNORE_FIND_ARGS -not -name \"*inter*\"" sh -c "find $SRC_DIR $IGNORE_FIND_ARGS -name \"*.c\"" diff --git a/script/generate_rendu_makefile.sh b/script/generate_rendu_makefile.sh new file mode 100644 index 0000000..00a9e81 --- /dev/null +++ b/script/generate_rendu_makefile.sh @@ -0,0 +1,5 @@ +#!bin/sh + +SRC=`sh script/find_src.sh .libftignore` + +sed 's:\#INSERTSRC:'$SRC':g' template.makefile > rendu.makefile diff --git a/script/template.makefile b/script/template.makefile new file mode 100644 index 0000000..b0902ec --- /dev/null +++ b/script/template.makefile @@ -0,0 +1,38 @@ +# **************************************************************************** # +# # +# ::: :::::::: # +# Makefile :+: :+: :+: # +# +:+ +:+ +:+ # +# By: cacharle <marvin@42.fr> +#+ +:+ +#+ # +# +#+#+#+#+#+ +#+ # +# Created: 2019/10/08 15:45:53 by cacharle #+# #+# # +# Updated: 2020/01/31 06:51:18 by cacharle ### ########.fr # +# # +# **************************************************************************** # + +RM = rm -f +LIB = ar rcs + +CC = gcc +CCFLAGS = -Iinclude -Wall -Wextra -Werror + +#INSERTSRC + +OBJ = $(SRC:.c=.o) +NAME = libft.a + +all: $(NAME) + +$(NAME): $(OBJ) + $(LIB) $@ $(OBJ) + +%.o: %.c + $(CC) $(CCFLAGS) -c -o $@ $< + +clean: + $(RM) -r $(OBJ_DIR) + +fclean: clean + $(RM) $(NAME) + +re: fclean all diff --git a/test/Makefile b/test/Makefile new file mode 100644 index 0000000..4d84321 --- /dev/null +++ b/test/Makefile @@ -0,0 +1,48 @@ +MAKE = make +MAKE_ARGS = --no-print-directory + +UNITY_DIR = ../vendor/_unity +LIBFT_DIR = .. + +SRC_DIR = src +INCLUDE_DIR = include + +CC = gcc +CCFLAGS = -I$(INCLUDE_DIR) -I$(UNITY_DIR)/include -I$(LIBFT_DIR)/include -Wall -Wextra -Werror +LDFLAGS = -L$(UNITY_DIR) -lunity -L$(LIBFT_DIR) -lft + +NAME = libft_test + +SRC = $(shell find $(SRC_DIR) -type f -name "*.c") +OBJ = $(SRC:.c=.o) + + +all: unity_all $(NAME) + +run: all + @echo "Test: Running" + @./$(NAME) + +$(NAME): $(OBJ) + @echo "Test: Linking: $@" + @$(CC) -o $@ $^ $(LDFLAGS) + +%.o: %.c + @echo "Test: Compiling: $@" + @$(CC) $(CCFLAGS) -c -o $@ $< + +clean: unity_fclean + @echo "Test: Removing object" + @$(RM) $(OBJ) + +fclean: + @echo "Test: Removing executable" + @$(RM) $(NAME) + +re: fclean all + +unity_all: + @$(MAKE) $(MAKE_ARGS) -s -C $(UNITY_DIR) all + +unity_fclean: + @$(MAKE) $(MAKE_ARGS) -s -C $(UNITY_DIR) fclean diff --git a/test/include/libft_test.h b/test/include/libft_test.h new file mode 100644 index 0000000..1c5ebb5 --- /dev/null +++ b/test/include/libft_test.h @@ -0,0 +1,8 @@ +#ifndef LIBFT_TEST_H +# define LIBFT_TEST_H + +# include "unity.h" +# include "unity_fixture.h" +# include "libft.h" + +#endif diff --git a/test/libft_test b/test/libft_test Binary files differnew file mode 100755 index 0000000..13cbab2 --- /dev/null +++ b/test/libft_test diff --git a/test/src/runner/test_ft_strlen_runner.c b/test/src/runner/test_ft_strlen_runner.c new file mode 100644 index 0000000..368c033 --- /dev/null +++ b/test/src/runner/test_ft_strlen_runner.c @@ -0,0 +1,6 @@ +#include "libft_test.h" + +TEST_GROUP_RUNNER(ft_strlen) +{ + RUN_TEST_CASE(ft_strlen, yo); +} diff --git a/test/src/str/test_ft_strlen.c b/test/src/str/test_ft_strlen.c new file mode 100644 index 0000000..1e4e1c4 --- /dev/null +++ b/test/src/str/test_ft_strlen.c @@ -0,0 +1,14 @@ +#include "libft_test.h" + +TEST_GROUP(ft_strlen); + +TEST_SETUP(ft_strlen) +{} + +TEST_TEAR_DOWN(ft_strlen) +{} + +TEST(ft_strlen, yo) +{ + TEST_ASSERT_EQUAL(0, 0); +} diff --git a/vendor/_unity/LICENSE.txt b/vendor/_unity/LICENSE.txt new file mode 100644 index 0000000..d66fba5 --- /dev/null +++ b/vendor/_unity/LICENSE.txt @@ -0,0 +1,21 @@ +The MIT License (MIT) + +Copyright (c) <year> 2007-14 Mike Karlesky, Mark VanderVoord, Greg Williams + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. diff --git a/vendor/_unity/Makefile b/vendor/_unity/Makefile new file mode 100644 index 0000000..d9700ea --- /dev/null +++ b/vendor/_unity/Makefile @@ -0,0 +1,41 @@ +# **************************************************************************** # +# # +# ::: :::::::: # +# Makefile :+: :+: :+: # +# +:+ +:+ +:+ # +# By: cacharle <marvin@42.fr> +#+ +:+ +#+ # +# +#+#+#+#+#+ +#+ # +# Created: 2020/01/31 07:27:12 by cacharle #+# #+# # +# Updated: 2020/01/31 08:39:24 by cacharle ### ########.fr # +# # +# **************************************************************************** # + +CC = gcc +CCFLAGS = -Iinclude -Wall -Wextra -Werror + +NAME = libunity.a + +INCLUDE = $(shell find include -type f -name "*.h") +SRC = $(shell find src -type f -name "*.c") +OBJ = $(SRC:.c=.o) + +.PHONY: all +all: $(NAME) + +$(NAME): $(OBJ) + @echo "Unity: Linking: $@" + @ar rcs $@ $^ + +%.o: %.c $(INCLUDE) + @echo "Unity: Compiling: $@" + @$(CC) $(CCFLAGS) -c -o $@ $< + +clean: + @echo "Unity: Removing objects" + @rm -f $(OBJ) + +fclean: clean + @echo "Unity: Removing: $(NAME)" + @rm -f $(NAME) + +re: fclean all diff --git a/vendor/_unity/README.md b/vendor/_unity/README.md new file mode 100644 index 0000000..e6e7ea2 --- /dev/null +++ b/vendor/_unity/README.md @@ -0,0 +1,191 @@ +Unity Test API +============== + +[](https://travis-ci.org/ThrowTheSwitch/Unity) +__Copyright (c) 2007 - 2020 Unity Project by Mike Karlesky, Mark VanderVoord, and Greg Williams__ + +Getting Started +=============== +The [docs](docs/) folder contains a [getting started guide](docs/UnityGettingStartedGuide.md) +and much more tips about using Unity. + +Unity Assertion Summary +======================= +For the full list, see [UnityAssertionsReference.md](docs/UnityAssertionsReference.md). + +Basic Validity Tests +-------------------- + + TEST_ASSERT_TRUE(condition) + +Evaluates whatever code is in condition and fails if it evaluates to false + + TEST_ASSERT_FALSE(condition) + +Evaluates whatever code is in condition and fails if it evaluates to true + + TEST_ASSERT(condition) + +Another way of calling `TEST_ASSERT_TRUE` + + TEST_ASSERT_UNLESS(condition) + +Another way of calling `TEST_ASSERT_FALSE` + + TEST_FAIL() + TEST_FAIL_MESSAGE(message) + +This test is automatically marked as a failure. The message is output stating why. + +Numerical Assertions: Integers +------------------------------ + + TEST_ASSERT_EQUAL_INT(expected, actual) + TEST_ASSERT_EQUAL_INT8(expected, actual) + TEST_ASSERT_EQUAL_INT16(expected, actual) + TEST_ASSERT_EQUAL_INT32(expected, actual) + TEST_ASSERT_EQUAL_INT64(expected, actual) + +Compare two integers for equality and display errors as signed integers. A cast will be performed +to your natural integer size so often this can just be used. When you need to specify the exact size, +like when comparing arrays, you can use a specific version: + + TEST_ASSERT_EQUAL_UINT(expected, actual) + TEST_ASSERT_EQUAL_UINT8(expected, actual) + TEST_ASSERT_EQUAL_UINT16(expected, actual) + TEST_ASSERT_EQUAL_UINT32(expected, actual) + TEST_ASSERT_EQUAL_UINT64(expected, actual) + +Compare two integers for equality and display errors as unsigned integers. Like INT, there are +variants for different sizes also. + + TEST_ASSERT_EQUAL_HEX(expected, actual) + TEST_ASSERT_EQUAL_HEX8(expected, actual) + TEST_ASSERT_EQUAL_HEX16(expected, actual) + TEST_ASSERT_EQUAL_HEX32(expected, actual) + TEST_ASSERT_EQUAL_HEX64(expected, actual) + +Compares two integers for equality and display errors as hexadecimal. Like the other integer comparisons, +you can specify the size... here the size will also effect how many nibbles are shown (for example, `HEX16` +will show 4 nibbles). + + TEST_ASSERT_EQUAL(expected, actual) + +Another way of calling TEST_ASSERT_EQUAL_INT + + TEST_ASSERT_INT_WITHIN(delta, expected, actual) + +Asserts that the actual value is within plus or minus delta of the expected value. This also comes in +size specific variants. + + + TEST_ASSERT_GREATER_THAN(threshold, actual) + +Asserts that the actual value is greater than the threshold. This also comes in size specific variants. + + + TEST_ASSERT_LESS_THAN(threshold, actual) + +Asserts that the actual value is less than the threshold. This also comes in size specific variants. + + +Arrays +------ + + _ARRAY + +You can append `_ARRAY` to any of these macros to make an array comparison of that type. Here you will +need to care a bit more about the actual size of the value being checked. You will also specify an +additional argument which is the number of elements to compare. For example: + + TEST_ASSERT_EQUAL_HEX8_ARRAY(expected, actual, elements) + + _EACH_EQUAL + +Another array comparison option is to check that EVERY element of an array is equal to a single expected +value. You do this by specifying the EACH_EQUAL macro. For example: + + TEST_ASSERT_EACH_EQUAL_INT32(expected, actual, elements) + +Numerical Assertions: Bitwise +----------------------------- + + TEST_ASSERT_BITS(mask, expected, actual) + +Use an integer mask to specify which bits should be compared between two other integers. High bits in the mask are compared, low bits ignored. + + TEST_ASSERT_BITS_HIGH(mask, actual) + +Use an integer mask to specify which bits should be inspected to determine if they are all set high. High bits in the mask are compared, low bits ignored. + + TEST_ASSERT_BITS_LOW(mask, actual) + +Use an integer mask to specify which bits should be inspected to determine if they are all set low. High bits in the mask are compared, low bits ignored. + + TEST_ASSERT_BIT_HIGH(bit, actual) + +Test a single bit and verify that it is high. The bit is specified 0-31 for a 32-bit integer. + + TEST_ASSERT_BIT_LOW(bit, actual) + +Test a single bit and verify that it is low. The bit is specified 0-31 for a 32-bit integer. + +Numerical Assertions: Floats +---------------------------- + + TEST_ASSERT_FLOAT_WITHIN(delta, expected, actual) + +Asserts that the actual value is within plus or minus delta of the expected value. + + TEST_ASSERT_EQUAL_FLOAT(expected, actual) + TEST_ASSERT_EQUAL_DOUBLE(expected, actual) + +Asserts that two floating point values are "equal" within a small % delta of the expected value. + +String Assertions +----------------- + + TEST_ASSERT_EQUAL_STRING(expected, actual) + +Compare two null-terminate strings. Fail if any character is different or if the lengths are different. + + TEST_ASSERT_EQUAL_STRING_LEN(expected, actual, len) + +Compare two strings. Fail if any character is different, stop comparing after len characters. + + TEST_ASSERT_EQUAL_STRING_MESSAGE(expected, actual, message) + +Compare two null-terminate strings. Fail if any character is different or if the lengths are different. Output a custom message on failure. + + TEST_ASSERT_EQUAL_STRING_LEN_MESSAGE(expected, actual, len, message) + +Compare two strings. Fail if any character is different, stop comparing after len characters. Output a custom message on failure. + +Pointer Assertions +------------------ + +Most pointer operations can be performed by simply using the integer comparisons above. However, a couple of special cases are added for clarity. + + TEST_ASSERT_NULL(pointer) + +Fails if the pointer is not equal to NULL + + TEST_ASSERT_NOT_NULL(pointer) + +Fails if the pointer is equal to NULL + +Memory Assertions +----------------- + + TEST_ASSERT_EQUAL_MEMORY(expected, actual, len) + +Compare two blocks of memory. This is a good generic assertion for types that can't be coerced into acting like +standard types... but since it's a memory compare, you have to be careful that your data types are packed. + +\_MESSAGE +--------- + +you can append \_MESSAGE to any of the macros to make them take an additional argument. This argument +is a string that will be printed at the end of the failure strings. This is useful for specifying more +information about the problem. + diff --git a/vendor/_unity/include/unity.h b/vendor/_unity/include/unity.h new file mode 100644 index 0000000..34d7f93 --- /dev/null +++ b/vendor/_unity/include/unity.h @@ -0,0 +1,617 @@ +/* ========================================== + Unity Project - A Test Framework for C + Copyright (c) 2007-19 Mike Karlesky, Mark VanderVoord, Greg Williams + [Released under MIT License. Please refer to license.txt for details] +========================================== */ + +#ifndef UNITY_FRAMEWORK_H +#define UNITY_FRAMEWORK_H +#define UNITY + +#define UNITY_VERSION_MAJOR 2 +#define UNITY_VERSION_MINOR 5 +#define UNITY_VERSION_BUILD 0 +#define UNITY_VERSION ((UNITY_VERSION_MAJOR << 16) | (UNITY_VERSION_MINOR << 8) | UNITY_VERSION_BUILD) + +#ifdef __cplusplus +extern "C" +{ +#endif + +#include "unity_internals.h" + +/*------------------------------------------------------- + * Test Setup / Teardown + *-------------------------------------------------------*/ + +/* These functions are intended to be called before and after each test. + * If using unity directly, these will need to be provided for each test + * executable built. If you are using the test runner generator and/or + * Ceedling, these are optional. */ +void setUp(void); +void tearDown(void); + +/* These functions are intended to be called at the beginning and end of an + * entire test suite. suiteTearDown() is passed the number of tests that + * failed, and its return value becomes the exit code of main(). If using + * Unity directly, you're in charge of calling these if they are desired. + * If using Ceedling or the test runner generator, these will be called + * automatically if they exist. */ +void suiteSetUp(void); +int suiteTearDown(int num_failures); + +/*------------------------------------------------------- + * Test Reset and Verify + *-------------------------------------------------------*/ + +/* These functions are intended to be called before during tests in order + * to support complex test loops, etc. Both are NOT built into Unity. Instead + * the test runner generator will create them. resetTest will run teardown and + * setup again, verifying any end-of-test needs between. verifyTest will only + * run the verification. */ +void resetTest(void); +void verifyTest(void); + +/*------------------------------------------------------- + * Configuration Options + *------------------------------------------------------- + * 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. + + * Integers/longs/pointers + * - Unity attempts to automatically discover your integer sizes + * - define UNITY_EXCLUDE_STDINT_H to stop attempting to look in <stdint.h> + * - define UNITY_EXCLUDE_LIMITS_H to stop attempting to look in <limits.h> + * - If you cannot use the automatic methods above, you can force Unity by using these options: + * - define UNITY_SUPPORT_64 + * - set UNITY_INT_WIDTH + * - set UNITY_LONG_WIDTH + * - set UNITY_POINTER_WIDTH + + * Floats + * - define UNITY_EXCLUDE_FLOAT to disallow floating point comparisons + * - define UNITY_FLOAT_PRECISION to specify the precision to use when doing TEST_ASSERT_EQUAL_FLOAT + * - define UNITY_FLOAT_TYPE to specify doubles instead of single precision floats + * - define UNITY_INCLUDE_DOUBLE to allow double floating point comparisons + * - define UNITY_EXCLUDE_DOUBLE to disallow double floating point comparisons (default) + * - define UNITY_DOUBLE_PRECISION to specify the precision to use when doing TEST_ASSERT_EQUAL_DOUBLE + * - define UNITY_DOUBLE_TYPE to specify something other than double + * - define UNITY_EXCLUDE_FLOAT_PRINT to trim binary size, won't print floating point values in errors + + * Output + * - by default, Unity prints to standard out with putchar. define UNITY_OUTPUT_CHAR(a) with a different function if desired + * - define UNITY_DIFFERENTIATE_FINAL_FAIL to print FAILED (vs. FAIL) at test end summary - for automated search for failure + + * Optimization + * - by default, line numbers are stored in unsigned shorts. Define UNITY_LINE_TYPE with a different type if your files are huge + * - 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. + + * Test Cases + * - define UNITY_SUPPORT_TEST_CASES to include the TEST_CASE macro, though really it's mostly about the runner generator script + + * Parameterized Tests + * - you'll want to create a define of TEST_CASE(...) which basically evaluates to nothing + + * Tests with Arguments + * - you'll want to define UNITY_USE_COMMAND_LINE_ARGS if you have the test runner passing arguments to Unity + + *------------------------------------------------------- + * Basic Fail and Ignore + *-------------------------------------------------------*/ + +#define TEST_FAIL_MESSAGE(message) UNITY_TEST_FAIL(__LINE__, (message)) +#define TEST_FAIL() UNITY_TEST_FAIL(__LINE__, NULL) +#define TEST_IGNORE_MESSAGE(message) UNITY_TEST_IGNORE(__LINE__, (message)) +#define TEST_IGNORE() UNITY_TEST_IGNORE(__LINE__, NULL) +#define TEST_MESSAGE(message) UnityMessage((message), __LINE__) +#define TEST_ONLY() + +/* It is not necessary for you to call PASS. A PASS condition is assumed if nothing fails. + * This method allows you to abort a test immediately with a PASS state, ignoring the remainder of the test. */ +#define TEST_PASS() TEST_ABORT() +#define TEST_PASS_MESSAGE(message) do { UnityMessage((message), __LINE__); TEST_ABORT(); } while(0) + +/* This macro does nothing, but it is useful for build tools (like Ceedling) to make use of this to figure out + * which files should be linked to in order to perform a test. Use it like TEST_FILE("sandwiches.c") */ +#define TEST_FILE(a) + +/*------------------------------------------------------- + * Test Asserts (simple) + *-------------------------------------------------------*/ + +/* Boolean */ +#define TEST_ASSERT(condition) UNITY_TEST_ASSERT( (condition), __LINE__, " Expression Evaluated To FALSE") +#define TEST_ASSERT_TRUE(condition) UNITY_TEST_ASSERT( (condition), __LINE__, " Expected TRUE Was FALSE") +#define TEST_ASSERT_UNLESS(condition) UNITY_TEST_ASSERT( !(condition), __LINE__, " Expression Evaluated To TRUE") +#define TEST_ASSERT_FALSE(condition) UNITY_TEST_ASSERT( !(condition), __LINE__, " Expected FALSE Was TRUE") +#define TEST_ASSERT_NULL(pointer) UNITY_TEST_ASSERT_NULL( (pointer), __LINE__, " Expected NULL") +#define TEST_ASSERT_NOT_NULL(pointer) UNITY_TEST_ASSERT_NOT_NULL((pointer), __LINE__, " Expected Non-NULL") + +/* Integers (of all sizes) */ +#define TEST_ASSERT_EQUAL_INT(expected, actual) UNITY_TEST_ASSERT_EQUAL_INT((expected), (actual), __LINE__, NULL) +#define TEST_ASSERT_EQUAL_INT8(expected, actual) UNITY_TEST_ASSERT_EQUAL_INT8((expected), (actual), __LINE__, NULL) +#define TEST_ASSERT_EQUAL_INT16(expected, actual) UNITY_TEST_ASSERT_EQUAL_INT16((expected), (actual), __LINE__, NULL) +#define TEST_ASSERT_EQUAL_INT32(expected, actual) UNITY_TEST_ASSERT_EQUAL_INT32((expected), (actual), __LINE__, NULL) +#define TEST_ASSERT_EQUAL_INT64(expected, actual) UNITY_TEST_ASSERT_EQUAL_INT64((expected), (actual), __LINE__, NULL) +#define TEST_ASSERT_EQUAL_UINT(expected, actual) UNITY_TEST_ASSERT_EQUAL_UINT( (expected), (actual), __LINE__, NULL) +#define TEST_ASSERT_EQUAL_UINT8(expected, actual) UNITY_TEST_ASSERT_EQUAL_UINT8( (expected), (actual), __LINE__, NULL) +#define TEST_ASSERT_EQUAL_UINT16(expected, actual) UNITY_TEST_ASSERT_EQUAL_UINT16( (expected), (actual), __LINE__, NULL) +#define TEST_ASSERT_EQUAL_UINT32(expected, actual) UNITY_TEST_ASSERT_EQUAL_UINT32( (expected), (actual), __LINE__, NULL) +#define TEST_ASSERT_EQUAL_UINT64(expected, actual) UNITY_TEST_ASSERT_EQUAL_UINT64( (expected), (actual), __LINE__, NULL) +#define TEST_ASSERT_EQUAL_size_t(expected, actual) UNITY_TEST_ASSERT_EQUAL_UINT((expected), (actual), __LINE__, NULL) +#define TEST_ASSERT_EQUAL_HEX(expected, actual) UNITY_TEST_ASSERT_EQUAL_HEX32((expected), (actual), __LINE__, NULL) +#define TEST_ASSERT_EQUAL_HEX8(expected, actual) UNITY_TEST_ASSERT_EQUAL_HEX8( (expected), (actual), __LINE__, NULL) +#define TEST_ASSERT_EQUAL_HEX16(expected, actual) UNITY_TEST_ASSERT_EQUAL_HEX16((expected), (actual), __LINE__, NULL) +#define TEST_ASSERT_EQUAL_HEX32(expected, actual) UNITY_TEST_ASSERT_EQUAL_HEX32((expected), (actual), __LINE__, NULL) +#define TEST_ASSERT_EQUAL_HEX64(expected, actual) UNITY_TEST_ASSERT_EQUAL_HEX64((expected), (actual), __LINE__, NULL) +#define TEST_ASSERT_EQUAL_CHAR(expected, actual) UNITY_TEST_ASSERT_EQUAL_CHAR((expected), (actual), __LINE__, NULL) +#define TEST_ASSERT_BITS(mask, expected, actual) UNITY_TEST_ASSERT_BITS((mask), (expected), (actual), __LINE__, NULL) +#define TEST_ASSERT_BITS_HIGH(mask, actual) UNITY_TEST_ASSERT_BITS((mask), (UNITY_UINT32)(-1), (actual), __LINE__, NULL) +#define TEST_ASSERT_BITS_LOW(mask, actual) UNITY_TEST_ASSERT_BITS((mask), (UNITY_UINT32)(0), (actual), __LINE__, NULL) +#define TEST_ASSERT_BIT_HIGH(bit, actual) UNITY_TEST_ASSERT_BITS(((UNITY_UINT32)1 << (bit)), (UNITY_UINT32)(-1), (actual), __LINE__, NULL) +#define TEST_ASSERT_BIT_LOW(bit, actual) UNITY_TEST_ASSERT_BITS(((UNITY_UINT32)1 << (bit)), (UNITY_UINT32)(0), (actual), __LINE__, NULL) + +/* Integer Greater Than/ Less Than (of all sizes) */ +#define TEST_ASSERT_GREATER_THAN(threshold, actual) UNITY_TEST_ASSERT_GREATER_THAN_INT((threshold), (actual), __LINE__, NULL) +#define TEST_ASSERT_GREATER_THAN_INT(threshold, actual) UNITY_TEST_ASSERT_GREATER_THAN_INT((threshold), (actual), __LINE__, NULL) +#define TEST_ASSERT_GREATER_THAN_INT8(threshold, actual) UNITY_TEST_ASSERT_GREATER_THAN_INT8((threshold), (actual), __LINE__, NULL) +#define TEST_ASSERT_GREATER_THAN_INT16(threshold, actual) UNITY_TEST_ASSERT_GREATER_THAN_INT16((threshold), (actual), __LINE__, NULL) +#define TEST_ASSERT_GREATER_THAN_INT32(threshold, actual) UNITY_TEST_ASSERT_GREATER_THAN_INT32((threshold), (actual), __LINE__, NULL) +#define TEST_ASSERT_GREATER_THAN_INT64(threshold, actual) UNITY_TEST_ASSERT_GREATER_THAN_INT64((threshold), (actual), __LINE__, NULL) +#define TEST_ASSERT_GREATER_THAN_UINT(threshold, actual) UNITY_TEST_ASSERT_GREATER_THAN_UINT((threshold), (actual), __LINE__, NULL) +#define TEST_ASSERT_GREATER_THAN_UINT8(threshold, actual) UNITY_TEST_ASSERT_GREATER_THAN_UINT8((threshold), (actual), __LINE__, NULL) +#define TEST_ASSERT_GREATER_THAN_UINT16(threshold, actual) UNITY_TEST_ASSERT_GREATER_THAN_UINT16((threshold), (actual), __LINE__, NULL) +#define TEST_ASSERT_GREATER_THAN_UINT32(threshold, actual) UNITY_TEST_ASSERT_GREATER_THAN_UINT32((threshold), (actual), __LINE__, NULL) +#define TEST_ASSERT_GREATER_THAN_UINT64(threshold, actual) UNITY_TEST_ASSERT_GREATER_THAN_UINT64((threshold), (actual), __LINE__, NULL) +#define TEST_ASSERT_GREATER_THAN_size_t(threshold, actual) UNITY_TEST_ASSERT_GREATER_THAN_UINT((threshold), (actual), __LINE__, NULL) +#define TEST_ASSERT_GREATER_THAN_HEX8(threshold, actual) UNITY_TEST_ASSERT_GREATER_THAN_HEX8((threshold), (actual), __LINE__, NULL) +#define TEST_ASSERT_GREATER_THAN_HEX16(threshold, actual) UNITY_TEST_ASSERT_GREATER_THAN_HEX16((threshold), (actual), __LINE__, NULL) +#define TEST_ASSERT_GREATER_THAN_HEX32(threshold, actual) UNITY_TEST_ASSERT_GREATER_THAN_HEX32((threshold), (actual), __LINE__, NULL) +#define TEST_ASSERT_GREATER_THAN_HEX64(threshold, actual) UNITY_TEST_ASSERT_GREATER_THAN_HEX64((threshold), (actual), __LINE__, NULL) +#define TEST_ASSERT_GREATER_THAN_CHAR(threshold, actual) UNITY_TEST_ASSERT_GREATER_THAN_CHAR((threshold), (actual), __LINE__, NULL) + +#define TEST_ASSERT_LESS_THAN(threshold, actual) UNITY_TEST_ASSERT_SMALLER_THAN_INT((threshold), (actual), __LINE__, NULL) +#define TEST_ASSERT_LESS_THAN_INT(threshold, actual) UNITY_TEST_ASSERT_SMALLER_THAN_INT((threshold), (actual), __LINE__, NULL) +#define TEST_ASSERT_LESS_THAN_INT8(threshold, actual) UNITY_TEST_ASSERT_SMALLER_THAN_INT8((threshold), (actual), __LINE__, NULL) +#define TEST_ASSERT_LESS_THAN_INT16(threshold, actual) UNITY_TEST_ASSERT_SMALLER_THAN_INT16((threshold), (actual), __LINE__, NULL) +#define TEST_ASSERT_LESS_THAN_INT32(threshold, actual) UNITY_TEST_ASSERT_SMALLER_THAN_INT32((threshold), (actual), __LINE__, NULL) +#define TEST_ASSERT_LESS_THAN_INT64(threshold, actual) UNITY_TEST_ASSERT_SMALLER_THAN_INT64((threshold), (actual), __LINE__, NULL) +#define TEST_ASSERT_LESS_THAN_UINT(threshold, actual) UNITY_TEST_ASSERT_SMALLER_THAN_UINT((threshold), (actual), __LINE__, NULL) +#define TEST_ASSERT_LESS_THAN_UINT8(threshold, actual) UNITY_TEST_ASSERT_SMALLER_THAN_UINT8((threshold), (actual), __LINE__, NULL) +#define TEST_ASSERT_LESS_THAN_UINT16(threshold, actual) UNITY_TEST_ASSERT_SMALLER_THAN_UINT16((threshold), (actual), __LINE__, NULL) +#define TEST_ASSERT_LESS_THAN_UINT32(threshold, actual) UNITY_TEST_ASSERT_SMALLER_THAN_UINT32((threshold), (actual), __LINE__, NULL) +#define TEST_ASSERT_LESS_THAN_UINT64(threshold, actual) UNITY_ |
