You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+56-42Lines changed: 56 additions & 42 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -2,21 +2,19 @@
2
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. Unity Test is a
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
7
8
-
This project is made to test code targetting microcontrollers big and small. The core project is a
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.
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.
13
12
14
13
If you're new to Unity, we encourage you to tour the [getting started guide][].
15
14
16
15
## Getting Started
17
16
18
-
The [docs][] folder contains a [getting started guide][]
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
19
## Unity Assertion Summary
22
20
@@ -43,7 +41,8 @@ Another way of calling `TEST_ASSERT_FALSE`
43
41
TEST_FAIL()
44
42
TEST_FAIL_MESSAGE(message)
45
43
46
-
This test is automatically marked as a failure. The message is output stating why.
44
+
This test is automatically marked as a failure.
45
+
The message is output stating why.
47
46
48
47
### Numerical Assertions: Integers
49
48
@@ -53,84 +52,92 @@ This test is automatically marked as a failure. The message is output stating wh
53
52
TEST_ASSERT_EQUAL_INT32(expected, actual)
54
53
TEST_ASSERT_EQUAL_INT64(expected, actual)
55
54
56
-
Compare two integers for equality and display errors as signed integers. A cast will be performed
57
-
to your natural integer size so often this can just be used. When you need to specify the exact size,
58
-
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:
59
58
60
59
TEST_ASSERT_EQUAL_UINT(expected, actual)
61
60
TEST_ASSERT_EQUAL_UINT8(expected, actual)
62
61
TEST_ASSERT_EQUAL_UINT16(expected, actual)
63
62
TEST_ASSERT_EQUAL_UINT32(expected, actual)
64
63
TEST_ASSERT_EQUAL_UINT64(expected, actual)
65
64
66
-
Compare two integers for equality and display errors as unsigned integers. Like INT, there are
67
-
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.
68
67
69
68
TEST_ASSERT_EQUAL_HEX(expected, actual)
70
69
TEST_ASSERT_EQUAL_HEX8(expected, actual)
71
70
TEST_ASSERT_EQUAL_HEX16(expected, actual)
72
71
TEST_ASSERT_EQUAL_HEX32(expected, actual)
73
72
TEST_ASSERT_EQUAL_HEX64(expected, actual)
74
73
75
-
Compares two integers for equality and display errors as hexadecimal. Like the other integer comparisons,
76
-
you can specify the size... here the size will also effect how many nibbles are shown (for example, `HEX16`
77
-
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).
78
76
79
77
TEST_ASSERT_EQUAL(expected, actual)
80
78
81
79
Another way of calling TEST_ASSERT_EQUAL_INT
82
80
83
81
TEST_ASSERT_INT_WITHIN(delta, expected, actual)
84
82
85
-
Asserts that the actual value is within plus or minus delta of the expected value. This also comes in
86
-
size specific variants.
83
+
Asserts that the actual value is within plus or minus delta of the expected value.
84
+
This also comes in size specific variants.
87
85
88
86
TEST_ASSERT_GREATER_THAN(threshold, actual)
89
87
90
-
Asserts that the actual value is greater than the threshold. This also comes in size specific variants.
88
+
Asserts that the actual value is greater than the threshold.
89
+
This also comes in size specific variants.
91
90
92
91
TEST_ASSERT_LESS_THAN(threshold, actual)
93
92
94
-
Asserts that the actual value is less than the threshold. This also comes in size specific variants.
93
+
Asserts that the actual value is less than the threshold.
94
+
This also comes in size specific variants.
95
95
96
96
### Arrays
97
97
98
98
_ARRAY
99
99
100
-
You can append `_ARRAY` to any of these macros to make an array comparison of that type. Here you will
101
-
need to care a bit more about the actual size of the value being checked. You will also specify an
102
-
additional argument which is the number of elements to compare. For example:
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.
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.
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.
118
121
119
122
TEST_ASSERT_BITS_HIGH(mask, actual)
120
123
121
-
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.
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.
122
126
123
127
TEST_ASSERT_BITS_LOW(mask, actual)
124
128
125
-
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.
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.
126
131
127
132
TEST_ASSERT_BIT_HIGH(bit, actual)
128
133
129
-
Test a single bit and verify that it is high. The bit is specified 0-31 for a 32-bit integer.
134
+
Test a single bit and verify that it is high.
135
+
The bit is specified 0-31 for a 32-bit integer.
130
136
131
137
TEST_ASSERT_BIT_LOW(bit, actual)
132
138
133
-
Test a single bit and verify that it is low. The bit is specified 0-31 for a 32-bit integer.
139
+
Test a single bit and verify that it is low.
140
+
The bit is specified 0-31 for a 32-bit integer.
134
141
135
142
### Numerical Assertions: Floats
136
143
@@ -147,23 +154,30 @@ Asserts that two floating point values are "equal" within a small % delta of the
147
154
148
155
TEST_ASSERT_EQUAL_STRING(expected, actual)
149
156
150
-
Compare two null-terminate strings. Fail if any character is different or if the lengths are different.
157
+
Compare two null-terminate strings.
158
+
Fail if any character is different or if the lengths are different.
Compare two strings. Fail if any character is different, stop comparing after len characters. Output a custom message on failure.
173
+
Compare two strings.
174
+
Fail if any character is different, stop comparing after len characters.
175
+
Output a custom message on failure.
163
176
164
177
### Pointer Assertions
165
178
166
-
Most pointer operations can be performed by simply using the integer comparisons above. However, a couple of special cases are added for clarity.
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.
167
181
168
182
TEST_ASSERT_NULL(pointer)
169
183
@@ -177,14 +191,14 @@ Fails if the pointer is equal to NULL
177
191
178
192
TEST_ASSERT_EQUAL_MEMORY(expected, actual, len)
179
193
180
-
Compare two blocks of memory. This is a good generic assertion for types that can't be coerced into acting like
181
-
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.
182
196
183
197
### \_MESSAGE
184
198
185
-
you can append `\_MESSAGE` to any of the macros to make them take an additional argument. This argument
186
-
is a string that will be printed at the end of the failure strings. This is useful for specifying more
187
-
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.
0 commit comments