MCPcopy Index your code
hub / github.com/ThrowTheSwitch/Unity / UnityPrintNumberByStyle

Function UnityPrintNumberByStyle

src/unity.c:188–236  ·  view source on GitHub ↗

-----------------------------------------------*/

Source from the content-addressed store, hash-verified

186
187/*-----------------------------------------------*/
188void UnityPrintNumberByStyle(const UNITY_INT number, const UNITY_DISPLAY_STYLE_T style)
189{
190 if ((style & UNITY_DISPLAY_RANGE_INT) == UNITY_DISPLAY_RANGE_INT)
191 {
192 if (style == UNITY_DISPLAY_STYLE_CHAR)
193 {
194 /* printable characters plus CR & LF are printed */
195 UNITY_OUTPUT_CHAR('\'');
196 if ((number <= 126) && (number >= 32))
197 {
198 UNITY_OUTPUT_CHAR((int)number);
199 }
200 /* write escaped carriage returns */
201 else if (number == 13)
202 {
203 UNITY_OUTPUT_CHAR('\\');
204 UNITY_OUTPUT_CHAR('r');
205 }
206 /* write escaped line feeds */
207 else if (number == 10)
208 {
209 UNITY_OUTPUT_CHAR('\\');
210 UNITY_OUTPUT_CHAR('n');
211 }
212 /* unprintable characters are shown as codes */
213 else
214 {
215 UNITY_OUTPUT_CHAR('\\');
216 UNITY_OUTPUT_CHAR('x');
217 UnityPrintNumberHex((UNITY_UINT)number, 2);
218 }
219 UNITY_OUTPUT_CHAR('\'');
220 }
221 else
222 {
223 UnityPrintNumber(number);
224 }
225 }
226 else if ((style & UNITY_DISPLAY_RANGE_UINT) == UNITY_DISPLAY_RANGE_UINT)
227 {
228 UnityPrintNumberUnsigned((UNITY_UINT)number);
229 }
230 else
231 {
232 UNITY_OUTPUT_CHAR('0');
233 UNITY_OUTPUT_CHAR('x');
234 UnityPrintNumberHex((UNITY_UINT)number, (char)((style & 0xF) * 2));
235 }
236}
237
238/*-----------------------------------------------*/
239void UnityPrintNumber(const UNITY_INT number_to_print)

Calls 3

UnityPrintNumberHexFunction · 0.85
UnityPrintNumberFunction · 0.85
UnityPrintNumberUnsignedFunction · 0.85

Tested by

no test coverage detected