- updated tests (unit and system) to prove strict ordering is happy

git-svn-id: http://cmock.svn.sourceforge.net/svnroot/cmock/trunk@136 bf332499-1b4d-0410-844d-d2d48d5cc64c
This commit is contained in:
mvandervoord
2009-06-24 12:09:43 +00:00
parent ffbb92854f
commit d37f46ffbd
4 changed files with 27 additions and 5 deletions
+3
View File
@@ -250,6 +250,9 @@ module RakefileHelpers
total_failures += 1
test_results =~ /test#{index+1}:(.+)/
failure_messages << "#{test_file}:test#{index+1}:should #{test[:should]}:#{$1}"
elsif (test[:verify_error]) and not (test_results =~ /test#{index+1}:.*#{test[:verify_error]}/)
total_failures += 1
failure_messages << "#{test_file}:test#{index+1}:should #{test[:should]}:should have output matching '#{test[:verify_error]}'"
end
end
end
@@ -89,7 +89,8 @@
}
- :pass: FALSE
:should: 'fail because bar() is not called but is expected'
:should: 'fail because bar() is called but is not expected'
:verify_error: 'Called More Times Than Expected'
:code: |
test()
{
@@ -99,6 +100,7 @@
- :pass: FALSE
:should: 'fail because bar() is called twice but is expected once'
:verify_error: 'called unexpected number of times'
:code: |
test()
{
@@ -110,6 +112,7 @@
- :pass: FALSE
:should: 'fail because bar and foo called in reverse order'
:verify_error: 'Called Out Of Order'
:code: |
test()
{
+6
View File
@@ -195,6 +195,7 @@ class CMockGeneratorTest < Test::Unit::TestCase
expected = [ "extern jmp_buf AbortFrame;\n",
"extern int GlobalExpectCount;\n",
"extern int GlobalVerifyOrder;\n",
"extern char* GlobalOrderError;\n",
"\n" ]
@cmock_generator_strict.create_extern_declarations(output)
@@ -297,6 +298,11 @@ class CMockGeneratorTest < Test::Unit::TestCase
" memset(&Mock, 0, sizeof(Mock));\n",
" GlobalExpectCount = 0;\n",
" GlobalVerifyOrder = 0;\n",
" if (GlobalOrderError)\n",
" {\n",
" free(GlobalOrderError);\n",
" GlobalOrderError = NULL;\n",
" }\n",
"}\n\n"
]
@plugins.expect.run(:mock_destroy, functions[0]).returns([" Uno_First(int Candy, int)"," Dos_First(int Candy, int)"])
@@ -172,7 +172,6 @@ class CMockGeneratorPluginExpectTest < Test::Unit::TestCase
end
should "add mock function implementation using ordering if needed" do
@utils.expect.expect_helper('int','*p_expected','GlobalVerifyOrder',"\"Function 'Apple' Called Out Of Order.\"", ' ').returns(" mocked_retval")
function = {:name => "Apple", :args => [], :return_type => "void"}
expected = [" Mock.Apple_CallCount++;\n",
" if (Mock.Apple_CallCount > Mock.Apple_CallsExpected)\n",
@@ -184,7 +183,13 @@ class CMockGeneratorPluginExpectTest < Test::Unit::TestCase
" ++GlobalVerifyOrder;\n",
" if (Mock.Apple_CallOrder != Mock.Apple_CallOrder_Tail)\n",
" Mock.Apple_CallOrder++;\n",
" mocked_retval",
" if ((*p_expected != GlobalVerifyOrder) && (GlobalOrderError == NULL))\n",
" {\n",
" const char* ErrStr = \"Function 'Apple' Called Out Of Order.\";\n",
" GlobalOrderError = malloc(38);\n",
" if (GlobalOrderError)\n",
" strcpy(GlobalOrderError, ErrStr);\n",
" }\n",
" }\n"
]
@cmock_generator_plugin_expect.ordered = true
@@ -204,10 +209,15 @@ class CMockGeneratorPluginExpectTest < Test::Unit::TestCase
" ++GlobalVerifyOrder;\n",
" if (Mock.Apple_CallOrder != Mock.Apple_CallOrder_Tail)\n",
" Mock.Apple_CallOrder++;\n",
" BLEH",
" if ((*p_expected != GlobalVerifyOrder) && (GlobalOrderError == NULL))\n",
" {\n",
" const char* ErrStr = \"Function 'Apple' Called Out Of Order.\";\n",
" GlobalOrderError = malloc(38);\n",
" if (GlobalOrderError)\n",
" strcpy(GlobalOrderError, ErrStr);\n",
" }\n",
" }\n"
]
@utils.expect.expect_helper('int', '*p_expected', 'GlobalVerifyOrder', "\"Function 'Apple' Called Out Of Order.\""," ").returns(" BLEH")
returned = @cmock_generator_plugin_expect_strict.mock_implementation(function)
assert_equal(expected, returned)
end