ceedling 0.31.0 → 0.31.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/assets/example_file_call.c +6 -0
- data/assets/example_file_call.h +6 -0
- data/assets/test_example_file_with_mock.c +13 -0
- data/bin/ceedling +2 -2
- data/ceedling.gemspec +1 -1
- data/lib/ceedling/configurator.rb +7 -2
- data/lib/ceedling/configurator_plugins.rb +21 -1
- data/lib/ceedling/defaults.rb +1 -0
- data/lib/ceedling/preprocessinator_extractor.rb +2 -0
- data/lib/ceedling/preprocessinator_includes_handler.rb +24 -24
- data/lib/ceedling/version.rb +11 -7
- data/plugins/gcov/config/defaults_gcov.rb +118 -0
- data/plugins/gcov/lib/gcovr_reportinator.rb +1 -1
- data/plugins/gcov/lib/reportgenerator_reportinator.rb +1 -1
- data/plugins/junit_tests_report/lib/junit_tests_report.rb +6 -6
- data/plugins/module_generator/README.md +16 -2
- data/plugins/module_generator/lib/module_generator.rb +1 -0
- data/spec/gcov/gcov_deployment_spec.rb +1 -1
- data/spec/preprocessinator_includes_handler_spec.rb +38 -8
- data/spec/spec_system_helper.rb +19 -0
- data/spec/system/deployment_spec.rb +1 -0
- data/vendor/cmock/lib/cmock_file_writer.rb +2 -3
- data/vendor/cmock/lib/cmock_generator.rb +87 -70
- data/vendor/cmock/lib/cmock_header_parser.rb +29 -27
- data/vendor/cmock/src/cmock.h +1 -1
- data/vendor/cmock/test/unit/cmock_generator_main_test.rb +46 -41
- data/vendor/cmock/test/unit/cmock_header_parser_test.rb +46 -40
- data/vendor/cmock/vendor/c_exception/README.md +6 -4
- data/vendor/cmock/vendor/c_exception/docs/CException.md +2 -2
- data/vendor/cmock/vendor/c_exception/lib/CException.h +1 -1
- data/vendor/cmock/vendor/c_exception/lib/meson.build +2 -2
- data/vendor/cmock/vendor/c_exception/meson.build +36 -2
- data/vendor/cmock/vendor/unity/README.md +77 -71
- data/vendor/cmock/vendor/unity/auto/generate_test_runner.rb +1 -1
- data/vendor/cmock/vendor/unity/docs/ThrowTheSwitchCodingStandard.md +107 -126
- data/vendor/cmock/vendor/unity/docs/UnityAssertionsReference.md +149 -193
- data/vendor/cmock/vendor/unity/docs/UnityConfigurationGuide.md +236 -294
- data/vendor/cmock/vendor/unity/docs/UnityGettingStartedGuide.md +112 -121
- data/vendor/cmock/vendor/unity/docs/UnityHelperScriptsGuide.md +82 -115
- data/vendor/cmock/vendor/unity/extras/fixture/readme.md +16 -19
- data/vendor/cmock/vendor/unity/extras/memory/readme.md +27 -34
- data/vendor/cmock/vendor/unity/src/unity.c +1 -1
- data/vendor/cmock/vendor/unity/src/unity.h +1 -1
- data/vendor/cmock/vendor/unity/src/unity_internals.h +21 -7
- data/vendor/unity/README.md +77 -71
- data/vendor/unity/auto/generate_test_runner.rb +1 -1
- data/vendor/unity/docs/ThrowTheSwitchCodingStandard.md +107 -126
- data/vendor/unity/docs/UnityAssertionsReference.md +149 -193
- data/vendor/unity/docs/UnityConfigurationGuide.md +236 -294
- data/vendor/unity/docs/UnityGettingStartedGuide.md +112 -121
- data/vendor/unity/docs/UnityHelperScriptsGuide.md +82 -115
- data/vendor/unity/extras/fixture/readme.md +16 -19
- data/vendor/unity/extras/memory/readme.md +27 -34
- data/vendor/unity/src/unity.c +1 -1
- data/vendor/unity/src/unity.h +1 -1
- data/vendor/unity/src/unity_internals.h +21 -7
- metadata +14 -5
- data/plugins/gcov/config/defaults.yml +0 -55
@@ -1,29 +1,26 @@
|
|
1
1
|
# Unity Fixtures
|
2
2
|
|
3
|
-
This Framework is an optional add-on to Unity.
|
4
|
-
you may now work with Unity in a manner similar to CppUTest.
|
5
|
-
test groups and gives finer control of your tests over the command line.
|
3
|
+
This Framework is an optional add-on to Unity.
|
4
|
+
By including unity_framework.h in place of unity.h, you may now work with Unity in a manner similar to CppUTest.
|
5
|
+
This framework adds the concepts of test groups and gives finer control of your tests over the command line.
|
6
6
|
|
7
|
-
This framework is primarily supplied for those working through James Grenning's book on Embedded
|
8
|
-
|
9
|
-
framework glosses over some of the features of Unity, and makes it more difficult
|
10
|
-
to integrate with other testing tools like Ceedling and CMock.
|
7
|
+
This framework is primarily supplied for those working through James Grenning's book on Embedded Test Driven Development, or those coming to Unity from CppUTest.
|
8
|
+
We should note that using this framework glosses over some of the features of Unity, and makes it more difficult to integrate with other testing tools like Ceedling and CMock.
|
11
9
|
|
12
|
-
|
10
|
+
## Dependency Notification
|
13
11
|
|
14
|
-
Fixtures, by default, uses the Memory addon as well.
|
15
|
-
|
16
|
-
|
17
|
-
|
12
|
+
Fixtures, by default, uses the Memory addon as well.
|
13
|
+
This is to make it simple for those trying to follow along with James' book.
|
14
|
+
Using them together is completely optional.
|
15
|
+
You may choose to use Fixtures without Memory handling by defining `UNITY_FIXTURE_NO_EXTRAS`.
|
16
|
+
It will then stop automatically pulling in extras and leave you to do it as desired.
|
18
17
|
|
19
|
-
|
18
|
+
## Usage information
|
20
19
|
|
21
|
-
By default the test executables produced by Unity Fixtures run all tests once, but the behavior can
|
22
|
-
|
23
|
-
information.
|
20
|
+
By default the test executables produced by Unity Fixtures run all tests once, but the behavior can be configured with command-line flags.
|
21
|
+
Run the test executable with the `--help` flag for more information.
|
24
22
|
|
25
|
-
It's possible to add a custom line at the end of the help message, typically to point to
|
26
|
-
|
27
|
-
provide a custom message, e.g.:
|
23
|
+
It's possible to add a custom line at the end of the help message, typically to point to project-specific or company-specific unit test documentation.
|
24
|
+
Define `UNITY_CUSTOM_HELP_MSG` to provide a custom message, e.g.:
|
28
25
|
|
29
26
|
#define UNITY_CUSTOM_HELP_MSG "If any test fails see https://example.com/troubleshooting"
|
@@ -1,49 +1,42 @@
|
|
1
1
|
# Unity Memory
|
2
2
|
|
3
|
-
This Framework is an optional add-on to Unity.
|
4
|
-
unity_memory.h, you have the added ability to track malloc and free calls.
|
5
|
-
addon requires that the stdlib functions be overridden by its own defines.
|
6
|
-
defines will still malloc / realloc / free etc, but will also track the calls
|
7
|
-
in order to ensure that you don't have any memory leaks in your programs.
|
3
|
+
This Framework is an optional add-on to Unity.
|
4
|
+
By including unity.h and then unity_memory.h, you have the added ability to track malloc and free calls.
|
5
|
+
This addon requires that the stdlib functions be overridden by its own defines.
|
6
|
+
These defines will still malloc / realloc / free etc, but will also track the calls in order to ensure that you don't have any memory leaks in your programs.
|
8
7
|
|
9
|
-
Note that this is only useful in situations where a unit is in charge of both
|
10
|
-
|
11
|
-
|
12
|
-
track complete system memory handling.
|
8
|
+
Note that this is only useful in situations where a unit is in charge of both the allocation and deallocation of memory.
|
9
|
+
When it is not symmetric, unit testing can report a number of false failures.
|
10
|
+
A more advanced runtime tool is required to track complete system memory handling.
|
13
11
|
|
14
|
-
|
12
|
+
## Module API
|
15
13
|
|
16
|
-
|
14
|
+
### `UnityMalloc_StartTest` and `UnityMalloc_EndTest`
|
17
15
|
|
18
|
-
These must be called at the beginning and end of each test.
|
19
|
-
be added to `setUp` and `tearDown` in order to do their job.
|
20
|
-
runner generator scripts, these will be automatically added to the runner whenever
|
21
|
-
unity_memory.h is included.
|
16
|
+
These must be called at the beginning and end of each test.
|
17
|
+
For simplicity, they can be added to `setUp` and `tearDown` in order to do their job.
|
18
|
+
When using the test runner generator scripts, these will be automatically added to the runner whenever unity_memory.h is included.
|
22
19
|
|
23
|
-
|
20
|
+
### `UnityMalloc_MakeMallocFailAfterCount`
|
24
21
|
|
25
|
-
This can be called from the tests themselves.
|
26
|
-
force the reference counter to start keeping track of malloc calls.
|
27
|
-
if the number of malloc calls exceeds the number given, malloc will immediately
|
28
|
-
|
29
|
-
simplified mock.
|
22
|
+
This can be called from the tests themselves.
|
23
|
+
Passing this function a number will force the reference counter to start keeping track of malloc calls.
|
24
|
+
During that test, if the number of malloc calls exceeds the number given, malloc will immediately start returning `NULL`.
|
25
|
+
This allows you to test error conditions.
|
26
|
+
Think of it as a simplified mock.
|
30
27
|
|
31
|
-
|
28
|
+
## Configuration
|
32
29
|
|
33
|
-
|
30
|
+
### `UNITY_MALLOC` and `UNITY_FREE`
|
34
31
|
|
35
|
-
By default, this module tries to use the real stdlib `malloc` and `free` internally.
|
36
|
-
If you would prefer it to use something else, like FreeRTOS's `pvPortMalloc` and
|
37
|
-
`pvPortFree`, then you can use these defines to make it so.
|
32
|
+
By default, this module tries to use the real stdlib `malloc` and `free` internally.
|
33
|
+
If you would prefer it to use something else, like FreeRTOS's `pvPortMalloc` and `pvPortFree`, then you can use these defines to make it so.
|
38
34
|
|
39
|
-
|
35
|
+
### `UNITY_EXCLUDE_STDLIB_MALLOC`
|
40
36
|
|
41
|
-
If you would like this library to ignore stdlib or other heap engines completely, and
|
42
|
-
|
43
|
-
(and at likely lower overhead). Note that this is not a very featureful memory manager,
|
44
|
-
but is sufficient for most testing purposes.
|
37
|
+
If you would like this library to ignore stdlib or other heap engines completely, and manage the memory on its own, then define this. All memory will be handled internally (and at likely lower overhead).
|
38
|
+
Note that this is not a very featureful memory manager, but is sufficient for most testing purposes.
|
45
39
|
|
46
|
-
|
40
|
+
### `UNITY_INTERNAL_HEAP_SIZE_BYTES`
|
47
41
|
|
48
|
-
When using the built-in memory manager (see `UNITY_EXCLUDE_STDLIB_MALLOC`) this define
|
49
|
-
allows you to set the heap size this library will use to manage the memory.
|
42
|
+
When using the built-in memory manager (see `UNITY_EXCLUDE_STDLIB_MALLOC`) this define allows you to set the heap size this library will use to manage the memory.
|
@@ -445,7 +445,7 @@ void UnityPrintFloat(const UNITY_DOUBLE input_number)
|
|
445
445
|
|
446
446
|
/* build up buffer in reverse order */
|
447
447
|
digits = 0;
|
448
|
-
while ((n != 0) || (digits
|
448
|
+
while ((n != 0) || (digits <= decimals))
|
449
449
|
{
|
450
450
|
buf[digits++] = (char)('0' + n % 10);
|
451
451
|
n /= 10;
|
@@ -10,7 +10,7 @@
|
|
10
10
|
|
11
11
|
#define UNITY_VERSION_MAJOR 2
|
12
12
|
#define UNITY_VERSION_MINOR 5
|
13
|
-
#define UNITY_VERSION_BUILD
|
13
|
+
#define UNITY_VERSION_BUILD 4
|
14
14
|
#define UNITY_VERSION ((UNITY_VERSION_MAJOR << 16) | (UNITY_VERSION_MINOR << 8) | UNITY_VERSION_BUILD)
|
15
15
|
|
16
16
|
#ifdef __cplusplus
|
@@ -40,10 +40,24 @@
|
|
40
40
|
#include <limits.h>
|
41
41
|
#endif
|
42
42
|
|
43
|
-
#if defined
|
44
|
-
#
|
43
|
+
#if defined(__GNUC__) || defined(__clang__)
|
44
|
+
#define UNITY_FUNCTION_ATTR(a) __attribute__((a))
|
45
45
|
#else
|
46
|
-
#
|
46
|
+
#define UNITY_FUNCTION_ATTR(a) /* ignore */
|
47
|
+
#endif
|
48
|
+
|
49
|
+
#ifndef UNITY_NORETURN
|
50
|
+
#if defined(__cplusplus)
|
51
|
+
#if __cplusplus >= 201103L
|
52
|
+
#define UNITY_NORETURN [[ noreturn ]]
|
53
|
+
#endif
|
54
|
+
#elif defined(__STDC_VERSION__) && __STDC_VERSION__ >= 201112L
|
55
|
+
#include <stdnoreturn.h>
|
56
|
+
#define UNITY_NORETURN noreturn
|
57
|
+
#endif
|
58
|
+
#endif
|
59
|
+
#ifndef UNITY_NORETURN
|
60
|
+
#define UNITY_NORETURN UNITY_FUNCTION_ATTR(noreturn)
|
47
61
|
#endif
|
48
62
|
|
49
63
|
/*-------------------------------------------------------
|
@@ -333,7 +347,7 @@ typedef UNITY_FLOAT_TYPE UNITY_FLOAT;
|
|
333
347
|
UnityPrintNumberUnsigned(execTimeMs); \
|
334
348
|
UnityPrint(" ms)"); \
|
335
349
|
}
|
336
|
-
#elif defined(__unix__)
|
350
|
+
#elif defined(__unix__) || defined(__APPLE__)
|
337
351
|
#include <time.h>
|
338
352
|
#define UNITY_TIME_TYPE struct timespec
|
339
353
|
#define UNITY_GET_TIME(t) clock_gettime(CLOCK_MONOTONIC, &t)
|
@@ -618,8 +632,8 @@ void UnityAssertNumbersArrayWithin(const UNITY_UINT delta,
|
|
618
632
|
const UNITY_FLAGS_T flags);
|
619
633
|
|
620
634
|
#ifndef UNITY_EXCLUDE_SETJMP_H
|
621
|
-
void UnityFail(const char* message, const UNITY_LINE_TYPE line)
|
622
|
-
void UnityIgnore(const char* message, const UNITY_LINE_TYPE line)
|
635
|
+
UNITY_NORETURN void UnityFail(const char* message, const UNITY_LINE_TYPE line);
|
636
|
+
UNITY_NORETURN void UnityIgnore(const char* message, const UNITY_LINE_TYPE line);
|
623
637
|
#else
|
624
638
|
void UnityFail(const char* message, const UNITY_LINE_TYPE line);
|
625
639
|
void UnityIgnore(const char* message, const UNITY_LINE_TYPE line);
|
@@ -875,7 +889,7 @@ int UnityTestMatches(void);
|
|
875
889
|
#define UNITY_TEST_ASSERT_INT16_ARRAY_WITHIN(delta, expected, actual, num_elements, line, message) UnityAssertNumbersArrayWithin((UNITY_UINT16)(delta), (UNITY_INTERNAL_PTR)(expected), (UNITY_INTERNAL_PTR)(actual), ((UNITY_UINT32)(num_elements)), (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_INT16, UNITY_ARRAY_TO_ARRAY)
|
876
890
|
#define UNITY_TEST_ASSERT_INT32_ARRAY_WITHIN(delta, expected, actual, num_elements, line, message) UnityAssertNumbersArrayWithin((UNITY_UINT32)(delta), (UNITY_INTERNAL_PTR)(expected), (UNITY_INTERNAL_PTR)(actual), ((UNITY_UINT32)(num_elements)), (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_INT32, UNITY_ARRAY_TO_ARRAY)
|
877
891
|
#define UNITY_TEST_ASSERT_UINT_ARRAY_WITHIN(delta, expected, actual, num_elements, line, message) UnityAssertNumbersArrayWithin( (delta), (UNITY_INTERNAL_PTR)(expected), (UNITY_INTERNAL_PTR)(actual), ((UNITY_UINT32)(num_elements)), (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_UINT, UNITY_ARRAY_TO_ARRAY)
|
878
|
-
#define UNITY_TEST_ASSERT_UINT8_ARRAY_WITHIN(delta, expected, actual, num_elements, line, message)
|
892
|
+
#define UNITY_TEST_ASSERT_UINT8_ARRAY_WITHIN(delta, expected, actual, num_elements, line, message) UnityAssertNumbersArrayWithin((UNITY_UINT16)(delta), (UNITY_INTERNAL_PTR)(expected), (UNITY_INTERNAL_PTR)(actual), ((UNITY_UINT32)(num_elements)), (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_UINT8, UNITY_ARRAY_TO_ARRAY)
|
879
893
|
#define UNITY_TEST_ASSERT_UINT16_ARRAY_WITHIN(delta, expected, actual, num_elements, line, message) UnityAssertNumbersArrayWithin((UNITY_UINT16)(delta), (UNITY_INTERNAL_PTR)(expected), (UNITY_INTERNAL_PTR)(actual), ((UNITY_UINT32)(num_elements)), (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_UINT16, UNITY_ARRAY_TO_ARRAY)
|
880
894
|
#define UNITY_TEST_ASSERT_UINT32_ARRAY_WITHIN(delta, expected, actual, num_elements, line, message) UnityAssertNumbersArrayWithin((UNITY_UINT32)(delta), (UNITY_INTERNAL_PTR)(expected), (UNITY_INTERNAL_PTR)(actual), ((UNITY_UINT32)(num_elements)), (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_UINT32, UNITY_ARRAY_TO_ARRAY)
|
881
895
|
#define UNITY_TEST_ASSERT_HEX8_ARRAY_WITHIN(delta, expected, actual, num_elements, line, message) UnityAssertNumbersArrayWithin((UNITY_UINT8 )(delta), (UNITY_INTERNAL_PTR)(expected), (UNITY_INTERNAL_PTR)(actual), ((UNITY_UINT32)(num_elements)), (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_HEX8, UNITY_ARRAY_TO_ARRAY)
|
data/vendor/unity/README.md
CHANGED
@@ -1,29 +1,26 @@
|
|
1
|
-
Unity Test ![CI]
|
2
|
-
|
1
|
+
# Unity Test ![CI][]
|
2
|
+
|
3
3
|
__Copyright (c) 2007 - 2021 Unity Project by Mike Karlesky, Mark VanderVoord, and Greg Williams__
|
4
4
|
|
5
|
-
Welcome to the Unity Test Project, one of the main projects of ThrowTheSwitch.org.
|
6
|
-
unit testing framework built for C, with a focus on working with embedded toolchains.
|
5
|
+
Welcome to the Unity Test Project, one of the main projects of ThrowTheSwitch.org.
|
6
|
+
Unity Test is a unit testing framework built for C, with a focus on working with embedded toolchains.
|
7
|
+
|
8
|
+
This project is made to test code targetting microcontrollers big and small.
|
9
|
+
The core project is a single C file and a pair of headers, allowing it to the added to your existing build setup without too much headache.
|
10
|
+
You may use any compiler you wish, and may use most existing build systems including Make, CMake, etc.
|
11
|
+
If you'd like to leave the hard work to us, you might be interested in Ceedling, a build tool also by ThrowTheSwitch.org.
|
7
12
|
|
8
|
-
|
9
|
-
single C file and a pair of headers, allowing it to the added to your existing build setup without
|
10
|
-
too much headache. You may use any compiler you wish, and may use most existing build systems
|
11
|
-
including make, cmake, etc. If you'd like to leave the hard work to us, you might be interested
|
12
|
-
in Ceedling, a build tool also by ThrowTheSwitch.org.
|
13
|
+
If you're new to Unity, we encourage you to tour the [getting started guide][].
|
13
14
|
|
14
|
-
|
15
|
+
## Getting Started
|
15
16
|
|
16
|
-
|
17
|
-
===============
|
18
|
-
The [docs](docs/) folder contains a [getting started guide](docs/UnityGettingStartedGuide.md)
|
19
|
-
and much more tips about using Unity.
|
17
|
+
The [docs][] folder contains a [getting started guide][] and much more tips about using Unity.
|
20
18
|
|
21
|
-
Unity Assertion Summary
|
22
|
-
=======================
|
23
|
-
For the full list, see [UnityAssertionsReference.md](docs/UnityAssertionsReference.md).
|
19
|
+
## Unity Assertion Summary
|
24
20
|
|
25
|
-
|
26
|
-
|
21
|
+
For the full list, see [UnityAssertionsReference.md][].
|
22
|
+
|
23
|
+
### Basic Validity Tests
|
27
24
|
|
28
25
|
TEST_ASSERT_TRUE(condition)
|
29
26
|
|
@@ -44,10 +41,10 @@ Another way of calling `TEST_ASSERT_FALSE`
|
|
44
41
|
TEST_FAIL()
|
45
42
|
TEST_FAIL_MESSAGE(message)
|
46
43
|
|
47
|
-
This test is automatically marked as a failure.
|
44
|
+
This test is automatically marked as a failure.
|
45
|
+
The message is output stating why.
|
48
46
|
|
49
|
-
Numerical Assertions: Integers
|
50
|
-
------------------------------
|
47
|
+
### Numerical Assertions: Integers
|
51
48
|
|
52
49
|
TEST_ASSERT_EQUAL_INT(expected, actual)
|
53
50
|
TEST_ASSERT_EQUAL_INT8(expected, actual)
|
@@ -55,9 +52,9 @@ Numerical Assertions: Integers
|
|
55
52
|
TEST_ASSERT_EQUAL_INT32(expected, actual)
|
56
53
|
TEST_ASSERT_EQUAL_INT64(expected, actual)
|
57
54
|
|
58
|
-
Compare two integers for equality and display errors as signed integers.
|
59
|
-
to your natural integer size so often this can just be used.
|
60
|
-
like when comparing arrays, you can use a specific version:
|
55
|
+
Compare two integers for equality and display errors as signed integers.
|
56
|
+
A cast will be performed to your natural integer size so often this can just be used.
|
57
|
+
When you need to specify the exact size, like when comparing arrays, you can use a specific version:
|
61
58
|
|
62
59
|
TEST_ASSERT_EQUAL_UINT(expected, actual)
|
63
60
|
TEST_ASSERT_EQUAL_UINT8(expected, actual)
|
@@ -65,8 +62,8 @@ like when comparing arrays, you can use a specific version:
|
|
65
62
|
TEST_ASSERT_EQUAL_UINT32(expected, actual)
|
66
63
|
TEST_ASSERT_EQUAL_UINT64(expected, actual)
|
67
64
|
|
68
|
-
Compare two integers for equality and display errors as unsigned integers.
|
69
|
-
variants for different sizes also.
|
65
|
+
Compare two integers for equality and display errors as unsigned integers.
|
66
|
+
Like INT, there are variants for different sizes also.
|
70
67
|
|
71
68
|
TEST_ASSERT_EQUAL_HEX(expected, actual)
|
72
69
|
TEST_ASSERT_EQUAL_HEX8(expected, actual)
|
@@ -74,9 +71,8 @@ variants for different sizes also.
|
|
74
71
|
TEST_ASSERT_EQUAL_HEX32(expected, actual)
|
75
72
|
TEST_ASSERT_EQUAL_HEX64(expected, actual)
|
76
73
|
|
77
|
-
Compares two integers for equality and display errors as hexadecimal.
|
78
|
-
you can specify the size... here the size will also effect how many nibbles are shown (for example, `HEX16`
|
79
|
-
will show 4 nibbles).
|
74
|
+
Compares two integers for equality and display errors as hexadecimal.
|
75
|
+
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).
|
80
76
|
|
81
77
|
TEST_ASSERT_EQUAL(expected, actual)
|
82
78
|
|
@@ -84,63 +80,66 @@ Another way of calling TEST_ASSERT_EQUAL_INT
|
|
84
80
|
|
85
81
|
TEST_ASSERT_INT_WITHIN(delta, expected, actual)
|
86
82
|
|
87
|
-
Asserts that the actual value is within plus or minus delta of the expected value.
|
88
|
-
size specific variants.
|
89
|
-
|
83
|
+
Asserts that the actual value is within plus or minus delta of the expected value.
|
84
|
+
This also comes in size specific variants.
|
90
85
|
|
91
86
|
TEST_ASSERT_GREATER_THAN(threshold, actual)
|
92
87
|
|
93
|
-
Asserts that the actual value is greater than the threshold.
|
94
|
-
|
88
|
+
Asserts that the actual value is greater than the threshold.
|
89
|
+
This also comes in size specific variants.
|
95
90
|
|
96
91
|
TEST_ASSERT_LESS_THAN(threshold, actual)
|
97
92
|
|
98
|
-
Asserts that the actual value is less than the threshold.
|
99
|
-
|
93
|
+
Asserts that the actual value is less than the threshold.
|
94
|
+
This also comes in size specific variants.
|
100
95
|
|
101
|
-
Arrays
|
102
|
-
------
|
96
|
+
### Arrays
|
103
97
|
|
104
98
|
_ARRAY
|
105
99
|
|
106
|
-
You can append `_ARRAY` to any of these macros to make an array comparison of that type.
|
107
|
-
need to care a bit more about the actual size of the value being checked.
|
108
|
-
additional argument which is the number of elements to compare.
|
100
|
+
You can append `_ARRAY` to any of these macros to make an array comparison of that type.
|
101
|
+
Here you will need to care a bit more about the actual size of the value being checked.
|
102
|
+
You will also specify an additional argument which is the number of elements to compare.
|
103
|
+
For example:
|
109
104
|
|
110
105
|
TEST_ASSERT_EQUAL_HEX8_ARRAY(expected, actual, elements)
|
111
106
|
|
112
107
|
_EACH_EQUAL
|
113
108
|
|
114
|
-
Another array comparison option is to check that EVERY element of an array is equal to a single expected
|
115
|
-
|
109
|
+
Another array comparison option is to check that EVERY element of an array is equal to a single expected value.
|
110
|
+
You do this by specifying the EACH_EQUAL macro.
|
111
|
+
For example:
|
116
112
|
|
117
113
|
TEST_ASSERT_EACH_EQUAL_INT32(expected, actual, elements)
|
118
114
|
|
119
|
-
Numerical Assertions: Bitwise
|
120
|
-
-----------------------------
|
115
|
+
### Numerical Assertions: Bitwise
|
121
116
|
|
122
117
|
TEST_ASSERT_BITS(mask, expected, actual)
|
123
118
|
|
124
|
-
Use an integer mask to specify which bits should be compared between two other integers.
|
119
|
+
Use an integer mask to specify which bits should be compared between two other integers.
|
120
|
+
High bits in the mask are compared, low bits ignored.
|
125
121
|
|
126
122
|
TEST_ASSERT_BITS_HIGH(mask, actual)
|
127
123
|
|
128
|
-
Use an integer mask to specify which bits should be inspected to determine if they are all set high.
|
124
|
+
Use an integer mask to specify which bits should be inspected to determine if they are all set high.
|
125
|
+
High bits in the mask are compared, low bits ignored.
|
129
126
|
|
130
127
|
TEST_ASSERT_BITS_LOW(mask, actual)
|
131
128
|
|
132
|
-
Use an integer mask to specify which bits should be inspected to determine if they are all set low.
|
129
|
+
Use an integer mask to specify which bits should be inspected to determine if they are all set low.
|
130
|
+
High bits in the mask are compared, low bits ignored.
|
133
131
|
|
134
132
|
TEST_ASSERT_BIT_HIGH(bit, actual)
|
135
133
|
|
136
|
-
Test a single bit and verify that it is high.
|
134
|
+
Test a single bit and verify that it is high.
|
135
|
+
The bit is specified 0-31 for a 32-bit integer.
|
137
136
|
|
138
137
|
TEST_ASSERT_BIT_LOW(bit, actual)
|
139
138
|
|
140
|
-
Test a single bit and verify that it is low.
|
139
|
+
Test a single bit and verify that it is low.
|
140
|
+
The bit is specified 0-31 for a 32-bit integer.
|
141
141
|
|
142
|
-
Numerical Assertions: Floats
|
143
|
-
----------------------------
|
142
|
+
### Numerical Assertions: Floats
|
144
143
|
|
145
144
|
TEST_ASSERT_FLOAT_WITHIN(delta, expected, actual)
|
146
145
|
|
@@ -151,29 +150,34 @@ Asserts that the actual value is within plus or minus delta of the expected valu
|
|
151
150
|
|
152
151
|
Asserts that two floating point values are "equal" within a small % delta of the expected value.
|
153
152
|
|
154
|
-
String Assertions
|
155
|
-
-----------------
|
153
|
+
### String Assertions
|
156
154
|
|
157
155
|
TEST_ASSERT_EQUAL_STRING(expected, actual)
|
158
156
|
|
159
|
-
Compare two null-terminate strings.
|
157
|
+
Compare two null-terminate strings.
|
158
|
+
Fail if any character is different or if the lengths are different.
|
160
159
|
|
161
160
|
TEST_ASSERT_EQUAL_STRING_LEN(expected, actual, len)
|
162
161
|
|
163
|
-
Compare two strings.
|
162
|
+
Compare two strings.
|
163
|
+
Fail if any character is different, stop comparing after len characters.
|
164
164
|
|
165
165
|
TEST_ASSERT_EQUAL_STRING_MESSAGE(expected, actual, message)
|
166
166
|
|
167
|
-
Compare two null-terminate strings.
|
167
|
+
Compare two null-terminate strings.
|
168
|
+
Fail if any character is different or if the lengths are different.
|
169
|
+
Output a custom message on failure.
|
168
170
|
|
169
171
|
TEST_ASSERT_EQUAL_STRING_LEN_MESSAGE(expected, actual, len, message)
|
170
172
|
|
171
|
-
Compare two strings.
|
173
|
+
Compare two strings.
|
174
|
+
Fail if any character is different, stop comparing after len characters.
|
175
|
+
Output a custom message on failure.
|
172
176
|
|
173
|
-
Pointer Assertions
|
174
|
-
------------------
|
177
|
+
### Pointer Assertions
|
175
178
|
|
176
|
-
Most pointer operations can be performed by simply using the integer comparisons above.
|
179
|
+
Most pointer operations can be performed by simply using the integer comparisons above.
|
180
|
+
However, a couple of special cases are added for clarity.
|
177
181
|
|
178
182
|
TEST_ASSERT_NULL(pointer)
|
179
183
|
|
@@ -183,18 +187,20 @@ Fails if the pointer is not equal to NULL
|
|
183
187
|
|
184
188
|
Fails if the pointer is equal to NULL
|
185
189
|
|
186
|
-
Memory Assertions
|
187
|
-
-----------------
|
190
|
+
### Memory Assertions
|
188
191
|
|
189
192
|
TEST_ASSERT_EQUAL_MEMORY(expected, actual, len)
|
190
193
|
|
191
|
-
Compare two blocks of memory.
|
192
|
-
standard types... but since it's a memory compare, you have to be careful that your data types are packed.
|
194
|
+
Compare two blocks of memory.
|
195
|
+
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.
|
193
196
|
|
194
|
-
\_MESSAGE
|
195
|
-
---------
|
197
|
+
### \_MESSAGE
|
196
198
|
|
197
|
-
|
198
|
-
is a string that will be printed at the end of the failure strings.
|
199
|
-
information about the problem.
|
199
|
+
You can append `\_MESSAGE` to any of the macros to make them take an additional argument.
|
200
|
+
This argument is a string that will be printed at the end of the failure strings.
|
201
|
+
This is useful for specifying more information about the problem.
|
200
202
|
|
203
|
+
[CI]: https://github.com/ThrowTheSwitch/Unity/workflows/CI/badge.svg
|
204
|
+
[getting started guide]: docs/UnityGettingStartedGuide.md
|
205
|
+
[docs]: docs/
|
206
|
+
[UnityAssertionsReference.md]: docs/UnityAssertionsReference.md
|