diff --git a/lib/cmock_generator_plugin_cexception.rb b/lib/cmock_generator_plugin_cexception.rb index d9299de..c9be80c 100644 --- a/lib/cmock_generator_plugin_cexception.rb +++ b/lib/cmock_generator_plugin_cexception.rb @@ -13,7 +13,7 @@ class CMockGeneratorPluginCexception def include_files include = @config.cexception_include - include = "Exception.h" if (include.nil?) + include = "CException.h" if (include.nil?) return "#include \"#{include}\"\n" end @@ -23,9 +23,9 @@ class CMockGeneratorPluginCexception def mock_function_declarations(function) if (function[:args_string] == "void") - return "void #{function[:name]}_ExpectAndThrow(EXCEPTION_T toThrow);\n" + return "void #{function[:name]}_ExpectAndThrow(CEXCEPTION_T toThrow);\n" else - return "void #{function[:name]}_ExpectAndThrow(#{function[:args_string]}, EXCEPTION_T toThrow);\n" + return "void #{function[:name]}_ExpectAndThrow(#{function[:args_string]}, CEXCEPTION_T toThrow);\n" end end @@ -36,10 +36,10 @@ class CMockGeneratorPluginCexception def mock_interfaces(function) arg_insert = (function[:args_string] == "void") ? "" : "#{function[:args_string]}, " call_string = function[:args].map{|m| m[:name]}.join(', ') - [ "void #{function[:name]}_ExpectAndThrow(#{arg_insert}EXCEPTION_T toThrow)\n{\n", + [ "void #{function[:name]}_ExpectAndThrow(#{arg_insert}CEXCEPTION_T toThrow)\n{\n", @utils.code_add_base_expectation(function[:name]), @utils.code_insert_item_into_expect_array('int', "Mock.#{function[:name]}_ThrowOnCallCount", "Mock.#{function[:name]}_CallsExpected"), - @utils.code_insert_item_into_expect_array('EXCEPTION_T', "Mock.#{function[:name]}_ThrowValue", "toThrow"), + @utils.code_insert_item_into_expect_array('CEXCEPTION_T', "Mock.#{function[:name]}_ThrowValue", "toThrow"), (MOCK_INTERFACE_THROW_HANDLING_SNIPPET % function[:name]), (function[:args_string] != "void") ? " ExpectParameters_#{function[:name]}(#{call_string});\n" : nil, "}\n\n" ].join @@ -55,9 +55,9 @@ class CMockGeneratorPluginCexception int *%1$s_ThrowOnCallCount; int *%1$s_ThrowOnCallCount_Head; int *%1$s_ThrowOnCallCount_Tail; - EXCEPTION_T *%1$s_ThrowValue; - EXCEPTION_T *%1$s_ThrowValue_Head; - EXCEPTION_T *%1$s_ThrowValue_Tail; + CEXCEPTION_T *%1$s_ThrowValue; + CEXCEPTION_T *%1$s_ThrowValue_Head; + CEXCEPTION_T *%1$s_ThrowValue_Tail; ] MOCK_IMPLEMENTATION_SNIPPET = %q[ @@ -67,7 +67,7 @@ class CMockGeneratorPluginCexception if (*Mock.%1$s_ThrowOnCallCount && (Mock.%1$s_CallCount == *Mock.%1$s_ThrowOnCallCount)) { - EXCEPTION_T toThrow = *Mock.%1$s_ThrowValue; + CEXCEPTION_T toThrow = *Mock.%1$s_ThrowValue; Mock.%1$s_ThrowOnCallCount++; Mock.%1$s_ThrowValue++; Throw(toThrow); diff --git a/test/Exception.h b/test/Exception.h deleted file mode 100644 index 2ac40b3..0000000 --- a/test/Exception.h +++ /dev/null @@ -1,8 +0,0 @@ -#ifndef _EXCEPTION_H -#define _EXCEPTION_H - -// Just use defaults -// INCLUDE THE ACTUAL CEXCEPTION LIBRARY -#include "CException.h" - -#endif // _EXCEPTION_H diff --git a/test/system/test_interactions/all_plugins_coexist.yml b/test/system/test_interactions/all_plugins_coexist.yml index 06fdeec..d4e80c6 100644 --- a/test/system/test_interactions/all_plugins_coexist.yml +++ b/test/system/test_interactions/all_plugins_coexist.yml @@ -14,7 +14,7 @@ } POINT_T; :mockable: | - #include "Exception.h" + #include "CException.h" void foo(POINT_T* a); POINT_T* bar(void); void fooa(POINT_T a[]); @@ -25,7 +25,7 @@ :source: :header: | - #include "Exception.h" + #include "CException.h" void function_a(void); void function_b(void); void function_c(void); @@ -42,7 +42,7 @@ } void function_c(void) { - EXCEPTION_T e; + CEXCEPTION_T e; Try { foos(bars()); } Catch(e) { foos("err"); } diff --git a/test/system/test_interactions/enforce_strict_ordering.yml b/test/system/test_interactions/enforce_strict_ordering.yml index d344112..e80a7ab 100644 --- a/test/system/test_interactions/enforce_strict_ordering.yml +++ b/test/system/test_interactions/enforce_strict_ordering.yml @@ -12,14 +12,14 @@ typedef signed int custom_type; :mockable: | - #include "Exception.h" + #include "CException.h" UINT32 foo(custom_type a); UINT32 bar(custom_type b); void baz(custom_type c); :source: :header: | - #include "Exception.h" + #include "CException.h" UINT32 function_a(int a, int b); void function_b(void); void function_c(void); @@ -53,7 +53,7 @@ void function_d(void) { - EXCEPTION_T e; + CEXCEPTION_T e; Try { foo((custom_type)1); diff --git a/test/system/test_interactions/expect_and_throw.yml b/test/system/test_interactions/expect_and_throw.yml index f1d6f42..997e9f3 100644 --- a/test/system/test_interactions/expect_and_throw.yml +++ b/test/system/test_interactions/expect_and_throw.yml @@ -9,14 +9,14 @@ typedef signed int custom_type; :mockable: | - #include "Exception.h" + #include "CException.h" UINT32 foo(custom_type a); UINT32 bar(custom_type b); UINT32 foo_varargs(custom_type a, ...); :source: :header: | - #include "Exception.h" + #include "CException.h" UINT32 function_a(int a); void function_b(char a); @@ -24,7 +24,7 @@ UINT32 function_a(int a) { UINT32 r = 0; - EXCEPTION_T e; + CEXCEPTION_T e; Try { @@ -41,7 +41,7 @@ { if (a) { - Throw((EXCEPTION_T)a); + Throw((CEXCEPTION_T)a); } } @@ -106,7 +106,7 @@ :code: | test() { - EXCEPTION_T e; + CEXCEPTION_T e; Try { function_b(3); diff --git a/test/unit/cmock_generator_plugin_cexception_test.rb b/test/unit/cmock_generator_plugin_cexception_test.rb index 26ffa0f..95438c1 100644 --- a/test/unit/cmock_generator_plugin_cexception_test.rb +++ b/test/unit/cmock_generator_plugin_cexception_test.rb @@ -18,15 +18,15 @@ class CMockGeneratorPluginCexceptionTest < Test::Unit::TestCase end should "include the cexception library" do - expected = "#include \"Exception.h\"\n" + expected = "#include \"CException.h\"\n" @config.expect.cexception_include.returns(nil) returned = @cmock_generator_plugin_cexception.include_files assert_equal(expected, returned) end should "include the cexception library with a custom path if specified" do - expected = "#include \"../cexception/lib/Exception.h\"\n" - @config.expect.cexception_include.returns("../cexception/lib/Exception.h") + expected = "#include \"../cexception/lib/CException.h\"\n" + @config.expect.cexception_include.returns("../cexception/lib/CException.h") returned = @cmock_generator_plugin_cexception.include_files assert_equal(expected, returned) end @@ -37,9 +37,9 @@ class CMockGeneratorPluginCexceptionTest < Test::Unit::TestCase " int *Oak_ThrowOnCallCount;\n", " int *Oak_ThrowOnCallCount_Head;\n", " int *Oak_ThrowOnCallCount_Tail;\n", - " EXCEPTION_T *Oak_ThrowValue;\n", - " EXCEPTION_T *Oak_ThrowValue_Head;\n", - " EXCEPTION_T *Oak_ThrowValue_Tail;\n" + " CEXCEPTION_T *Oak_ThrowValue;\n", + " CEXCEPTION_T *Oak_ThrowValue_Head;\n", + " CEXCEPTION_T *Oak_ThrowValue_Tail;\n" ].join returned = @cmock_generator_plugin_cexception.instance_structure(function) assert_equal(expected, returned) @@ -47,14 +47,14 @@ class CMockGeneratorPluginCexceptionTest < Test::Unit::TestCase should "add mock function declarations for functions without arguments" do function = { :name => "Spruce", :args_string => "void", :return_type => "void" } - expected = "void Spruce_ExpectAndThrow(EXCEPTION_T toThrow);\n" + expected = "void Spruce_ExpectAndThrow(CEXCEPTION_T toThrow);\n" returned = @cmock_generator_plugin_cexception.mock_function_declarations(function) assert_equal(expected, returned) end should "add mock function declarations for functions with arguments" do function = { :name => "Spruce", :args_string => "const char* Petunia, uint32_t Lily", :return_type => "void" } - expected = "void Spruce_ExpectAndThrow(const char* Petunia, uint32_t Lily, EXCEPTION_T toThrow);\n" + expected = "void Spruce_ExpectAndThrow(const char* Petunia, uint32_t Lily, CEXCEPTION_T toThrow);\n" returned = @cmock_generator_plugin_cexception.mock_function_declarations(function) assert_equal(expected, returned) end @@ -68,7 +68,7 @@ class CMockGeneratorPluginCexceptionTest < Test::Unit::TestCase " if (*Mock.Cherry_ThrowOnCallCount &&\n", " (Mock.Cherry_CallCount == *Mock.Cherry_ThrowOnCallCount))\n", " {\n", - " EXCEPTION_T toThrow = *Mock.Cherry_ThrowValue;\n", + " CEXCEPTION_T toThrow = *Mock.Cherry_ThrowValue;\n", " Mock.Cherry_ThrowOnCallCount++;\n", " Mock.Cherry_ThrowValue++;\n", " Throw(toThrow);\n", @@ -83,9 +83,9 @@ class CMockGeneratorPluginCexceptionTest < Test::Unit::TestCase function = {:name => "Pear", :args_string => "void", :args => [], :return_type => "void"} @utils.expect.code_add_base_expectation("Pear").returns("mock_retval_0") @utils.expect.code_insert_item_into_expect_array("int", "Mock.Pear_ThrowOnCallCount", "Mock.Pear_CallsExpected").returns("mock_return_1") - @utils.expect.code_insert_item_into_expect_array("EXCEPTION_T", "Mock.Pear_ThrowValue", "toThrow").returns("mock_return_2") + @utils.expect.code_insert_item_into_expect_array("CEXCEPTION_T", "Mock.Pear_ThrowValue", "toThrow").returns("mock_return_2") - expected = ["void Pear_ExpectAndThrow(EXCEPTION_T toThrow)\n", + expected = ["void Pear_ExpectAndThrow(CEXCEPTION_T toThrow)\n", "{\n", "mock_retval_0", "mock_return_1", @@ -108,9 +108,9 @@ class CMockGeneratorPluginCexceptionTest < Test::Unit::TestCase function = {:name => "Pear", :args_string => "int blah", :args => [{ :type => "int", :name => "blah" }], :return_type => "void"} @utils.expect.code_add_base_expectation("Pear").returns("mock_retval_0") @utils.expect.code_insert_item_into_expect_array("int", "Mock.Pear_ThrowOnCallCount", "Mock.Pear_CallsExpected").returns("mock_return_1") - @utils.expect.code_insert_item_into_expect_array("EXCEPTION_T", "Mock.Pear_ThrowValue", "toThrow").returns("mock_return_2") + @utils.expect.code_insert_item_into_expect_array("CEXCEPTION_T", "Mock.Pear_ThrowValue", "toThrow").returns("mock_return_2") - expected = ["void Pear_ExpectAndThrow(int blah, EXCEPTION_T toThrow)\n", + expected = ["void Pear_ExpectAndThrow(int blah, CEXCEPTION_T toThrow)\n", "{\n", "mock_retval_0", "mock_return_1",