mirror of
https://github.com/ThrowTheSwitch/CMock.git
synced 2026-09-20 17:17:25 +00:00
Verify #463 isn't currently an error, and won't return.
This commit is contained in:
@@ -44,6 +44,7 @@ module RakefileHelpers
|
||||
|
||||
def load_configuration(config_file, cmock_overlay = nil)
|
||||
$cfg_file = config_file
|
||||
cmock_overlay += '.yml' if cmock_overlay && cmock_overlay !~ /\.yml$/i
|
||||
$proj = load_yaml('./project.yml')
|
||||
|
||||
unity_targets_dir = '../vendor/unity/test/targets'
|
||||
@@ -89,7 +90,6 @@ module RakefileHelpers
|
||||
def configure_toolchain(config_file = DEFAULT_CONFIG_FILE, cmock_overlay = nil)
|
||||
config_file = config_file || DEFAULT_CONFIG_FILE
|
||||
config_file += '.yml' unless config_file =~ /\.yml$/i
|
||||
cmock_overlay += '.yml' if cmock_overlay && cmock_overlay !~ /\.yml$/i
|
||||
load_configuration(config_file, cmock_overlay)
|
||||
configure_clean
|
||||
end
|
||||
@@ -154,8 +154,7 @@ module RakefileHelpers
|
||||
|
||||
def unsupported_tests
|
||||
result = ($cmock_cfg[:unsupported] || []) | ($unity_cfg[:unsupported] || [])
|
||||
test_defs = $unity_cfg.dig(:defines, :test)
|
||||
conf_defs = (test_defs.is_a?(Hash) ? test_defs['*'] : nil) || test_defs || []
|
||||
conf_defs = all_defines
|
||||
UNSUPPORTED_CRITERIA.each_pair do |name, crit|
|
||||
result |= [name] if (crit[:defines] & conf_defs).empty?
|
||||
end
|
||||
@@ -343,7 +342,7 @@ module RakefileHelpers
|
||||
|
||||
SystemTestGenerator.new.generate_files(test_case_files)
|
||||
|
||||
load_configuration($cfg_file)
|
||||
load_configuration($cfg_file, $cmock_test_overlay_file)
|
||||
|
||||
include_dirs = get_local_include_dirs
|
||||
|
||||
@@ -481,7 +480,7 @@ module RakefileHelpers
|
||||
|
||||
def run_system_test_compilations(mockables)
|
||||
load '../lib/cmock.rb'
|
||||
load_configuration($cfg_file)
|
||||
load_configuration($cfg_file, $cmock_test_overlay_file)
|
||||
|
||||
unsupported = unsupported_tests
|
||||
mockables = mockables.reject do |f|
|
||||
@@ -510,7 +509,7 @@ module RakefileHelpers
|
||||
|
||||
def run_system_test_profiles(mockables)
|
||||
load '../lib/cmock.rb'
|
||||
load_configuration($cfg_file)
|
||||
load_configuration($cfg_file, $cmock_test_overlay_file)
|
||||
|
||||
report "\n"
|
||||
report "--------------------------\n"
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
|
||||
---
|
||||
:cmock:
|
||||
:plugins: []
|
||||
:plugins: [ignore, expect_any_args, array]
|
||||
:treat_as:
|
||||
custom_type: INT
|
||||
|
||||
@@ -21,6 +21,8 @@
|
||||
|
||||
:mockable: |
|
||||
void foo(BIG_FAT_STRUCT_T a);
|
||||
int get_result(void);
|
||||
void process_data(int* data, int count);
|
||||
|
||||
:source:
|
||||
:header: |
|
||||
@@ -68,6 +70,7 @@
|
||||
|
||||
- :pass: FALSE
|
||||
:should: 'should error out because we do not have eough memory to handle two of these structures'
|
||||
:verify_error: 'CMock has run out of memory. Please allocate more.'
|
||||
:code: |
|
||||
test()
|
||||
{
|
||||
@@ -86,4 +89,41 @@
|
||||
}
|
||||
}
|
||||
|
||||
- :pass: FALSE
|
||||
:should: 'should error out on ExpectAnyArgs when memory is exhausted'
|
||||
:verify_error: 'CMock has run out of memory. Please allocate more.'
|
||||
:code: |
|
||||
test()
|
||||
{
|
||||
// Fill all available memory with ExpectAnyArgs call instances
|
||||
while (CMock_Guts_MemBytesFree() > 0) {
|
||||
foo_ExpectAnyArgs();
|
||||
}
|
||||
}
|
||||
|
||||
- :pass: FALSE
|
||||
:should: 'should error out on IgnoreAndReturn when memory is exhausted'
|
||||
:verify_error: 'CMock has run out of memory. Please allocate more.'
|
||||
:code: |
|
||||
test()
|
||||
{
|
||||
// Fill all available memory with IgnoreAndReturn call instances
|
||||
while (CMock_Guts_MemBytesFree() > 0) {
|
||||
get_result_IgnoreAndReturn(42);
|
||||
}
|
||||
}
|
||||
|
||||
- :pass: FALSE
|
||||
:should: 'should error out on ExpectWithArray when memory is exhausted'
|
||||
:verify_error: 'CMock has run out of memory. Please allocate more.'
|
||||
:code: |
|
||||
test()
|
||||
{
|
||||
int data = 0;
|
||||
// Fill all available memory with ExpectWithArray call instances
|
||||
while (CMock_Guts_MemBytesFree() > 0) {
|
||||
process_data_ExpectWithArray(&data, 1, 1);
|
||||
}
|
||||
}
|
||||
|
||||
...
|
||||
|
||||
@@ -98,6 +98,46 @@ describe CMockGeneratorUtils, "Verify CMockGeneratorUtils Module" do
|
||||
assert_equal(expected, output)
|
||||
end
|
||||
|
||||
it "add code for a base expectation with expect_any_args plugin" do
|
||||
config = create_stub(
|
||||
:when_ptr => :smart,
|
||||
:enforce_strict_ordering => false,
|
||||
:plugins => [:expect_any_args],
|
||||
:treat_as => {},
|
||||
:respond_to? => false
|
||||
)
|
||||
utils = CMockGeneratorUtils.new(config, {})
|
||||
expected =
|
||||
" CMOCK_MEM_INDEX_TYPE cmock_guts_index = CMock_Guts_MemNew(sizeof(CMOCK_Apple_CALL_INSTANCE));\n" +
|
||||
" CMOCK_Apple_CALL_INSTANCE* cmock_call_instance = (CMOCK_Apple_CALL_INSTANCE*)CMock_Guts_GetAddressFor(cmock_guts_index);\n" +
|
||||
" UNITY_TEST_ASSERT_NOT_NULL(cmock_call_instance, cmock_line, CMockStringOutOfMemory);\n" +
|
||||
" memset(cmock_call_instance, 0, sizeof(*cmock_call_instance));\n" +
|
||||
" Mock.Apple_CallInstance = CMock_Guts_MemChain(Mock.Apple_CallInstance, cmock_guts_index);\n" +
|
||||
" cmock_call_instance->LineNumber = cmock_line;\n" +
|
||||
" cmock_call_instance->ExpectAnyArgsBool = (char)0;\n"
|
||||
assert_equal(expected, utils.code_add_base_expectation("Apple"))
|
||||
end
|
||||
|
||||
it "add code for a base expectation with ignore_stateless plugin (without ignore)" do
|
||||
config = create_stub(
|
||||
:when_ptr => :smart,
|
||||
:enforce_strict_ordering => false,
|
||||
:plugins => [:ignore_stateless],
|
||||
:treat_as => {},
|
||||
:respond_to? => false
|
||||
)
|
||||
utils = CMockGeneratorUtils.new(config, {})
|
||||
expected =
|
||||
" CMOCK_MEM_INDEX_TYPE cmock_guts_index = CMock_Guts_MemNew(sizeof(CMOCK_Apple_CALL_INSTANCE));\n" +
|
||||
" CMOCK_Apple_CALL_INSTANCE* cmock_call_instance = (CMOCK_Apple_CALL_INSTANCE*)CMock_Guts_GetAddressFor(cmock_guts_index);\n" +
|
||||
" UNITY_TEST_ASSERT_NOT_NULL(cmock_call_instance, cmock_line, CMockStringOutOfMemory);\n" +
|
||||
" memset(cmock_call_instance, 0, sizeof(*cmock_call_instance));\n" +
|
||||
" Mock.Apple_CallInstance = CMock_Guts_MemChain(Mock.Apple_CallInstance, cmock_guts_index);\n" +
|
||||
" Mock.Apple_IgnoreBool = (char)0;\n" +
|
||||
" cmock_call_instance->LineNumber = cmock_line;\n"
|
||||
assert_equal(expected, utils.code_add_base_expectation("Apple"))
|
||||
end
|
||||
|
||||
it "add argument expectations for values when no array plugin" do
|
||||
arg1 = { :name => "Orange", :const? => false, :type => 'int', :ptr? => false }
|
||||
expected1 = " cmock_call_instance->Expected_Orange = Orange;\n"
|
||||
|
||||
Reference in New Issue
Block a user