mirror of
https://github.com/ThrowTheSwitch/Unity.git
synced 2026-10-15 13:17:24 +00:00
Merge pull request #848 from ThrowTheSwitch/feature/choose-printable-chars
Feature/choose printable chars
This commit is contained in:
@@ -407,43 +407,43 @@ class UnityTestRunnerGenerator
|
||||
end
|
||||
|
||||
def create_run_test(output)
|
||||
output.puts("/*=======Test Runner Used To Run Each Test=====*/")
|
||||
output.puts("static void run_test(UnityTestFunction func, const char* name, UNITY_LINE_TYPE line_num)")
|
||||
output.puts("{")
|
||||
output.puts(" Unity.CurrentTestName = name;")
|
||||
output.puts(" Unity.CurrentTestLineNumber = (UNITY_UINT) line_num;")
|
||||
output.puts("#ifdef UNITY_USE_COMMAND_LINE_ARGS")
|
||||
output.puts(" if (!UnityTestMatches())")
|
||||
output.puts(" return;")
|
||||
output.puts("#endif")
|
||||
output.puts(" Unity.NumberOfTests++;")
|
||||
output.puts(" UNITY_CLR_DETAILS();")
|
||||
output.puts(" UNITY_EXEC_TIME_START();")
|
||||
output.puts(" CMock_Init();")
|
||||
output.puts(" if (TEST_PROTECT())")
|
||||
output.puts(" {")
|
||||
output.puts('/*=======Test Runner Used To Run Each Test=====*/')
|
||||
output.puts('static void run_test(UnityTestFunction func, const char* name, UNITY_LINE_TYPE line_num)')
|
||||
output.puts('{')
|
||||
output.puts(' Unity.CurrentTestName = name;')
|
||||
output.puts(' Unity.CurrentTestLineNumber = (UNITY_UINT) line_num;')
|
||||
output.puts('#ifdef UNITY_USE_COMMAND_LINE_ARGS')
|
||||
output.puts(' if (!UnityTestMatches())')
|
||||
output.puts(' return;')
|
||||
output.puts('#endif')
|
||||
output.puts(' Unity.NumberOfTests++;')
|
||||
output.puts(' UNITY_CLR_DETAILS();')
|
||||
output.puts(' UNITY_EXEC_TIME_START();')
|
||||
output.puts(' CMock_Init();')
|
||||
output.puts(' if (TEST_PROTECT())')
|
||||
output.puts(' {')
|
||||
if @options[:plugins].include?(:cexception)
|
||||
output.puts(" volatile CEXCEPTION_T e;")
|
||||
output.puts(" Try {")
|
||||
output.puts(' volatile CEXCEPTION_T e;')
|
||||
output.puts(' Try {')
|
||||
output.puts(" #{@options[:setup_name]}();")
|
||||
output.puts(" func();")
|
||||
output.puts(" } Catch(e) {")
|
||||
output.puts(" TEST_ASSERT_EQUAL_HEX32_MESSAGE(CEXCEPTION_NONE, e, \"Unhandled Exception!\");")
|
||||
output.puts(" }")
|
||||
output.puts(' func();')
|
||||
output.puts(' } Catch(e) {')
|
||||
output.puts(' TEST_ASSERT_EQUAL_HEX32_MESSAGE(CEXCEPTION_NONE, e, "Unhandled Exception!");')
|
||||
output.puts(' }')
|
||||
else
|
||||
output.puts(" #{@options[:setup_name]}();")
|
||||
output.puts(" func();")
|
||||
output.puts(' func();')
|
||||
end
|
||||
output.puts(" }")
|
||||
output.puts(" if (TEST_PROTECT())")
|
||||
output.puts(" {")
|
||||
output.puts(' }')
|
||||
output.puts(' if (TEST_PROTECT())')
|
||||
output.puts(' {')
|
||||
output.puts(" #{@options[:teardown_name]}();")
|
||||
output.puts(" CMock_Verify();")
|
||||
output.puts(" }")
|
||||
output.puts(" CMock_Destroy();")
|
||||
output.puts(" UNITY_EXEC_TIME_STOP();")
|
||||
output.puts(" UnityConcludeTest();")
|
||||
output.puts("}")
|
||||
output.puts(' CMock_Verify();')
|
||||
output.puts(' }')
|
||||
output.puts(' CMock_Destroy();')
|
||||
output.puts(' UNITY_EXEC_TIME_STOP();')
|
||||
output.puts(' UnityConcludeTest();')
|
||||
output.puts('}')
|
||||
end
|
||||
|
||||
def create_args_wrappers(output, tests)
|
||||
@@ -465,7 +465,7 @@ class UnityTestRunnerGenerator
|
||||
def create_warning_test(output, filename, tests)
|
||||
if count_tests(tests) == 0
|
||||
warning_test = {
|
||||
:test => "test_empty_warning",
|
||||
:test => 'test_empty_warning',
|
||||
:line_number => 0
|
||||
}
|
||||
output.puts("\n/*=======Warning Test=====*/")
|
||||
@@ -475,7 +475,7 @@ class UnityTestRunnerGenerator
|
||||
output.puts("}\n")
|
||||
tests = [warning_test]
|
||||
end
|
||||
return tests
|
||||
tests
|
||||
end
|
||||
|
||||
def create_shuffle_tests(output)
|
||||
|
||||
@@ -250,4 +250,12 @@
|
||||
*/
|
||||
/* #define UNITY_INCLUDE_EXEC_TIME */
|
||||
|
||||
/* Define this macro to redefine what the UnityPrintChar() function considers
|
||||
* a printable character.
|
||||
*
|
||||
* Example, for printing UTF-8:
|
||||
* #define UNITY_IS_PRINTABLE_CHAR(c) ((128 <= (c)) && ((c) <= 255))
|
||||
*/
|
||||
/* #define UNITY_IS_PRINTABLE_CHAR(c) ((32 <= (c)) && ((c) <= 126)) */
|
||||
|
||||
#endif /* UNITY_CONFIG_H */
|
||||
|
||||
+9
-1
@@ -7,6 +7,8 @@
|
||||
|
||||
#include "unity.h"
|
||||
|
||||
#include <stdbool.h>
|
||||
|
||||
#ifndef UNITY_PROGMEM
|
||||
#define UNITY_PROGMEM
|
||||
#endif
|
||||
@@ -88,8 +90,14 @@ static const char UNITY_PROGMEM UnityStrDetail2Name[] = " " UNITY_DET
|
||||
/* Local helper function to print characters. */
|
||||
static void UnityPrintChar(const char* pch)
|
||||
{
|
||||
#ifdef UNITY_IS_PRINTABLE_CHAR
|
||||
const int isPrintable = UNITY_IS_PRINTABLE_CHAR(*pch);
|
||||
#else
|
||||
const int isPrintable = ((32 <= *pch) && (*pch <= 126));
|
||||
#endif
|
||||
|
||||
/* printable characters plus CR & LF are printed */
|
||||
if ((*pch <= 126) && (*pch >= 32))
|
||||
if (isPrintable)
|
||||
{
|
||||
UNITY_OUTPUT_CHAR(*pch);
|
||||
}
|
||||
|
||||
+2
-1
@@ -19,6 +19,7 @@ TEMP_DIRS = [
|
||||
|
||||
TEMP_DIRS.each do |dir|
|
||||
directory(dir)
|
||||
CLEAN.include(File.join(dir, '*.*'))
|
||||
CLOBBER.include(dir)
|
||||
end
|
||||
|
||||
@@ -167,7 +168,7 @@ namespace :style do
|
||||
|
||||
desc "Attempt to Autocorrect style"
|
||||
task :auto => ['style:clean'] do
|
||||
execute("rubocop ../auto ../examples ../extras --auto-correct --config .rubocop.yml")
|
||||
execute("rubocop ../auto ../examples ../extras --autocorrect --config .rubocop.yml")
|
||||
report "Autocorrected What We Could."
|
||||
end
|
||||
|
||||
|
||||
Reference in New Issue
Block a user