ceedling 0.17.0 → 0.18.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/ceedling.gemspec +1 -1
- data/lib/ceedling/version.rb +2 -2
- data/lib/ceedling/version.rb.erb +1 -2
- data/test_graveyard/unit/busted/generator_test_runner_test.rb +2 -5
- data/vendor/cmock/Gemfile +1 -3
- data/vendor/cmock/Rakefile +10 -17
- data/vendor/cmock/docs/license.txt +18 -30
- data/vendor/cmock/examples/gcc.yml +2 -2
- data/vendor/cmock/examples/iar_v4.yml +3 -3
- data/vendor/cmock/examples/iar_v5.yml +3 -3
- data/vendor/cmock/examples/rakefile_helper.rb +35 -35
- data/vendor/cmock/lib/cmock_generator.rb +17 -5
- data/vendor/cmock/lib/cmock_generator_plugin_array.rb +9 -3
- data/vendor/cmock/lib/cmock_generator_plugin_ignore_arg.rb +1 -1
- data/vendor/cmock/lib/cmock_generator_plugin_return_thru_ptr.rb +1 -1
- data/vendor/cmock/lib/cmock_header_parser.rb +7 -3
- data/vendor/cmock/release/version.info +1 -1
- data/vendor/cmock/test/c/TestCMockCDynamic_Runner.c +1 -2
- data/vendor/cmock/test/c/TestCMockC_Runner.c +1 -1
- data/vendor/cmock/test/system/systest_generator.rb +6 -2
- data/vendor/cmock/test/system/test_compilation/const.h +3 -1
- data/vendor/cmock/test/test_helper.rb +38 -40
- data/vendor/cmock/test/unit/cmock_config_test.rb +26 -29
- data/vendor/cmock/test/unit/cmock_file_writer_test.rb +8 -11
- data/vendor/cmock/test/unit/cmock_generator_main_test.rb +82 -80
- data/vendor/cmock/test/unit/cmock_generator_plugin_array_test.rb +62 -43
- data/vendor/cmock/test/unit/cmock_generator_plugin_callback_test.rb +44 -45
- data/vendor/cmock/test/unit/cmock_generator_plugin_cexception_test.rb +30 -31
- data/vendor/cmock/test/unit/cmock_generator_plugin_expect_any_args_test.rb +15 -16
- data/vendor/cmock/test/unit/cmock_generator_plugin_expect_test.rb +76 -77
- data/vendor/cmock/test/unit/cmock_generator_plugin_ignore_arg_test.rb +19 -19
- data/vendor/cmock/test/unit/cmock_generator_plugin_ignore_test.rb +17 -18
- data/vendor/cmock/test/unit/cmock_generator_plugin_return_thru_ptr_test.rb +17 -17
- data/vendor/cmock/test/unit/cmock_generator_utils_test.rb +74 -65
- data/vendor/cmock/test/unit/cmock_header_parser_test.rb +103 -76
- data/vendor/cmock/test/unit/cmock_plugin_manager_test.rb +46 -36
- data/vendor/cmock/test/unit/cmock_unityhelper_parser_test.rb +85 -85
- data/vendor/unity/auto/generate_test_runner.rb +4 -3
- data/vendor/unity/auto/type_sanitizer.rb +8 -0
- data/vendor/unity/auto/unity_test_summary.py +135 -0
- data/vendor/unity/examples/example_1/makefile +16 -0
- data/vendor/unity/examples/example_1/src/ProductionCode2.c +2 -0
- data/vendor/unity/examples/example_1/test/test_runners/TestProductionCode2_Runner.c +0 -13
- data/vendor/unity/examples/example_1/test/test_runners/TestProductionCode_Runner.c +0 -13
- data/vendor/unity/examples/example_2/makefile +20 -1
- data/vendor/unity/examples/example_2/src/ProductionCode2.c +2 -0
- data/vendor/unity/examples/example_2/test/test_runners/all_tests.c +2 -2
- data/vendor/unity/examples/example_3/makefile +16 -0
- data/vendor/unity/examples/example_3/src/ProductionCode2.c +2 -0
- data/vendor/unity/examples/example_3/test/no_ruby/TestProductionCode2_Runner.c +0 -13
- data/vendor/unity/examples/example_3/test/no_ruby/TestProductionCode_Runner.c +0 -13
- data/vendor/unity/extras/fixture/rakefile.rb +14 -3
- data/vendor/unity/extras/fixture/src/unity_fixture.c +21 -11
- data/vendor/unity/extras/fixture/src/unity_fixture.h +8 -4
- data/vendor/unity/extras/fixture/src/unity_fixture_internals.h +1 -1
- data/vendor/unity/extras/fixture/src/unity_fixture_malloc_overrides.h +5 -0
- data/vendor/unity/extras/fixture/test/main/AllTests.c +2 -2
- data/vendor/unity/extras/fixture/test/unity_fixture_Test.c +8 -8
- data/vendor/unity/extras/fixture/test/unity_output_Spy.c +2 -2
- data/vendor/unity/extras/fixture/test/unity_output_Spy.h +2 -2
- data/vendor/unity/release/version.info +1 -1
- data/vendor/unity/src/unity.c +26 -19
- data/vendor/unity/src/unity_internals.h +9 -12
- data/vendor/unity/test/targets/gcc_auto_stdint.yml +13 -0
- metadata +4 -5
- data/vendor/cmock/test/spec/cmock_file_writer_spec.rb +0 -45
- data/vendor/cmock/test/spec/cmock_generator_plugin_array_spec.rb +0 -52
- data/vendor/cmock/test/spec/spec_helper.rb +0 -12
@@ -2,51 +2,50 @@
|
|
2
2
|
# CMock Project - Automatic Mock Generation for C
|
3
3
|
# Copyright (c) 2007 Mike Karlesky, Mark VanderVoord, Greg Williams
|
4
4
|
# [Released under MIT License. Please refer to license.txt for details]
|
5
|
-
# ==========================================
|
5
|
+
# ==========================================
|
6
6
|
|
7
7
|
require File.expand_path(File.dirname(__FILE__)) + "/../test_helper"
|
8
8
|
require 'cmock_generator_plugin_callback'
|
9
9
|
|
10
|
-
|
11
|
-
|
10
|
+
describe CMockGeneratorPluginCallback, "Verify CMockGeneratorPluginCallback Module" do
|
11
|
+
|
12
|
+
before do
|
12
13
|
create_mocks :config, :utils
|
13
|
-
|
14
|
-
@config.expect
|
15
|
-
@config.expect
|
16
|
-
|
14
|
+
|
15
|
+
@config.expect :callback_include_count, true
|
16
|
+
@config.expect :callback_after_arg_check, false
|
17
|
+
|
17
18
|
@cmock_generator_plugin_callback = CMockGeneratorPluginCallback.new(@config, @utils)
|
18
19
|
end
|
19
20
|
|
20
|
-
|
21
|
+
after do
|
21
22
|
end
|
22
|
-
|
23
|
-
|
24
|
-
assert_equal(
|
25
|
-
assert_equal(@utils, @cmock_generator_plugin_callback.utils)
|
26
|
-
assert_equal(6, @cmock_generator_plugin_callback.priority)
|
23
|
+
|
24
|
+
it "have set up internal priority" do
|
25
|
+
assert_equal(6, @cmock_generator_plugin_callback.priority)
|
27
26
|
end
|
28
|
-
|
29
|
-
|
27
|
+
|
28
|
+
it "not include any additional include files" do
|
30
29
|
assert(!@cmock_generator_plugin_callback.respond_to?(:include_files))
|
31
30
|
end
|
32
|
-
|
33
|
-
|
31
|
+
|
32
|
+
it "add to instance structure" do
|
34
33
|
function = {:name => "Oak", :args => [:type => "int*", :name => "blah", :ptr? => true], :return => test_return[:int_ptr]}
|
35
34
|
expected = " CMOCK_Oak_CALLBACK Oak_CallbackFunctionPointer;\n" +
|
36
35
|
" int Oak_CallbackCalls;\n"
|
37
36
|
returned = @cmock_generator_plugin_callback.instance_structure(function)
|
38
37
|
assert_equal(expected, returned)
|
39
38
|
end
|
40
|
-
|
41
|
-
|
39
|
+
|
40
|
+
it "add mock function declaration for function without arguments" do
|
42
41
|
function = {:name => "Maple", :args_string => "void", :args => [], :return => test_return[:void]}
|
43
42
|
expected = [ "typedef void (* CMOCK_Maple_CALLBACK)(int cmock_num_calls);\n",
|
44
43
|
"void Maple_StubWithCallback(CMOCK_Maple_CALLBACK Callback);\n" ].join
|
45
44
|
returned = @cmock_generator_plugin_callback.mock_function_declarations(function)
|
46
45
|
assert_equal(expected, returned)
|
47
46
|
end
|
48
|
-
|
49
|
-
|
47
|
+
|
48
|
+
it "add mock function declaration for function without arguments when count is also turned off" do
|
50
49
|
function = {:name => "Maple", :args_string => "void", :args => [], :return => test_return[:void]}
|
51
50
|
expected = [ "typedef void (* CMOCK_Maple_CALLBACK)(void);\n",
|
52
51
|
"void Maple_StubWithCallback(CMOCK_Maple_CALLBACK Callback);\n" ].join
|
@@ -54,24 +53,24 @@ class CMockGeneratorPluginCallbackTest < Test::Unit::TestCase
|
|
54
53
|
returned = @cmock_generator_plugin_callback.mock_function_declarations(function)
|
55
54
|
assert_equal(expected, returned)
|
56
55
|
end
|
57
|
-
|
58
|
-
|
56
|
+
|
57
|
+
it "add mock function declaration for function with arguments" do
|
59
58
|
function = {:name => "Maple", :args_string => "int* tofu", :args => [1], :return => test_return[:void]}
|
60
59
|
expected = [ "typedef void (* CMOCK_Maple_CALLBACK)(int* tofu, int cmock_num_calls);\n",
|
61
60
|
"void Maple_StubWithCallback(CMOCK_Maple_CALLBACK Callback);\n" ].join
|
62
61
|
returned = @cmock_generator_plugin_callback.mock_function_declarations(function)
|
63
62
|
assert_equal(expected, returned)
|
64
63
|
end
|
65
|
-
|
66
|
-
|
64
|
+
|
65
|
+
it "add mock function declaration for function with return values" do
|
67
66
|
function = {:name => "Maple", :args_string => "int* tofu", :args => [1], :return => test_return[:string]}
|
68
67
|
expected = [ "typedef const char* (* CMOCK_Maple_CALLBACK)(int* tofu, int cmock_num_calls);\n",
|
69
68
|
"void Maple_StubWithCallback(CMOCK_Maple_CALLBACK Callback);\n" ].join
|
70
69
|
returned = @cmock_generator_plugin_callback.mock_function_declarations(function)
|
71
70
|
assert_equal(expected, returned)
|
72
71
|
end
|
73
|
-
|
74
|
-
|
72
|
+
|
73
|
+
it "add mock function declaration for function with return values and count is turned off" do
|
75
74
|
function = {:name => "Maple", :args_string => "int* tofu", :args => [1], :return => test_return[:string]}
|
76
75
|
expected = [ "typedef const char* (* CMOCK_Maple_CALLBACK)(int* tofu);\n",
|
77
76
|
"void Maple_StubWithCallback(CMOCK_Maple_CALLBACK Callback);\n" ].join
|
@@ -80,7 +79,7 @@ class CMockGeneratorPluginCallbackTest < Test::Unit::TestCase
|
|
80
79
|
assert_equal(expected, returned)
|
81
80
|
end
|
82
81
|
|
83
|
-
|
82
|
+
it "add mock function implementation for functions of style 'void func(void)'" do
|
84
83
|
function = {:name => "Apple", :args => [], :args_string => "void", :return => test_return[:void]}
|
85
84
|
expected = [" if (Mock.Apple_CallbackFunctionPointer != NULL)\n",
|
86
85
|
" {\n",
|
@@ -92,7 +91,7 @@ class CMockGeneratorPluginCallbackTest < Test::Unit::TestCase
|
|
92
91
|
assert_equal(expected, returned)
|
93
92
|
end
|
94
93
|
|
95
|
-
|
94
|
+
it "add mock function implementation for functions of style 'void func(void)' when count turned off" do
|
96
95
|
function = {:name => "Apple", :args => [], :args_string => "void", :return => test_return[:void]}
|
97
96
|
expected = [" if (Mock.Apple_CallbackFunctionPointer != NULL)\n",
|
98
97
|
" {\n",
|
@@ -105,7 +104,7 @@ class CMockGeneratorPluginCallbackTest < Test::Unit::TestCase
|
|
105
104
|
assert_equal(expected, returned)
|
106
105
|
end
|
107
106
|
|
108
|
-
|
107
|
+
it "add mock function implementation for functions of style 'int func(void)'" do
|
109
108
|
function = {:name => "Apple", :args => [], :args_string => "void", :return => test_return[:int]}
|
110
109
|
expected = [" if (Mock.Apple_CallbackFunctionPointer != NULL)\n",
|
111
110
|
" {\n",
|
@@ -116,10 +115,10 @@ class CMockGeneratorPluginCallbackTest < Test::Unit::TestCase
|
|
116
115
|
assert_equal(expected, returned)
|
117
116
|
end
|
118
117
|
|
119
|
-
|
120
|
-
function = {:name => "Apple",
|
118
|
+
it "add mock function implementation for functions of style 'void func(int* steak, uint8_t flag)'" do
|
119
|
+
function = {:name => "Apple",
|
121
120
|
:args => [ { :type => 'int*', :name => 'steak', :ptr? => true},
|
122
|
-
{ :type => 'uint8_t', :name => 'flag', :ptr? => false} ],
|
121
|
+
{ :type => 'uint8_t', :name => 'flag', :ptr? => false} ],
|
123
122
|
:args_string => "int* steak, uint8_t flag",
|
124
123
|
:return=> test_return[:void]}
|
125
124
|
expected = [" if (Mock.Apple_CallbackFunctionPointer != NULL)\n",
|
@@ -132,10 +131,10 @@ class CMockGeneratorPluginCallbackTest < Test::Unit::TestCase
|
|
132
131
|
assert_equal(expected, returned)
|
133
132
|
end
|
134
133
|
|
135
|
-
|
136
|
-
function = {:name => "Apple",
|
134
|
+
it "add mock function implementation for functions of style 'void func(int* steak, uint8_t flag)' when count turned off" do
|
135
|
+
function = {:name => "Apple",
|
137
136
|
:args => [ { :type => 'int*', :name => 'steak', :ptr? => true},
|
138
|
-
{ :type => 'uint8_t', :name => 'flag', :ptr? => false} ],
|
137
|
+
{ :type => 'uint8_t', :name => 'flag', :ptr? => false} ],
|
139
138
|
:args_string => "int* steak, uint8_t flag",
|
140
139
|
:return=> test_return[:void]}
|
141
140
|
expected = [" if (Mock.Apple_CallbackFunctionPointer != NULL)\n",
|
@@ -149,11 +148,11 @@ class CMockGeneratorPluginCallbackTest < Test::Unit::TestCase
|
|
149
148
|
assert_equal(expected, returned)
|
150
149
|
end
|
151
150
|
|
152
|
-
|
153
|
-
function = {:name => "Apple",
|
151
|
+
it "add mock function implementation for functions of style 'int16_t func(int* steak, uint8_t flag)'" do
|
152
|
+
function = {:name => "Apple",
|
154
153
|
:args => [ { :type => 'int*', :name => 'steak', :ptr? => true},
|
155
154
|
{ :type => 'uint8_t', :name => 'flag', :ptr? => false} ],
|
156
|
-
:args_string => "int* steak, uint8_t flag",
|
155
|
+
:args_string => "int* steak, uint8_t flag",
|
157
156
|
:return => test_return[:int]}
|
158
157
|
expected = [" if (Mock.Apple_CallbackFunctionPointer != NULL)\n",
|
159
158
|
" {\n",
|
@@ -163,14 +162,14 @@ class CMockGeneratorPluginCallbackTest < Test::Unit::TestCase
|
|
163
162
|
returned = @cmock_generator_plugin_callback.mock_implementation_precheck(function)
|
164
163
|
assert_equal(expected, returned)
|
165
164
|
end
|
166
|
-
|
167
|
-
|
168
|
-
function = {:name => "Lemon",
|
169
|
-
:args => [{ :type => "char*", :name => "pescado"}],
|
165
|
+
|
166
|
+
it "add mock interfaces for functions " do
|
167
|
+
function = {:name => "Lemon",
|
168
|
+
:args => [{ :type => "char*", :name => "pescado"}],
|
170
169
|
:args_string => "char* pescado",
|
171
170
|
:return => test_return[:int]
|
172
171
|
}
|
173
|
-
|
172
|
+
|
174
173
|
expected = ["void Lemon_StubWithCallback(CMOCK_Lemon_CALLBACK Callback)\n",
|
175
174
|
"{\n",
|
176
175
|
" Mock.Lemon_CallbackFunctionPointer = Callback;\n",
|
@@ -180,7 +179,7 @@ class CMockGeneratorPluginCallbackTest < Test::Unit::TestCase
|
|
180
179
|
assert_equal(expected, returned)
|
181
180
|
end
|
182
181
|
|
183
|
-
|
182
|
+
it "add mock destroy for functions" do
|
184
183
|
function = {:name => "Peach", :args => [], :return => test_return[:void] }
|
185
184
|
expected = " Mock.Peach_CallbackFunctionPointer = NULL;\n" +
|
186
185
|
" Mock.Peach_CallbackCalls = 0;\n"
|
@@ -2,68 +2,67 @@
|
|
2
2
|
# CMock Project - Automatic Mock Generation for C
|
3
3
|
# Copyright (c) 2007 Mike Karlesky, Mark VanderVoord, Greg Williams
|
4
4
|
# [Released under MIT License. Please refer to license.txt for details]
|
5
|
-
# ==========================================
|
5
|
+
# ==========================================
|
6
6
|
|
7
7
|
require File.expand_path(File.dirname(__FILE__)) + "/../test_helper"
|
8
8
|
require 'cmock_generator_plugin_cexception'
|
9
9
|
|
10
|
-
|
11
|
-
|
10
|
+
describe CMockGeneratorPluginCexception, "Verify CMockGeneratorPluginCexception Module" do
|
11
|
+
|
12
|
+
before do
|
12
13
|
create_mocks :config, :utils
|
13
14
|
@cmock_generator_plugin_cexception = CMockGeneratorPluginCexception.new(@config, @utils)
|
14
15
|
end
|
15
16
|
|
16
|
-
|
17
|
+
after do
|
17
18
|
end
|
18
|
-
|
19
|
-
|
20
|
-
assert_equal(
|
21
|
-
assert_equal(@utils, @cmock_generator_plugin_cexception.utils)
|
22
|
-
assert_equal(7, @cmock_generator_plugin_cexception.priority)
|
19
|
+
|
20
|
+
it "have set up internal priority" do
|
21
|
+
assert_equal(7, @cmock_generator_plugin_cexception.priority)
|
23
22
|
end
|
24
|
-
|
25
|
-
|
23
|
+
|
24
|
+
it "include the cexception library" do
|
26
25
|
expected = "#include \"CException.h\"\n"
|
27
26
|
returned = @cmock_generator_plugin_cexception.include_files
|
28
27
|
assert_equal(expected, returned)
|
29
28
|
end
|
30
|
-
|
31
|
-
|
29
|
+
|
30
|
+
it "add to typedef structure mock needs" do
|
32
31
|
function = { :name => "Oak", :args => [], :return => test_return[:void] }
|
33
32
|
expected = " CEXCEPTION_T ExceptionToThrow;\n"
|
34
33
|
returned = @cmock_generator_plugin_cexception.instance_typedefs(function)
|
35
34
|
assert_equal(expected, returned)
|
36
35
|
end
|
37
|
-
|
38
|
-
|
36
|
+
|
37
|
+
it "add mock function declarations for functions without arguments" do
|
39
38
|
function = { :name => "Spruce", :args_string => "void", :return => test_return[:void] }
|
40
39
|
expected = "#define Spruce_ExpectAndThrow(cmock_to_throw) Spruce_CMockExpectAndThrow(__LINE__, cmock_to_throw)\n"+
|
41
40
|
"void Spruce_CMockExpectAndThrow(UNITY_LINE_TYPE cmock_line, CEXCEPTION_T cmock_to_throw);\n"
|
42
41
|
returned = @cmock_generator_plugin_cexception.mock_function_declarations(function)
|
43
42
|
assert_equal(expected, returned)
|
44
43
|
end
|
45
|
-
|
46
|
-
|
44
|
+
|
45
|
+
it "add mock function declarations for functions with arguments" do
|
47
46
|
function = { :name => "Spruce", :args_string => "const char* Petunia, uint32_t Lily", :args_call => "Petunia, Lily", :return => test_return[:void] }
|
48
47
|
expected = "#define Spruce_ExpectAndThrow(Petunia, Lily, cmock_to_throw) Spruce_CMockExpectAndThrow(__LINE__, Petunia, Lily, cmock_to_throw)\n" +
|
49
48
|
"void Spruce_CMockExpectAndThrow(UNITY_LINE_TYPE cmock_line, const char* Petunia, uint32_t Lily, CEXCEPTION_T cmock_to_throw);\n"
|
50
49
|
returned = @cmock_generator_plugin_cexception.mock_function_declarations(function)
|
51
50
|
assert_equal(expected, returned)
|
52
51
|
end
|
53
|
-
|
54
|
-
|
52
|
+
|
53
|
+
it "add a mock implementation" do
|
55
54
|
function = {:name => "Cherry", :args => [], :return => test_return[:void]}
|
56
|
-
expected = " if (cmock_call_instance->ExceptionToThrow != CEXCEPTION_NONE)\n {\n" +
|
55
|
+
expected = " if (cmock_call_instance->ExceptionToThrow != CEXCEPTION_NONE)\n {\n" +
|
57
56
|
" Throw(cmock_call_instance->ExceptionToThrow);\n }\n"
|
58
57
|
returned = @cmock_generator_plugin_cexception.mock_implementation(function)
|
59
58
|
assert_equal(expected, returned)
|
60
59
|
end
|
61
|
-
|
62
|
-
|
60
|
+
|
61
|
+
it "add mock interfaces for functions without arguments" do
|
63
62
|
function = {:name => "Pear", :args_string => "void", :args => [], :return => test_return[:void]}
|
64
|
-
@utils.expect
|
65
|
-
@utils.expect
|
66
|
-
|
63
|
+
@utils.expect :code_add_base_expectation, "mock_retval_0", ["Pear"]
|
64
|
+
@utils.expect :code_call_argument_loader, "", [function]
|
65
|
+
|
67
66
|
expected = ["void Pear_CMockExpectAndThrow(UNITY_LINE_TYPE cmock_line, CEXCEPTION_T cmock_to_throw)\n",
|
68
67
|
"{\n",
|
69
68
|
"mock_retval_0",
|
@@ -74,12 +73,12 @@ class CMockGeneratorPluginCexceptionTest < Test::Unit::TestCase
|
|
74
73
|
returned = @cmock_generator_plugin_cexception.mock_interfaces(function)
|
75
74
|
assert_equal(expected, returned)
|
76
75
|
end
|
77
|
-
|
78
|
-
|
76
|
+
|
77
|
+
it "add a mock interfaces for functions with arguments" do
|
79
78
|
function = {:name => "Pear", :args_string => "int blah", :args => [{ :type => "int", :name => "blah" }], :return => test_return[:void]}
|
80
|
-
@utils.expect
|
81
|
-
@utils.expect
|
82
|
-
|
79
|
+
@utils.expect :code_add_base_expectation, "mock_retval_0", ["Pear"]
|
80
|
+
@utils.expect :code_call_argument_loader, "mock_return_1", [function]
|
81
|
+
|
83
82
|
expected = ["void Pear_CMockExpectAndThrow(UNITY_LINE_TYPE cmock_line, int blah, CEXCEPTION_T cmock_to_throw)\n",
|
84
83
|
"{\n",
|
85
84
|
"mock_retval_0",
|
@@ -90,5 +89,5 @@ class CMockGeneratorPluginCexceptionTest < Test::Unit::TestCase
|
|
90
89
|
returned = @cmock_generator_plugin_cexception.mock_interfaces(function)
|
91
90
|
assert_equal(expected, returned)
|
92
91
|
end
|
93
|
-
|
92
|
+
|
94
93
|
end
|
@@ -7,34 +7,33 @@
|
|
7
7
|
require File.expand_path(File.dirname(__FILE__)) + "/../test_helper"
|
8
8
|
require 'cmock_generator_plugin_expect_any_args.rb'
|
9
9
|
|
10
|
-
|
11
|
-
|
10
|
+
describe CMockGeneratorPluginExpectAnyArgs, "Verify CMockGeneratorPluginExpectAnyArgs Module" do
|
11
|
+
|
12
|
+
before do
|
12
13
|
create_mocks :config, :utils
|
13
|
-
@config
|
14
|
+
@config = create_stub(:respond_to? => true)
|
14
15
|
@cmock_generator_plugin_expect_any_args = CMockGeneratorPluginExpectAnyArgs.new(@config, @utils)
|
15
16
|
end
|
16
17
|
|
17
|
-
|
18
|
+
after do
|
18
19
|
end
|
19
20
|
|
20
|
-
|
21
|
-
assert_equal(
|
22
|
-
assert_equal(@utils, @cmock_generator_plugin_expect_any_args.utils)
|
23
|
-
assert_equal(3, @cmock_generator_plugin_expect_any_args.priority)
|
21
|
+
it "have set up internal priority" do
|
22
|
+
assert_equal(3, @cmock_generator_plugin_expect_any_args.priority)
|
24
23
|
end
|
25
24
|
|
26
|
-
|
25
|
+
it "not have any additional include file requirements" do
|
27
26
|
assert(!@cmock_generator_plugin_expect_any_args.respond_to?(:include_files))
|
28
27
|
end
|
29
28
|
|
30
|
-
|
29
|
+
it "handle function declarations for functions without return values" do
|
31
30
|
function = {:name => "Mold", :args_string => "void", :return => test_return[:void]}
|
32
31
|
expected = "#define Mold_ExpectAnyArgs() Mold_CMockExpectAnyArgs(__LINE__)\nvoid Mold_CMockExpectAnyArgs(UNITY_LINE_TYPE cmock_line);\n"
|
33
32
|
returned = @cmock_generator_plugin_expect_any_args.mock_function_declarations(function)
|
34
33
|
assert_equal(expected, returned)
|
35
34
|
end
|
36
35
|
|
37
|
-
|
36
|
+
it "handle function declarations for functions that returns something" do
|
38
37
|
function = {:name => "Fungus", :args_string => "void", :return => test_return[:string]}
|
39
38
|
expected = "#define Fungus_ExpectAnyArgsAndReturn(cmock_retval) Fungus_CMockExpectAnyArgsAndReturn(__LINE__, cmock_retval)\n"+
|
40
39
|
"void Fungus_CMockExpectAnyArgsAndReturn(UNITY_LINE_TYPE cmock_line, const char* cmock_to_return);\n"
|
@@ -42,7 +41,7 @@ class CMockGeneratorPluginExpectAnyArgsTest < Test::Unit::TestCase
|
|
42
41
|
assert_equal(expected, returned)
|
43
42
|
end
|
44
43
|
|
45
|
-
|
44
|
+
it "add required code to implementation with void function" do
|
46
45
|
function = {:name => "Mold", :args_string => "void", :return => test_return[:void]}
|
47
46
|
expected = [" if (cmock_call_instance->IgnoreMode == CMOCK_ARG_NONE)\n",
|
48
47
|
" {\n",
|
@@ -53,10 +52,10 @@ class CMockGeneratorPluginExpectAnyArgsTest < Test::Unit::TestCase
|
|
53
52
|
assert_equal(expected, returned)
|
54
53
|
end
|
55
54
|
|
56
|
-
|
55
|
+
it "add required code to implementation with return functions" do
|
57
56
|
function = {:name => "Fungus", :args_string => "void", :return => test_return[:int]}
|
58
57
|
retval = test_return[:int].merge({ :name => "cmock_call_instance->ReturnVal"})
|
59
|
-
@utils.expect
|
58
|
+
@utils.expect :code_assign_argument_quickly, ' mock_retval_0', ["Mock.Fungus_FinalReturn", retval]
|
60
59
|
expected = [" if (cmock_call_instance->IgnoreMode == CMOCK_ARG_NONE)\n",
|
61
60
|
" {\n",
|
62
61
|
" mock_retval_0",
|
@@ -67,7 +66,7 @@ class CMockGeneratorPluginExpectAnyArgsTest < Test::Unit::TestCase
|
|
67
66
|
assert_equal(expected, returned)
|
68
67
|
end
|
69
68
|
|
70
|
-
|
69
|
+
it "add a new mock interface for ignoring when function had no return value" do
|
71
70
|
function = {:name => "Slime", :args => [], :args_string => "void", :return => test_return[:void]}
|
72
71
|
expected = ["void Slime_CMockExpectAnyArgs(UNITY_LINE_TYPE cmock_line)\n",
|
73
72
|
"{\n",
|
@@ -75,7 +74,7 @@ class CMockGeneratorPluginExpectAnyArgsTest < Test::Unit::TestCase
|
|
75
74
|
" cmock_call_instance->IgnoreMode = CMOCK_ARG_NONE;\n",
|
76
75
|
"}\n\n"
|
77
76
|
].join
|
78
|
-
@utils.expect
|
77
|
+
@utils.expect :code_add_base_expectation, "mock_return_1", ["Slime", true]
|
79
78
|
returned = @cmock_generator_plugin_expect_any_args.mock_interfaces(function)
|
80
79
|
assert_equal(expected, returned)
|
81
80
|
end
|
@@ -2,143 +2,142 @@
|
|
2
2
|
# CMock Project - Automatic Mock Generation for C
|
3
3
|
# Copyright (c) 2007 Mike Karlesky, Mark VanderVoord, Greg Williams
|
4
4
|
# [Released under MIT License. Please refer to license.txt for details]
|
5
|
-
# ==========================================
|
5
|
+
# ==========================================
|
6
6
|
|
7
7
|
require File.expand_path(File.dirname(__FILE__)) + "/../test_helper"
|
8
8
|
require 'cmock_generator_plugin_expect'
|
9
9
|
|
10
|
-
|
11
|
-
|
10
|
+
describe CMockGeneratorPluginExpect, "Verify CMockGeneratorPluginExpect Module" do
|
11
|
+
|
12
|
+
before do
|
12
13
|
create_mocks :config, :utils
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
@utils.expect
|
14
|
+
|
15
|
+
@config = create_stub(
|
16
|
+
:when_ptr => :compare_data,
|
17
|
+
:enforce_strict_ordering => false,
|
18
|
+
:respond_to? => true )
|
19
|
+
|
20
|
+
@utils.expect :helpers, {}
|
20
21
|
@cmock_generator_plugin_expect = CMockGeneratorPluginExpect.new(@config, @utils)
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
@utils.expect
|
28
|
-
@cmock_generator_plugin_expect_strict = CMockGeneratorPluginExpect.new(@
|
29
|
-
end
|
30
|
-
|
31
|
-
|
32
|
-
end
|
33
|
-
|
34
|
-
|
35
|
-
assert_equal(@config, @cmock_generator_plugin_expect.config)
|
36
|
-
assert_equal(@utils, @cmock_generator_plugin_expect.utils)
|
22
|
+
|
23
|
+
@config_strict = create_stub(
|
24
|
+
:when_ptr => :compare_data,
|
25
|
+
:enforce_strict_ordering => true,
|
26
|
+
:respond_to? => true )
|
27
|
+
|
28
|
+
@utils.expect :helpers, {}
|
29
|
+
@cmock_generator_plugin_expect_strict = CMockGeneratorPluginExpect.new(@config_strict, @utils)
|
30
|
+
end
|
31
|
+
|
32
|
+
after do
|
33
|
+
end
|
34
|
+
|
35
|
+
it "have set up internal priority on init" do
|
37
36
|
assert_equal(nil, @cmock_generator_plugin_expect.unity_helper)
|
38
37
|
assert_equal(5, @cmock_generator_plugin_expect.priority)
|
39
38
|
end
|
40
|
-
|
41
|
-
|
39
|
+
|
40
|
+
it "not include any additional include files" do
|
42
41
|
assert(!@cmock_generator_plugin_expect.respond_to?(:include_files))
|
43
42
|
end
|
44
|
-
|
45
|
-
|
43
|
+
|
44
|
+
it "add to typedef structure mock needs of functions of style 'void func(void)'" do
|
46
45
|
function = {:name => "Oak", :args => [], :return => test_return[:void]}
|
47
46
|
expected = ""
|
48
47
|
returned = @cmock_generator_plugin_expect.instance_typedefs(function)
|
49
48
|
assert_equal(expected, returned)
|
50
49
|
end
|
51
|
-
|
52
|
-
|
50
|
+
|
51
|
+
it "add to typedef structure mock needs of functions of style 'int func(void)'" do
|
53
52
|
function = {:name => "Elm", :args => [], :return => test_return[:int]}
|
54
53
|
expected = " int ReturnVal;\n"
|
55
54
|
returned = @cmock_generator_plugin_expect.instance_typedefs(function)
|
56
55
|
assert_equal(expected, returned)
|
57
56
|
end
|
58
|
-
|
59
|
-
|
57
|
+
|
58
|
+
it "add to typedef structure mock needs of functions of style 'void func(int chicken, char* pork)'" do
|
60
59
|
function = {:name => "Cedar", :args => [{ :name => "chicken", :type => "int"}, { :name => "pork", :type => "char*"}], :return => test_return[:void]}
|
61
60
|
expected = " int Expected_chicken;\n char* Expected_pork;\n"
|
62
61
|
returned = @cmock_generator_plugin_expect.instance_typedefs(function)
|
63
62
|
assert_equal(expected, returned)
|
64
63
|
end
|
65
|
-
|
66
|
-
|
64
|
+
|
65
|
+
it "add to typedef structure mock needs of functions of style 'int func(float beef)'" do
|
67
66
|
function = {:name => "Birch", :args => [{ :name => "beef", :type => "float"}], :return => test_return[:int]}
|
68
67
|
expected = " int ReturnVal;\n float Expected_beef;\n"
|
69
68
|
returned = @cmock_generator_plugin_expect.instance_typedefs(function)
|
70
69
|
assert_equal(expected, returned)
|
71
70
|
end
|
72
|
-
|
73
|
-
|
71
|
+
|
72
|
+
it "add to typedef structure mock needs of functions of style 'void func(void)' and global ordering" do
|
74
73
|
function = {:name => "Oak", :args => [], :return => test_return[:void]}
|
75
74
|
expected = " int CallOrder;\n"
|
76
75
|
returned = @cmock_generator_plugin_expect_strict.instance_typedefs(function)
|
77
76
|
assert_equal(expected, returned)
|
78
77
|
end
|
79
|
-
|
80
|
-
|
78
|
+
|
79
|
+
it "add mock function declaration for functions of style 'void func(void)'" do
|
81
80
|
function = {:name => "Maple", :args => [], :return => test_return[:void]}
|
82
81
|
expected = "#define Maple_Expect() Maple_CMockExpect(__LINE__)\n" +
|
83
82
|
"void Maple_CMockExpect(UNITY_LINE_TYPE cmock_line);\n"
|
84
83
|
returned = @cmock_generator_plugin_expect.mock_function_declarations(function)
|
85
84
|
assert_equal(expected, returned)
|
86
85
|
end
|
87
|
-
|
88
|
-
|
86
|
+
|
87
|
+
it "add mock function declaration for functions of style 'int func(void)'" do
|
89
88
|
function = {:name => "Spruce", :args => [], :return => test_return[:int]}
|
90
89
|
expected = "#define Spruce_ExpectAndReturn(cmock_retval) Spruce_CMockExpectAndReturn(__LINE__, cmock_retval)\n" +
|
91
90
|
"void Spruce_CMockExpectAndReturn(UNITY_LINE_TYPE cmock_line, int cmock_to_return);\n"
|
92
91
|
returned = @cmock_generator_plugin_expect.mock_function_declarations(function)
|
93
92
|
assert_equal(expected, returned)
|
94
93
|
end
|
95
|
-
|
96
|
-
|
94
|
+
|
95
|
+
it "add mock function declaration for functions of style 'const char* func(int tofu)'" do
|
97
96
|
function = {:name => "Pine", :args => ["int tofu"], :args_string => "int tofu", :args_call => 'tofu', :return => test_return[:string]}
|
98
97
|
expected = "#define Pine_ExpectAndReturn(tofu, cmock_retval) Pine_CMockExpectAndReturn(__LINE__, tofu, cmock_retval)\n" +
|
99
98
|
"void Pine_CMockExpectAndReturn(UNITY_LINE_TYPE cmock_line, int tofu, const char* cmock_to_return);\n"
|
100
99
|
returned = @cmock_generator_plugin_expect.mock_function_declarations(function)
|
101
100
|
assert_equal(expected, returned)
|
102
101
|
end
|
103
|
-
|
104
|
-
|
102
|
+
|
103
|
+
it "add mock function implementation for functions of style 'void func(void)'" do
|
105
104
|
function = {:name => "Apple", :args => [], :return => test_return[:void]}
|
106
105
|
expected = ""
|
107
106
|
returned = @cmock_generator_plugin_expect.mock_implementation(function)
|
108
107
|
assert_equal(expected, returned)
|
109
108
|
end
|
110
|
-
|
111
|
-
|
109
|
+
|
110
|
+
it "add mock function implementation for functions of style 'int func(int veal, unsigned int sushi)'" do
|
112
111
|
function = {:name => "Cherry", :args => [ { :type => "int", :name => "veal" }, { :type => "unsigned int", :name => "sushi" } ], :return => test_return[:int]}
|
113
|
-
|
114
|
-
@utils.expect
|
115
|
-
@utils.expect
|
112
|
+
|
113
|
+
@utils.expect :code_verify_an_arg_expectation, " mocked_retval_1", [function, function[:args][0]]
|
114
|
+
@utils.expect :code_verify_an_arg_expectation, " mocked_retval_2", [function, function[:args][1]]
|
116
115
|
expected = " mocked_retval_1 mocked_retval_2"
|
117
116
|
returned = @cmock_generator_plugin_expect.mock_implementation(function)
|
118
117
|
assert_equal(expected, returned)
|
119
118
|
end
|
120
|
-
|
121
|
-
|
119
|
+
|
120
|
+
it "add mock function implementation using ordering if needed" do
|
122
121
|
function = {:name => "Apple", :args => [], :return => test_return[:void]}
|
123
122
|
expected = ""
|
124
123
|
@cmock_generator_plugin_expect.ordered = true
|
125
124
|
returned = @cmock_generator_plugin_expect.mock_implementation(function)
|
126
125
|
assert_equal(expected, returned)
|
127
126
|
end
|
128
|
-
|
129
|
-
|
127
|
+
|
128
|
+
it "add mock function implementation for functions of style 'void func(int worm)' and strict ordering" do
|
130
129
|
function = {:name => "Apple", :args => [{ :type => "int", :name => "worm" }], :return => test_return[:void]}
|
131
|
-
@utils.expect
|
130
|
+
@utils.expect :code_verify_an_arg_expectation, "mocked_retval_0", [function, function[:args][0]]
|
132
131
|
expected = "mocked_retval_0"
|
133
132
|
@cmock_generator_plugin_expect.ordered = true
|
134
133
|
returned = @cmock_generator_plugin_expect_strict.mock_implementation(function)
|
135
134
|
assert_equal(expected, returned)
|
136
135
|
end
|
137
|
-
|
138
|
-
|
136
|
+
|
137
|
+
it "add mock interfaces for functions of style 'void func(void)'" do
|
139
138
|
function = {:name => "Pear", :args => [], :args_string => "void", :return => test_return[:void]}
|
140
|
-
@utils.expect
|
141
|
-
@utils.expect
|
139
|
+
@utils.expect :code_add_base_expectation, "mock_retval_0 ", ["Pear"]
|
140
|
+
@utils.expect :code_call_argument_loader, "mock_retval_1 ", [function]
|
142
141
|
expected = ["void Pear_CMockExpect(UNITY_LINE_TYPE cmock_line)\n",
|
143
142
|
"{\n",
|
144
143
|
"mock_retval_0 ",
|
@@ -148,12 +147,12 @@ class CMockGeneratorPluginExpectTest < Test::Unit::TestCase
|
|
148
147
|
returned = @cmock_generator_plugin_expect.mock_interfaces(function)
|
149
148
|
assert_equal(expected, returned)
|
150
149
|
end
|
151
|
-
|
152
|
-
|
150
|
+
|
151
|
+
it "add mock interfaces for functions of style 'int func(void)'" do
|
153
152
|
function = {:name => "Orange", :args => [], :args_string => "void", :return => test_return[:int]}
|
154
|
-
@utils.expect
|
155
|
-
@utils.expect
|
156
|
-
@utils.expect
|
153
|
+
@utils.expect :code_add_base_expectation, "mock_retval_0 ", ["Orange"]
|
154
|
+
@utils.expect :code_call_argument_loader, "mock_retval_1 ", [function]
|
155
|
+
@utils.expect :code_assign_argument_quickly, "mock_retval_2", ["cmock_call_instance->ReturnVal", function[:return]]
|
157
156
|
expected = ["void Orange_CMockExpectAndReturn(UNITY_LINE_TYPE cmock_line, int cmock_to_return)\n",
|
158
157
|
"{\n",
|
159
158
|
"mock_retval_0 ",
|
@@ -164,12 +163,12 @@ class CMockGeneratorPluginExpectTest < Test::Unit::TestCase
|
|
164
163
|
returned = @cmock_generator_plugin_expect.mock_interfaces(function)
|
165
164
|
assert_equal(expected, returned)
|
166
165
|
end
|
167
|
-
|
168
|
-
|
166
|
+
|
167
|
+
it "add mock interfaces for functions of style 'int func(char* pescado)'" do
|
169
168
|
function = {:name => "Lemon", :args => [{ :type => "char*", :name => "pescado"}], :args_string => "char* pescado", :return => test_return[:int]}
|
170
|
-
@utils.expect
|
171
|
-
@utils.expect
|
172
|
-
@utils.expect
|
169
|
+
@utils.expect :code_add_base_expectation, "mock_retval_0 ", ["Lemon"]
|
170
|
+
@utils.expect :code_call_argument_loader, "mock_retval_1 ", [function]
|
171
|
+
@utils.expect :code_assign_argument_quickly, "mock_retval_2", ["cmock_call_instance->ReturnVal", function[:return]]
|
173
172
|
expected = ["void Lemon_CMockExpectAndReturn(UNITY_LINE_TYPE cmock_line, char* pescado, int cmock_to_return)\n",
|
174
173
|
"{\n",
|
175
174
|
"mock_retval_0 ",
|
@@ -180,11 +179,11 @@ class CMockGeneratorPluginExpectTest < Test::Unit::TestCase
|
|
180
179
|
returned = @cmock_generator_plugin_expect.mock_interfaces(function)
|
181
180
|
assert_equal(expected, returned)
|
182
181
|
end
|
183
|
-
|
184
|
-
|
182
|
+
|
183
|
+
it "add mock interfaces for functions when using ordering" do
|
185
184
|
function = {:name => "Pear", :args => [], :args_string => "void", :return => test_return[:void]}
|
186
|
-
@utils.expect
|
187
|
-
@utils.expect
|
185
|
+
@utils.expect :code_add_base_expectation, "mock_retval_0 ", ["Pear"]
|
186
|
+
@utils.expect :code_call_argument_loader, "mock_retval_1 ", [function]
|
188
187
|
expected = ["void Pear_CMockExpect(UNITY_LINE_TYPE cmock_line)\n",
|
189
188
|
"{\n",
|
190
189
|
"mock_retval_0 ",
|
@@ -195,12 +194,12 @@ class CMockGeneratorPluginExpectTest < Test::Unit::TestCase
|
|
195
194
|
returned = @cmock_generator_plugin_expect.mock_interfaces(function)
|
196
195
|
assert_equal(expected, returned)
|
197
196
|
end
|
198
|
-
|
199
|
-
|
197
|
+
|
198
|
+
it "add mock verify lines" do
|
200
199
|
function = {:name => "Banana" }
|
201
200
|
expected = " UNITY_TEST_ASSERT(CMOCK_GUTS_NONE == Mock.Banana_CallInstance, cmock_line, \"Function 'Banana' called less times than expected.\");\n"
|
202
201
|
returned = @cmock_generator_plugin_expect.mock_verify(function)
|
203
202
|
assert_equal(expected, returned)
|
204
203
|
end
|
205
|
-
|
204
|
+
|
206
205
|
end
|