ceedling 0.17.0 → 0.18.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- 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,20 +2,21 @@
|
|
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_ignore_arg'
|
9
9
|
|
10
|
-
|
11
|
-
|
10
|
+
describe CMockGeneratorPluginIgnoreArg, "Verify CMockGeneratorPluginIgnoreArg Module" do
|
11
|
+
|
12
|
+
before do
|
12
13
|
create_mocks :config, :utils
|
13
14
|
|
14
15
|
# int *Oak(void)"
|
15
16
|
@void_func = {:name => "Oak", :args => [], :return => test_return[:int_ptr]}
|
16
17
|
|
17
18
|
# void Pine(int chicken, const int beef, int *tofu)
|
18
|
-
@complex_func = {:name => "Pine",
|
19
|
+
@complex_func = {:name => "Pine",
|
19
20
|
:args => [{ :type => "int",
|
20
21
|
:name => "chicken",
|
21
22
|
:ptr? => false,
|
@@ -29,31 +30,30 @@ class CMockGeneratorPluginIgnoreArgTest < Test::Unit::TestCase
|
|
29
30
|
:name => "tofu",
|
30
31
|
:ptr? => true,
|
31
32
|
}],
|
32
|
-
:return => test_return[:void],
|
33
|
+
:return => test_return[:void],
|
33
34
|
:contains_ptr? => true }
|
34
35
|
|
35
36
|
#no strict ordering
|
36
37
|
@cmock_generator_plugin_ignore_arg = CMockGeneratorPluginIgnoreArg.new(@config, @utils)
|
37
38
|
end
|
38
39
|
|
39
|
-
|
40
|
+
after do
|
40
41
|
end
|
41
42
|
|
42
|
-
|
43
|
-
assert_equal(@utils, @cmock_generator_plugin_ignore_arg.utils)
|
43
|
+
it "have set up internal priority correctly on init" do
|
44
44
|
assert_equal(10, @cmock_generator_plugin_ignore_arg.priority)
|
45
45
|
end
|
46
|
-
|
47
|
-
|
46
|
+
|
47
|
+
it "not include any additional include files" do
|
48
48
|
assert(!@cmock_generator_plugin_ignore_arg.respond_to?(:include_files))
|
49
49
|
end
|
50
50
|
|
51
|
-
|
51
|
+
it "not add to typedef structure for functions with no args" do
|
52
52
|
returned = @cmock_generator_plugin_ignore_arg.instance_typedefs(@void_func)
|
53
53
|
assert_equal("", returned)
|
54
54
|
end
|
55
|
-
|
56
|
-
|
55
|
+
|
56
|
+
it "add to tyepdef structure mock needs of functions of style 'void func(int chicken, int* pork)'" do
|
57
57
|
expected = " int IgnoreArg_chicken;\n" +
|
58
58
|
" int IgnoreArg_beef;\n" +
|
59
59
|
" int IgnoreArg_tofu;\n"
|
@@ -61,7 +61,7 @@ class CMockGeneratorPluginIgnoreArgTest < Test::Unit::TestCase
|
|
61
61
|
assert_equal(expected, returned)
|
62
62
|
end
|
63
63
|
|
64
|
-
|
64
|
+
it "add mock function declarations for all arguments" do
|
65
65
|
expected =
|
66
66
|
"#define Pine_IgnoreArg_chicken()" +
|
67
67
|
" Pine_CMockIgnoreArg_chicken(__LINE__)\n" +
|
@@ -79,12 +79,12 @@ class CMockGeneratorPluginIgnoreArgTest < Test::Unit::TestCase
|
|
79
79
|
assert_equal(expected, returned)
|
80
80
|
end
|
81
81
|
|
82
|
-
|
82
|
+
it "add mock interfaces for all arguments" do
|
83
83
|
expected =
|
84
84
|
"void Pine_CMockIgnoreArg_chicken(UNITY_LINE_TYPE cmock_line)\n" +
|
85
85
|
"{\n" +
|
86
86
|
" CMOCK_Pine_CALL_INSTANCE* cmock_call_instance = " +
|
87
|
-
|
87
|
+
"(CMOCK_Pine_CALL_INSTANCE*)CMock_Guts_GetAddressFor(CMock_Guts_MemEndOfChain(Mock.Pine_CallInstance));\n" +
|
88
88
|
" UNITY_TEST_ASSERT_NOT_NULL(cmock_call_instance, cmock_line, \"chicken IgnoreArg called before Expect on 'Pine'.\");\n" +
|
89
89
|
" cmock_call_instance->IgnoreArg_chicken = 1;\n" +
|
90
90
|
"}\n\n" +
|
@@ -92,7 +92,7 @@ class CMockGeneratorPluginIgnoreArgTest < Test::Unit::TestCase
|
|
92
92
|
"void Pine_CMockIgnoreArg_beef(UNITY_LINE_TYPE cmock_line)\n" +
|
93
93
|
"{\n" +
|
94
94
|
" CMOCK_Pine_CALL_INSTANCE* cmock_call_instance = " +
|
95
|
-
|
95
|
+
"(CMOCK_Pine_CALL_INSTANCE*)CMock_Guts_GetAddressFor(CMock_Guts_MemEndOfChain(Mock.Pine_CallInstance));\n" +
|
96
96
|
" UNITY_TEST_ASSERT_NOT_NULL(cmock_call_instance, cmock_line, \"beef IgnoreArg called before Expect on 'Pine'.\");\n" +
|
97
97
|
" cmock_call_instance->IgnoreArg_beef = 1;\n" +
|
98
98
|
"}\n\n" +
|
@@ -100,7 +100,7 @@ class CMockGeneratorPluginIgnoreArgTest < Test::Unit::TestCase
|
|
100
100
|
"void Pine_CMockIgnoreArg_tofu(UNITY_LINE_TYPE cmock_line)\n" +
|
101
101
|
"{\n" +
|
102
102
|
" CMOCK_Pine_CALL_INSTANCE* cmock_call_instance = " +
|
103
|
-
|
103
|
+
"(CMOCK_Pine_CALL_INSTANCE*)CMock_Guts_GetAddressFor(CMock_Guts_MemEndOfChain(Mock.Pine_CallInstance));\n" +
|
104
104
|
" UNITY_TEST_ASSERT_NOT_NULL(cmock_call_instance, cmock_line, \"tofu IgnoreArg called before Expect on 'Pine'.\");\n" +
|
105
105
|
" cmock_call_instance->IgnoreArg_tofu = 1;\n" +
|
106
106
|
"}\n\n"
|
@@ -109,7 +109,7 @@ class CMockGeneratorPluginIgnoreArgTest < Test::Unit::TestCase
|
|
109
109
|
assert_equal(expected, returned)
|
110
110
|
end
|
111
111
|
|
112
|
-
|
112
|
+
it "not add a mock implementation" do
|
113
113
|
assert(!@cmock_generator_plugin_ignore_arg.respond_to?(:mock_implementation))
|
114
114
|
end
|
115
115
|
|
@@ -7,41 +7,40 @@
|
|
7
7
|
require File.expand_path(File.dirname(__FILE__)) + "/../test_helper"
|
8
8
|
require 'cmock_generator_plugin_ignore'
|
9
9
|
|
10
|
-
|
11
|
-
|
10
|
+
describe CMockGeneratorPluginIgnore, "Verify CMockGeneratorPluginIgnore 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_ignore = CMockGeneratorPluginIgnore.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_ignore.utils)
|
23
|
-
assert_equal(2, @cmock_generator_plugin_ignore.priority)
|
21
|
+
it "have set up internal priority" do
|
22
|
+
assert_equal(2, @cmock_generator_plugin_ignore.priority)
|
24
23
|
end
|
25
24
|
|
26
|
-
|
25
|
+
it "not have any additional include file requirements" do
|
27
26
|
assert(!@cmock_generator_plugin_ignore.respond_to?(:include_files))
|
28
27
|
end
|
29
28
|
|
30
|
-
|
29
|
+
it "add a required variable to the instance structure" do
|
31
30
|
function = {:name => "Grass", :args => [], :return => test_return[:void]}
|
32
31
|
expected = " int Grass_IgnoreBool;\n"
|
33
32
|
returned = @cmock_generator_plugin_ignore.instance_structure(function)
|
34
33
|
assert_equal(expected, returned)
|
35
34
|
end
|
36
35
|
|
37
|
-
|
36
|
+
it "handle function declarations for functions without return values" do
|
38
37
|
function = {:name => "Mold", :args_string => "void", :return => test_return[:void]}
|
39
38
|
expected = "#define Mold_Ignore() Mold_CMockIgnore()\nvoid Mold_CMockIgnore(void);\n"
|
40
39
|
returned = @cmock_generator_plugin_ignore.mock_function_declarations(function)
|
41
40
|
assert_equal(expected, returned)
|
42
41
|
end
|
43
42
|
|
44
|
-
|
43
|
+
it "handle function declarations for functions that returns something" do
|
45
44
|
function = {:name => "Fungus", :args_string => "void", :return => test_return[:string]}
|
46
45
|
expected = "#define Fungus_IgnoreAndReturn(cmock_retval) Fungus_CMockIgnoreAndReturn(__LINE__, cmock_retval)\n"+
|
47
46
|
"void Fungus_CMockIgnoreAndReturn(UNITY_LINE_TYPE cmock_line, const char* cmock_to_return);\n"
|
@@ -49,7 +48,7 @@ class CMockGeneratorPluginIgnoreTest < Test::Unit::TestCase
|
|
49
48
|
assert_equal(expected, returned)
|
50
49
|
end
|
51
50
|
|
52
|
-
|
51
|
+
it "add required code to implementation precheck with void function" do
|
53
52
|
function = {:name => "Mold", :args_string => "void", :return => test_return[:void]}
|
54
53
|
expected = [" if (Mock.Mold_IgnoreBool)\n",
|
55
54
|
" {\n",
|
@@ -60,10 +59,10 @@ class CMockGeneratorPluginIgnoreTest < Test::Unit::TestCase
|
|
60
59
|
assert_equal(expected, returned)
|
61
60
|
end
|
62
61
|
|
63
|
-
|
62
|
+
it "add required code to implementation precheck with return functions" do
|
64
63
|
function = {:name => "Fungus", :args_string => "void", :return => test_return[:int]}
|
65
64
|
retval = test_return[:int].merge({ :name => "cmock_call_instance->ReturnVal"})
|
66
|
-
@utils.expect
|
65
|
+
@utils.expect :code_assign_argument_quickly, ' mock_retval_0', ["Mock.Fungus_FinalReturn", retval]
|
67
66
|
expected = [" if (Mock.Fungus_IgnoreBool)\n",
|
68
67
|
" {\n",
|
69
68
|
" if (cmock_call_instance == NULL)\n",
|
@@ -76,7 +75,7 @@ class CMockGeneratorPluginIgnoreTest < Test::Unit::TestCase
|
|
76
75
|
assert_equal(expected, returned)
|
77
76
|
end
|
78
77
|
|
79
|
-
|
78
|
+
it "add a new mock interface for ignoring when function had no return value" do
|
80
79
|
function = {:name => "Slime", :args => [], :args_string => "void", :return => test_return[:void]}
|
81
80
|
expected = ["void Slime_CMockIgnore(void)\n",
|
82
81
|
"{\n",
|
@@ -87,9 +86,9 @@ class CMockGeneratorPluginIgnoreTest < Test::Unit::TestCase
|
|
87
86
|
assert_equal(expected, returned)
|
88
87
|
end
|
89
88
|
|
90
|
-
|
89
|
+
it "add a new mock interface for ignoring when function has return value" do
|
91
90
|
function = {:name => "Slime", :args => [], :args_string => "void", :return => test_return[:int]}
|
92
|
-
@utils.expect
|
91
|
+
@utils.expect :code_add_base_expectation, "mock_return_1", ["Slime", false]
|
93
92
|
expected = ["void Slime_CMockIgnoreAndReturn(UNITY_LINE_TYPE cmock_line, int cmock_to_return)\n",
|
94
93
|
"{\n",
|
95
94
|
"mock_return_1",
|
@@ -7,8 +7,9 @@
|
|
7
7
|
require File.expand_path(File.dirname(__FILE__)) + "/../test_helper"
|
8
8
|
require 'cmock_generator_plugin_return_thru_ptr'
|
9
9
|
|
10
|
-
|
11
|
-
|
10
|
+
describe CMockGeneratorPluginReturnThruPtr, "Verify CMockGeneratorPluginReturnThruPtr Module" do
|
11
|
+
|
12
|
+
before do
|
12
13
|
create_mocks :config, :utils
|
13
14
|
|
14
15
|
# int *Oak(void)"
|
@@ -42,34 +43,33 @@ class CMockGeneratorPluginReturnThruPtrTest < Test::Unit::TestCase
|
|
42
43
|
@cmock_generator_plugin_return_thru_ptr = CMockGeneratorPluginReturnThruPtr.new(@config, @utils)
|
43
44
|
end
|
44
45
|
|
45
|
-
|
46
|
+
after do
|
46
47
|
end
|
47
48
|
|
48
49
|
def simple_func_expect
|
49
|
-
@utils.expect
|
50
|
+
@utils.expect :ptr_or_str?, false, ['int']
|
50
51
|
end
|
51
52
|
|
52
53
|
def complex_func_expect
|
53
|
-
@utils.expect
|
54
|
-
@utils.expect
|
55
|
-
@utils.expect
|
54
|
+
@utils.expect :ptr_or_str?, false, ['int']
|
55
|
+
@utils.expect :ptr_or_str?, true, ['int*']
|
56
|
+
@utils.expect :ptr_or_str?, true, ['int*']
|
56
57
|
end
|
57
58
|
|
58
|
-
|
59
|
-
assert_equal(@utils, @cmock_generator_plugin_return_thru_ptr.utils)
|
59
|
+
it "have set up internal priority correctly on init" do
|
60
60
|
assert_equal(1, @cmock_generator_plugin_return_thru_ptr.priority)
|
61
61
|
end
|
62
62
|
|
63
|
-
|
63
|
+
it "not include any additional include files" do
|
64
64
|
assert(!@cmock_generator_plugin_return_thru_ptr.respond_to?(:include_files))
|
65
65
|
end
|
66
66
|
|
67
|
-
|
67
|
+
it "not add to typedef structure for functions of style 'int* func(void)'" do
|
68
68
|
returned = @cmock_generator_plugin_return_thru_ptr.instance_typedefs(@void_func)
|
69
69
|
assert_equal("", returned)
|
70
70
|
end
|
71
71
|
|
72
|
-
|
72
|
+
it "add to tyepdef structure mock needs of functions of style 'void func(int chicken, int* pork)'" do
|
73
73
|
complex_func_expect()
|
74
74
|
expected = " int ReturnThruPtr_tofu_Used;\n" +
|
75
75
|
" int* ReturnThruPtr_tofu_Val;\n" +
|
@@ -78,13 +78,13 @@ class CMockGeneratorPluginReturnThruPtrTest < Test::Unit::TestCase
|
|
78
78
|
assert_equal(expected, returned)
|
79
79
|
end
|
80
80
|
|
81
|
-
|
81
|
+
it "not add an additional mock interface for functions not containing pointers" do
|
82
82
|
simple_func_expect()
|
83
83
|
returned = @cmock_generator_plugin_return_thru_ptr.mock_function_declarations(@simple_func)
|
84
84
|
assert_equal("", returned)
|
85
85
|
end
|
86
86
|
|
87
|
-
|
87
|
+
it "add a mock function declaration only for non-const pointer arguments" do
|
88
88
|
complex_func_expect();
|
89
89
|
|
90
90
|
expected =
|
@@ -100,14 +100,14 @@ class CMockGeneratorPluginReturnThruPtrTest < Test::Unit::TestCase
|
|
100
100
|
assert_equal(expected, returned)
|
101
101
|
end
|
102
102
|
|
103
|
-
|
103
|
+
it "add mock interfaces only for non-const pointer arguments" do
|
104
104
|
complex_func_expect();
|
105
105
|
|
106
106
|
expected =
|
107
107
|
"void Pine_CMockReturnMemThruPtr_tofu(UNITY_LINE_TYPE cmock_line, int* tofu, int cmock_size)\n" +
|
108
108
|
"{\n" +
|
109
109
|
" CMOCK_Pine_CALL_INSTANCE* cmock_call_instance = " +
|
110
|
-
"
|
110
|
+
"(CMOCK_Pine_CALL_INSTANCE*)CMock_Guts_GetAddressFor(CMock_Guts_MemEndOfChain(Mock.Pine_CallInstance));\n" +
|
111
111
|
" UNITY_TEST_ASSERT_NOT_NULL(cmock_call_instance, cmock_line, \"tofu ReturnThruPtr called before Expect on 'Pine'.\");\n" +
|
112
112
|
" cmock_call_instance->ReturnThruPtr_tofu_Used = 1;\n" +
|
113
113
|
" cmock_call_instance->ReturnThruPtr_tofu_Val = tofu;\n" +
|
@@ -118,7 +118,7 @@ class CMockGeneratorPluginReturnThruPtrTest < Test::Unit::TestCase
|
|
118
118
|
assert_equal(expected, returned)
|
119
119
|
end
|
120
120
|
|
121
|
-
|
121
|
+
it "add mock implementations only for non-const pointer arguments" do
|
122
122
|
complex_func_expect()
|
123
123
|
|
124
124
|
expected =
|
@@ -7,57 +7,54 @@
|
|
7
7
|
require File.expand_path(File.dirname(__FILE__)) + "/../test_helper"
|
8
8
|
require 'cmock_generator_utils'
|
9
9
|
|
10
|
-
|
11
|
-
|
10
|
+
describe CMockGeneratorUtils, "Verify CMockGeneratorUtils Module" do
|
11
|
+
|
12
|
+
before do
|
12
13
|
create_mocks :config, :unity_helper, :unity_helper
|
13
14
|
|
14
|
-
@config.expect
|
15
|
-
@config.expect
|
16
|
-
@config.expect
|
17
|
-
@config.expect
|
18
|
-
@config.expect
|
19
|
-
@config.expect
|
20
|
-
@config.expect
|
21
|
-
@config.expect
|
22
|
-
@config.expect
|
15
|
+
@config.expect :when_ptr, :compare_ptr
|
16
|
+
@config.expect :enforce_strict_ordering, false
|
17
|
+
@config.expect :plugins, []
|
18
|
+
@config.expect :plugins, []
|
19
|
+
@config.expect :plugins, []
|
20
|
+
@config.expect :plugins, []
|
21
|
+
@config.expect :plugins, []
|
22
|
+
@config.expect :plugins, []
|
23
|
+
@config.expect :treat_as, {'int' => 'INT','short' => 'INT16','long' => 'INT','char' => 'INT8','char*' => 'STRING'}
|
23
24
|
@cmock_generator_utils_simple = CMockGeneratorUtils.new(@config, {:unity_helper => @unity_helper})
|
24
25
|
|
25
|
-
@config.expect
|
26
|
-
@config.expect
|
27
|
-
@config.expect
|
28
|
-
@config.expect
|
29
|
-
@config.expect
|
30
|
-
@config.expect
|
31
|
-
@config.expect
|
32
|
-
@config.expect
|
33
|
-
@config.expect
|
26
|
+
@config.expect :when_ptr, :smart
|
27
|
+
@config.expect :enforce_strict_ordering, true
|
28
|
+
@config.expect :plugins, [:array, :cexception, :return_thru_ptr, :ignore_arg, :ignore]
|
29
|
+
@config.expect :plugins, [:array, :cexception, :return_thru_ptr, :ignore_arg, :ignore]
|
30
|
+
@config.expect :plugins, [:array, :cexception, :return_thru_ptr, :ignore_arg, :ignore]
|
31
|
+
@config.expect :plugins, [:array, :cexception, :return_thru_ptr, :ignore_arg, :ignore]
|
32
|
+
@config.expect :plugins, [:array, :cexception, :return_thru_ptr, :ignore_arg, :ignore]
|
33
|
+
@config.expect :plugins, [:array, :cexception, :return_thru_ptr, :ignore_arg, :ignore]
|
34
|
+
@config.expect :treat_as, {'int' => 'INT','short' => 'INT16','long' => 'INT','char' => 'INT8','uint32_t' => 'HEX32','char*' => 'STRING'}
|
34
35
|
@cmock_generator_utils_complex = CMockGeneratorUtils.new(@config, {:unity_helper => @unity_helper, :A=>1, :B=>2})
|
35
36
|
end
|
36
37
|
|
37
|
-
|
38
|
+
after do
|
38
39
|
end
|
39
40
|
|
40
|
-
|
41
|
-
assert_equal(@config, @cmock_generator_utils_simple.config)
|
42
|
-
assert_equal({:unity_helper => @unity_helper}, @cmock_generator_utils_simple.helpers)
|
41
|
+
it "have set up internal accessors correctly on init" do
|
43
42
|
assert_equal(false, @cmock_generator_utils_simple.arrays)
|
44
43
|
assert_equal(false, @cmock_generator_utils_simple.cexception)
|
45
44
|
end
|
46
45
|
|
47
|
-
|
48
|
-
assert_equal(@config, @cmock_generator_utils_complex.config)
|
49
|
-
assert_equal({:unity_helper => @unity_helper, :A=>1, :B=>2},@cmock_generator_utils_complex.helpers)
|
46
|
+
it "have set up internal accessors correctly on init, complete with passed helpers" do
|
50
47
|
assert_equal(true, @cmock_generator_utils_complex.arrays)
|
51
48
|
assert_equal(true, @cmock_generator_utils_complex.cexception)
|
52
49
|
end
|
53
50
|
|
54
|
-
|
51
|
+
it "detect pointers and strings" do
|
55
52
|
assert_equal(false, @cmock_generator_utils_simple.ptr_or_str?('int'))
|
56
53
|
assert_equal(true, @cmock_generator_utils_simple.ptr_or_str?('int*'))
|
57
54
|
assert_equal(true, @cmock_generator_utils_simple.ptr_or_str?('char*'))
|
58
55
|
end
|
59
56
|
|
60
|
-
|
57
|
+
it "add code for a base expectation with no plugins" do
|
61
58
|
expected =
|
62
59
|
" CMOCK_MEM_INDEX_TYPE cmock_guts_index = CMock_Guts_MemNew(sizeof(CMOCK_Apple_CALL_INSTANCE));\n" +
|
63
60
|
" CMOCK_Apple_CALL_INSTANCE* cmock_call_instance = (CMOCK_Apple_CALL_INSTANCE*)CMock_Guts_GetAddressFor(cmock_guts_index);\n" +
|
@@ -69,7 +66,7 @@ class CMockGeneratorUtilsTest < Test::Unit::TestCase
|
|
69
66
|
assert_equal(expected, output)
|
70
67
|
end
|
71
68
|
|
72
|
-
|
69
|
+
it "add code for a base expectation with all plugins" do
|
73
70
|
expected =
|
74
71
|
" CMOCK_MEM_INDEX_TYPE cmock_guts_index = CMock_Guts_MemNew(sizeof(CMOCK_Apple_CALL_INSTANCE));\n" +
|
75
72
|
" CMOCK_Apple_CALL_INSTANCE* cmock_call_instance = (CMOCK_Apple_CALL_INSTANCE*)CMock_Guts_GetAddressFor(cmock_guts_index);\n" +
|
@@ -84,7 +81,7 @@ class CMockGeneratorUtilsTest < Test::Unit::TestCase
|
|
84
81
|
assert_equal(expected, output)
|
85
82
|
end
|
86
83
|
|
87
|
-
|
84
|
+
it "add code for a base expectation with all plugins and ordering not supported" do
|
88
85
|
expected =
|
89
86
|
" CMOCK_MEM_INDEX_TYPE cmock_guts_index = CMock_Guts_MemNew(sizeof(CMOCK_Apple_CALL_INSTANCE));\n" +
|
90
87
|
" CMOCK_Apple_CALL_INSTANCE* cmock_call_instance = (CMOCK_Apple_CALL_INSTANCE*)CMock_Guts_GetAddressFor(cmock_guts_index);\n" +
|
@@ -98,7 +95,7 @@ class CMockGeneratorUtilsTest < Test::Unit::TestCase
|
|
98
95
|
assert_equal(expected, output)
|
99
96
|
end
|
100
97
|
|
101
|
-
|
98
|
+
it "add argument expectations for values when no array plugin" do
|
102
99
|
arg1 = { :name => "Orange", :const? => false, :type => 'int', :ptr? => false }
|
103
100
|
expected1 = " cmock_call_instance->Expected_Orange = Orange;\n"
|
104
101
|
|
@@ -117,7 +114,7 @@ class CMockGeneratorUtilsTest < Test::Unit::TestCase
|
|
117
114
|
assert_equal(expected4, @cmock_generator_utils_simple.code_add_an_arg_expectation(arg4))
|
118
115
|
end
|
119
116
|
|
120
|
-
|
117
|
+
it "add argument expectations for values when array plugin enabled" do
|
121
118
|
arg1 = { :name => "Orange", :const? => false, :type => 'int', :ptr? => false }
|
122
119
|
expected1 = " cmock_call_instance->Expected_Orange = Orange;\n" +
|
123
120
|
" cmock_call_instance->IgnoreArg_Orange = 0;\n"
|
@@ -143,13 +140,13 @@ class CMockGeneratorUtilsTest < Test::Unit::TestCase
|
|
143
140
|
assert_equal(expected4, @cmock_generator_utils_complex.code_add_an_arg_expectation(arg4))
|
144
141
|
end
|
145
142
|
|
146
|
-
|
143
|
+
it 'not have an argument loader when the function has no arguments' do
|
147
144
|
function = { :name => "Melon", :args_string => "void" }
|
148
145
|
|
149
146
|
assert_equal("", @cmock_generator_utils_complex.code_add_argument_loader(function))
|
150
147
|
end
|
151
148
|
|
152
|
-
|
149
|
+
it 'create an argument loader when the function has arguments' do
|
153
150
|
function = { :name => "Melon",
|
154
151
|
:args_string => "stuff",
|
155
152
|
:args => [test_arg[:int_ptr], test_arg[:mytype], test_arg[:string]]
|
@@ -162,7 +159,7 @@ class CMockGeneratorUtilsTest < Test::Unit::TestCase
|
|
162
159
|
assert_equal(expected, @cmock_generator_utils_simple.code_add_argument_loader(function))
|
163
160
|
end
|
164
161
|
|
165
|
-
|
162
|
+
it 'create an argument loader when the function has arguments supporting arrays' do
|
166
163
|
function = { :name => "Melon",
|
167
164
|
:args_string => "stuff",
|
168
165
|
:args => [test_arg[:int_ptr], test_arg[:mytype], test_arg[:string]]
|
@@ -180,13 +177,13 @@ class CMockGeneratorUtilsTest < Test::Unit::TestCase
|
|
180
177
|
assert_equal(expected, @cmock_generator_utils_complex.code_add_argument_loader(function))
|
181
178
|
end
|
182
179
|
|
183
|
-
|
180
|
+
it "not call argument loader if there are no arguments to actually use for this function" do
|
184
181
|
function = { :name => "Pineapple", :args_string => "void" }
|
185
182
|
|
186
183
|
assert_equal("", @cmock_generator_utils_complex.code_call_argument_loader(function))
|
187
184
|
end
|
188
185
|
|
189
|
-
|
186
|
+
it 'call an argument loader when the function has arguments' do
|
190
187
|
function = { :name => "Pineapple",
|
191
188
|
:args_string => "stuff",
|
192
189
|
:args => [test_arg[:int_ptr], test_arg[:mytype], test_arg[:string]]
|
@@ -195,7 +192,7 @@ class CMockGeneratorUtilsTest < Test::Unit::TestCase
|
|
195
192
|
assert_equal(expected, @cmock_generator_utils_simple.code_call_argument_loader(function))
|
196
193
|
end
|
197
194
|
|
198
|
-
|
195
|
+
it 'call an argument loader when the function has arguments with arrays' do
|
199
196
|
function = { :name => "Pineapple",
|
200
197
|
:args_string => "stuff",
|
201
198
|
:args => [test_arg[:int_ptr], test_arg[:mytype], test_arg[:string]]
|
@@ -204,62 +201,68 @@ class CMockGeneratorUtilsTest < Test::Unit::TestCase
|
|
204
201
|
assert_equal(expected, @cmock_generator_utils_complex.code_call_argument_loader(function))
|
205
202
|
end
|
206
203
|
|
207
|
-
|
204
|
+
it 'handle a simple assert when requested' do
|
208
205
|
function = { :name => 'Pear' }
|
209
206
|
arg = test_arg[:int]
|
210
207
|
expected = " {\n UNITY_TEST_ASSERT_EQUAL_INT(cmock_call_instance->Expected_MyInt, MyInt, cmock_line, \"Function 'Pear' called with unexpected value for argument 'MyInt'.\");\n }\n"
|
211
|
-
@unity_helper.expect
|
208
|
+
@unity_helper.expect :nil?, false
|
209
|
+
@unity_helper.expect :get_helper, ['UNITY_TEST_ASSERT_EQUAL_INT', ''], ['int']
|
212
210
|
assert_equal(expected, @cmock_generator_utils_simple.code_verify_an_arg_expectation(function, arg))
|
213
211
|
end
|
214
212
|
|
215
|
-
|
213
|
+
it 'handle a pointer comparison when configured to do so' do
|
216
214
|
function = { :name => 'Pear' }
|
217
215
|
arg = test_arg[:int_ptr]
|
218
216
|
expected = " {\n UNITY_TEST_ASSERT_EQUAL_PTR(cmock_call_instance->Expected_MyIntPtr, MyIntPtr, cmock_line, \"Function 'Pear' called with unexpected value for argument 'MyIntPtr'.\");\n }\n"
|
219
217
|
assert_equal(expected, @cmock_generator_utils_simple.code_verify_an_arg_expectation(function, arg))
|
220
218
|
end
|
221
219
|
|
222
|
-
|
220
|
+
it 'handle const char as string compares ' do
|
223
221
|
function = { :name => 'Pear' }
|
224
222
|
arg = test_arg[:string]
|
225
223
|
expected = " {\n UNITY_TEST_ASSERT_EQUAL_STRING(cmock_call_instance->Expected_MyStr, MyStr, cmock_line, \"Function 'Pear' called with unexpected value for argument 'MyStr'.\");\n }\n"
|
226
|
-
@unity_helper.expect
|
224
|
+
@unity_helper.expect :nil?, false
|
225
|
+
@unity_helper.expect :get_helper, ['UNITY_TEST_ASSERT_EQUAL_STRING',''], ['char*']
|
227
226
|
assert_equal(expected, @cmock_generator_utils_simple.code_verify_an_arg_expectation(function, arg))
|
228
227
|
end
|
229
228
|
|
230
|
-
|
229
|
+
it 'handle custom types as memory compares when we have no better way to do it' do
|
231
230
|
function = { :name => 'Pear' }
|
232
231
|
arg = test_arg[:mytype]
|
233
232
|
expected = " {\n UNITY_TEST_ASSERT_EQUAL_MEMORY((void*)(&cmock_call_instance->Expected_MyMyType), (void*)(&MyMyType), sizeof(MY_TYPE), cmock_line, \"Function 'Pear' called with unexpected value for argument 'MyMyType'.\");\n }\n"
|
234
|
-
@unity_helper.expect
|
233
|
+
@unity_helper.expect :nil?, false
|
234
|
+
@unity_helper.expect :get_helper, ['UNITY_TEST_ASSERT_EQUAL_MEMORY','&'], ['MY_TYPE']
|
235
235
|
assert_equal(expected, @cmock_generator_utils_simple.code_verify_an_arg_expectation(function, arg))
|
236
236
|
end
|
237
237
|
|
238
|
-
|
238
|
+
it 'handle custom types with custom handlers when available, even if they do not support the extra message' do
|
239
239
|
function = { :name => 'Pear' }
|
240
240
|
arg = test_arg[:mytype]
|
241
241
|
expected = " {\n UNITY_TEST_ASSERT_EQUAL_MY_TYPE(cmock_call_instance->Expected_MyMyType, MyMyType, cmock_line, \"Function 'Pear' called with unexpected value for argument 'MyMyType'.\");\n }\n"
|
242
|
-
@unity_helper.expect
|
242
|
+
@unity_helper.expect :nil?, false
|
243
|
+
@unity_helper.expect :get_helper, ['UNITY_TEST_ASSERT_EQUAL_MY_TYPE',''], ['MY_TYPE']
|
243
244
|
assert_equal(expected, @cmock_generator_utils_simple.code_verify_an_arg_expectation(function, arg))
|
244
245
|
end
|
245
246
|
|
246
|
-
|
247
|
+
it 'handle pointers to custom types with array handlers, even if the array extension is turned off' do
|
247
248
|
function = { :name => 'Pear' }
|
248
249
|
arg = test_arg[:mytype]
|
249
250
|
expected = " {\n UNITY_TEST_ASSERT_EQUAL_MY_TYPE_ARRAY(&cmock_call_instance->Expected_MyMyType, &MyMyType, 1, cmock_line, \"Function 'Pear' called with unexpected value for argument 'MyMyType'.\");\n }\n"
|
250
|
-
@unity_helper.expect
|
251
|
+
@unity_helper.expect :nil?, false
|
252
|
+
@unity_helper.expect :get_helper, ['UNITY_TEST_ASSERT_EQUAL_MY_TYPE_ARRAY','&'], ['MY_TYPE']
|
251
253
|
assert_equal(expected, @cmock_generator_utils_simple.code_verify_an_arg_expectation(function, arg))
|
252
254
|
end
|
253
255
|
|
254
|
-
|
256
|
+
it 'handle a simple assert when requested with array plugin enabled' do
|
255
257
|
function = { :name => 'Pear' }
|
256
258
|
arg = test_arg[:int]
|
257
259
|
expected = " if (!cmock_call_instance->IgnoreArg_MyInt)\n {\n UNITY_TEST_ASSERT_EQUAL_INT(cmock_call_instance->Expected_MyInt, MyInt, cmock_line, \"Function 'Pear' called with unexpected value for argument 'MyInt'.\");\n }\n"
|
258
|
-
@unity_helper.expect
|
260
|
+
@unity_helper.expect :nil?, false
|
261
|
+
@unity_helper.expect :get_helper, ['UNITY_TEST_ASSERT_EQUAL_INT',''], ['int']
|
259
262
|
assert_equal(expected, @cmock_generator_utils_complex.code_verify_an_arg_expectation(function, arg))
|
260
263
|
end
|
261
264
|
|
262
|
-
|
265
|
+
it 'handle an array comparison with array plugin enabled' do
|
263
266
|
function = { :name => 'Pear' }
|
264
267
|
arg = test_arg[:int_ptr]
|
265
268
|
expected = " if (!cmock_call_instance->IgnoreArg_MyIntPtr)\n" +
|
@@ -271,35 +274,39 @@ class CMockGeneratorUtilsTest < Test::Unit::TestCase
|
|
271
274
|
" else\n" +
|
272
275
|
" { UNITY_TEST_ASSERT_EQUAL_INT_ARRAY(cmock_call_instance->Expected_MyIntPtr, MyIntPtr, cmock_call_instance->Expected_MyIntPtr_Depth, cmock_line, \"Function 'Pear' called with unexpected value for argument 'MyIntPtr'.\"); }\n" +
|
273
276
|
" }\n"
|
274
|
-
@unity_helper.expect
|
275
|
-
|
277
|
+
@unity_helper.expect :nil?, false
|
278
|
+
@unity_helper.expect :get_helper, ['UNITY_TEST_ASSERT_EQUAL_INT_ARRAY',''], ['int*']
|
279
|
+
assert_equal(expected, @cmock_generator_utils_complex.code_verify_an_arg_expectation(function, arg))
|
276
280
|
end
|
277
281
|
|
278
|
-
|
282
|
+
it 'handle const char as string compares with array plugin enabled' do
|
279
283
|
function = { :name => 'Pear' }
|
280
284
|
arg = test_arg[:string]
|
281
285
|
expected = " if (!cmock_call_instance->IgnoreArg_MyStr)\n {\n UNITY_TEST_ASSERT_EQUAL_STRING(cmock_call_instance->Expected_MyStr, MyStr, cmock_line, \"Function 'Pear' called with unexpected value for argument 'MyStr'.\");\n }\n"
|
282
|
-
@unity_helper.expect
|
286
|
+
@unity_helper.expect :nil?, false
|
287
|
+
@unity_helper.expect :get_helper, ['UNITY_TEST_ASSERT_EQUAL_STRING',''], ['char*']
|
283
288
|
assert_equal(expected, @cmock_generator_utils_complex.code_verify_an_arg_expectation(function, arg))
|
284
289
|
end
|
285
290
|
|
286
|
-
|
291
|
+
it 'handle custom types as memory compares when we have no better way to do it with array plugin enabled' do
|
287
292
|
function = { :name => 'Pear' }
|
288
293
|
arg = test_arg[:mytype]
|
289
294
|
expected = " if (!cmock_call_instance->IgnoreArg_MyMyType)\n {\n if (&cmock_call_instance->Expected_MyMyType == NULL)\n { UNITY_TEST_ASSERT_NULL(MyMyType, cmock_line, \"Expected NULL. Function 'Pear' called with unexpected value for argument 'MyMyType'.\"); }\n else\n { UNITY_TEST_ASSERT_EQUAL_MEMORY_ARRAY((void*)(&cmock_call_instance->Expected_MyMyType), (void*)(&MyMyType), sizeof(MY_TYPE), 1, cmock_line, \"Function 'Pear' called with unexpected value for argument 'MyMyType'.\"); }\n }\n"
|
290
|
-
@unity_helper.expect
|
295
|
+
@unity_helper.expect :nil?, false
|
296
|
+
@unity_helper.expect :get_helper, ['UNITY_TEST_ASSERT_EQUAL_MEMORY_ARRAY', '&'], ['MY_TYPE']
|
291
297
|
assert_equal(expected, @cmock_generator_utils_complex.code_verify_an_arg_expectation(function, arg))
|
292
298
|
end
|
293
299
|
|
294
|
-
|
300
|
+
it 'handle custom types with custom handlers when available, even if they do not support the extra message with array plugin enabled' do
|
295
301
|
function = { :name => 'Pear' }
|
296
302
|
arg = test_arg[:mytype]
|
297
303
|
expected = " if (!cmock_call_instance->IgnoreArg_MyMyType)\n {\n UNITY_TEST_ASSERT_EQUAL_MY_TYPE(cmock_call_instance->Expected_MyMyType, MyMyType, cmock_line, \"Function 'Pear' called with unexpected value for argument 'MyMyType'.\");\n }\n"
|
298
|
-
@unity_helper.expect
|
304
|
+
@unity_helper.expect :nil?, false
|
305
|
+
@unity_helper.expect :get_helper, ['UNITY_TEST_ASSERT_EQUAL_MY_TYPE', ''], ['MY_TYPE']
|
299
306
|
assert_equal(expected, @cmock_generator_utils_complex.code_verify_an_arg_expectation(function, arg))
|
300
307
|
end
|
301
308
|
|
302
|
-
|
309
|
+
it 'handle custom types with array handlers when array plugin is enabled' do
|
303
310
|
function = { :name => 'Pear' }
|
304
311
|
arg = test_arg[:mytype_ptr]
|
305
312
|
expected = " if (!cmock_call_instance->IgnoreArg_MyMyTypePtr)\n" +
|
@@ -311,15 +318,17 @@ class CMockGeneratorUtilsTest < Test::Unit::TestCase
|
|
311
318
|
" else\n" +
|
312
319
|
" { UNITY_TEST_ASSERT_EQUAL_MY_TYPE_ARRAY(cmock_call_instance->Expected_MyMyTypePtr, MyMyTypePtr, cmock_call_instance->Expected_MyMyTypePtr_Depth, cmock_line, \"Function 'Pear' called with unexpected value for argument 'MyMyTypePtr'.\"); }\n" +
|
313
320
|
" }\n"
|
314
|
-
@unity_helper.expect
|
321
|
+
@unity_helper.expect :nil?, false
|
322
|
+
@unity_helper.expect :get_helper, ['UNITY_TEST_ASSERT_EQUAL_MY_TYPE_ARRAY', ''], ['MY_TYPE*']
|
315
323
|
assert_equal(expected, @cmock_generator_utils_complex.code_verify_an_arg_expectation(function, arg))
|
316
324
|
end
|
317
325
|
|
318
|
-
|
326
|
+
it 'handle custom types with array handlers when array plugin is enabled for non-array types' do
|
319
327
|
function = { :name => 'Pear' }
|
320
328
|
arg = test_arg[:mytype]
|
321
329
|
expected = " if (!cmock_call_instance->IgnoreArg_MyMyType)\n {\n UNITY_TEST_ASSERT_EQUAL_MY_TYPE_ARRAY(&cmock_call_instance->Expected_MyMyType, &MyMyType, 1, cmock_line, \"Function 'Pear' called with unexpected value for argument 'MyMyType'.\");\n }\n"
|
322
|
-
@unity_helper.expect
|
330
|
+
@unity_helper.expect :nil?, false
|
331
|
+
@unity_helper.expect :get_helper, ['UNITY_TEST_ASSERT_EQUAL_MY_TYPE_ARRAY', '&'], ['MY_TYPE']
|
323
332
|
assert_equal(expected, @cmock_generator_utils_complex.code_verify_an_arg_expectation(function, arg))
|
324
333
|
end
|
325
334
|
end
|