From cf9961f81e8bbb687d7c15caa0547e750f35c054 Mon Sep 17 00:00:00 2001 From: Mark VanderVoord Date: Fri, 28 Feb 2014 09:03:28 -0500 Subject: [PATCH] - add tests to prove that args_only ignores are working as desired. --- .../test_interactions/ignore_args_only.yml | 161 ++++++++++++++++++ 1 file changed, 161 insertions(+) create mode 100644 test/system/test_interactions/ignore_args_only.yml diff --git a/test/system/test_interactions/ignore_args_only.yml b/test/system/test_interactions/ignore_args_only.yml new file mode 100644 index 0000000..f3286bd --- /dev/null +++ b/test/system/test_interactions/ignore_args_only.yml @@ -0,0 +1,161 @@ +--- +:cmock: + :plugins: + - 'ignore' + :ignore: :args_only + +:systest: + :types: | + + :mockable: | + int foo(int a); + void bar(int b); + + :source: + :header: | + int function(int a, int b, int c); + :code: | + int function(int a, int b, int c) + { + bar(b); + return foo(a) + foo(b) + foo(c); + } + + :tests: + :common: | + void setUp(void) {} + void tearDown(void) {} + :units: + - :pass: TRUE + :should: 'successfully exercise simple ExpectAndReturn mock calls' + :code: | + test() + { + bar_Expect(2); + foo_ExpectAndReturn(1, 10); + foo_ExpectAndReturn(2, 20); + foo_ExpectAndReturn(3, 30); + TEST_ASSERT_EQUAL(60, function(1, 2, 3)); + } + + - :pass: TRUE + :should: 'ignore foo() calls' + :code: | + test() + { + bar_Expect(4); + foo_IgnoreAndReturn(10); + foo_IgnoreAndReturn(40); + foo_IgnoreAndReturn(80); + TEST_ASSERT_EQUAL(130, function(3, 4, 3)); + } + + - :pass: FALSE + :should: 'ignore foo() calls and notice if we called foo() more times than expected' + :code: | + test() + { + bar_Expect(4); + foo_IgnoreAndReturn(20); + foo_IgnoreAndReturn(30); + TEST_ASSERT_EQUAL(50, function(3, 4, 9)); + } + + - :pass: FALSE + :should: 'ignore foo() calls and notice if we called foo() less times than expected' + :code: | + test() + { + bar_Expect(4); + foo_IgnoreAndReturn(20); + foo_IgnoreAndReturn(10); + foo_IgnoreAndReturn(50); + foo_IgnoreAndReturn(60); + TEST_ASSERT_EQUAL(70, function(3, 4, 9)); + } + + - :pass: TRUE + :should: 'ignore bar() and foo() calls' + :code: | + test() + { + bar_Ignore(); + foo_IgnoreAndReturn(50); + foo_IgnoreAndReturn(50); + foo_IgnoreAndReturn(50); + TEST_ASSERT_EQUAL(150, function(0, 0, 0)); + } + + - :pass: TRUE + :should: 'ignore foo() calls over multiple mock calls' + :code: | + test() + { + bar_Ignore(); + foo_IgnoreAndReturn(50); + foo_IgnoreAndReturn(60); + foo_IgnoreAndReturn(70); + TEST_ASSERT_EQUAL(180, function(0, 0, 0)); + + bar_Ignore(); + foo_IgnoreAndReturn(30); + foo_IgnoreAndReturn(80); + foo_IgnoreAndReturn(10); + TEST_ASSERT_EQUAL(120, function(0, 0, 0)); + + bar_Ignore(); + foo_IgnoreAndReturn(70); + foo_IgnoreAndReturn(20); + foo_IgnoreAndReturn(20); + TEST_ASSERT_EQUAL(110, function(0, 0, 0)); + } + + - :pass: TRUE + :should: 'multiple cycles of expects still pass when ignores enabled' + :code: | + test() + { + bar_Expect(2); + foo_ExpectAndReturn(1, 50); + foo_ExpectAndReturn(2, 60); + foo_ExpectAndReturn(3, 70); + TEST_ASSERT_EQUAL(180, function(1, 2, 3)); + + bar_Expect(5); + foo_ExpectAndReturn(4, 30); + foo_ExpectAndReturn(5, 80); + foo_ExpectAndReturn(6, 10); + TEST_ASSERT_EQUAL(120, function(4, 5, 6)); + + bar_Expect(8); + foo_ExpectAndReturn(7, 70); + foo_ExpectAndReturn(8, 20); + foo_ExpectAndReturn(9, 20); + TEST_ASSERT_EQUAL(110, function(7, 8, 9)); + } + + - :pass: FALSE + :should: 'multiple cycles of expects still fail when ignores enabled' + :code: | + test() + { + bar_Expect(2); + foo_ExpectAndReturn(1, 50); + foo_ExpectAndReturn(2, 60); + foo_ExpectAndReturn(3, 70); + TEST_ASSERT_EQUAL(180, function(1, 2, 3)); + + bar_Expect(5); + foo_ExpectAndReturn(4, 30); + foo_ExpectAndReturn(5, 80); + foo_ExpectAndReturn(6, 10); + TEST_ASSERT_EQUAL(120, function(4, 5, 6)); + + bar_Expect(8); + foo_ExpectAndReturn(7, 70); + foo_ExpectAndReturn(8, 20); + foo_ExpectAndReturn(9, 20); + TEST_ASSERT_EQUAL(110, function(0, 8, 9)); + } + +...