diff --git a/auto/generate_test_runner.rb b/auto/generate_test_runner.rb index 452fbc82..62eaf95f 100755 --- a/auto/generate_test_runner.rb +++ b/auto/generate_test_runner.rb @@ -407,43 +407,43 @@ def create_reset(output) 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 @@ def create_args_wrappers(output, tests) 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 @@ def create_warning_test(output, filename, tests) output.puts("}\n") tests = [warning_test] end - return tests + tests end def create_shuffle_tests(output) diff --git a/examples/unity_config.h b/examples/unity_config.h index 41195c2b..be746e7f 100644 --- a/examples/unity_config.h +++ b/examples/unity_config.h @@ -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 */ diff --git a/src/unity.c b/src/unity.c index d8a8dd35..68e833cc 100644 --- a/src/unity.c +++ b/src/unity.c @@ -7,6 +7,8 @@ #include "unity.h" +#include + #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); } diff --git a/test/rakefile b/test/rakefile index 0bfa70c5..0bd2782c 100644 --- a/test/rakefile +++ b/test/rakefile @@ -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