mirror of
https://github.com/ThrowTheSwitch/CMock.git
synced 2026-07-25 05:24:13 +00:00
slightly better system testing
This commit is contained in:
@@ -8,6 +8,8 @@
|
||||
- :cexception
|
||||
- :ignore
|
||||
- :callback
|
||||
- :return_thru_ptr
|
||||
- :ignore_arg
|
||||
- :expect_any_args
|
||||
|
||||
:systest:
|
||||
@@ -327,6 +329,30 @@
|
||||
function_e();
|
||||
}
|
||||
|
||||
- :pass: TRUE
|
||||
:should: 'be ok if we ExpectAnyArgs and Expect intermixed because we are counting calls'
|
||||
:code: |
|
||||
test()
|
||||
{
|
||||
foos_Expect("Hello");
|
||||
foos_ExpectAnyArgs();
|
||||
foos_ExpectAnyArgs();
|
||||
|
||||
function_e();
|
||||
}
|
||||
|
||||
- :pass: FALSE
|
||||
:should: 'be able to detect Expect problem if we ExpectAnyArgs and Expect intermixed'
|
||||
:code: |
|
||||
test()
|
||||
{
|
||||
foos_Expect("Hello");
|
||||
foos_ExpectAnyArgs();
|
||||
foos_Expect("Wrong");
|
||||
|
||||
function_e();
|
||||
}
|
||||
|
||||
- :pass: FALSE
|
||||
:should: 'fail if we do not ExpectAnyArgs a call once because we are counting calls'
|
||||
:code: |
|
||||
|
||||
@@ -8,6 +8,7 @@
|
||||
- :callback
|
||||
- :return_thru_ptr
|
||||
- :ignore_arg
|
||||
- :expect_any_args
|
||||
:callback_after_arg_check: true
|
||||
:callback_include_count: false
|
||||
:treat_externs: :include
|
||||
@@ -30,9 +31,9 @@
|
||||
int mixed(int a, int* b, int c);
|
||||
void no_args(void);
|
||||
|
||||
:source:
|
||||
:header: |
|
||||
#include "CException.h"
|
||||
:source:
|
||||
:header: |
|
||||
#include "CException.h"
|
||||
void function_a(void);
|
||||
void function_b(void);
|
||||
void function_c(void);
|
||||
@@ -40,41 +41,41 @@
|
||||
void function_e(void);
|
||||
|
||||
:code: |
|
||||
void function_a(void)
|
||||
void function_a(void)
|
||||
{
|
||||
foo(bar());
|
||||
}
|
||||
}
|
||||
|
||||
void function_b(void) {
|
||||
fooa(bar());
|
||||
}
|
||||
|
||||
|
||||
void function_c(void) {
|
||||
CEXCEPTION_T e;
|
||||
Try {
|
||||
foos(bars());
|
||||
} Catch(e) { foos("err"); }
|
||||
}
|
||||
|
||||
|
||||
int function_d(void) {
|
||||
int test_list[] = { 1, 2, 3, 4, 5 };
|
||||
no_pointers(1, "silly");
|
||||
return mixed(6, test_list, 7);
|
||||
}
|
||||
|
||||
|
||||
void function_e(void) {
|
||||
foos("Hello");
|
||||
foos("Tuna");
|
||||
foos("Oranges");
|
||||
}
|
||||
|
||||
|
||||
:tests:
|
||||
:common: |
|
||||
#include "CException.h"
|
||||
void setUp(void) {}
|
||||
void tearDown(void) {}
|
||||
void my_foo_callback(POINT_T* a) { TEST_ASSERT_EQUAL_INT(2, a->x); }
|
||||
|
||||
|
||||
:units:
|
||||
- :pass: TRUE
|
||||
:should: 'handle the situation where we pass nulls to pointers'
|
||||
@@ -83,10 +84,10 @@
|
||||
{
|
||||
bar_ExpectAndReturn(NULL);
|
||||
foo_Expect(NULL);
|
||||
|
||||
|
||||
function_a();
|
||||
}
|
||||
|
||||
|
||||
- :pass: FALSE
|
||||
:should: 'handle the situation where we expected nulls to pointers but did not get that'
|
||||
:code: |
|
||||
@@ -95,10 +96,10 @@
|
||||
POINT_T pt = {1, 2};
|
||||
bar_ExpectAndReturn(&pt);
|
||||
foo_Expect(NULL);
|
||||
|
||||
|
||||
function_a();
|
||||
}
|
||||
|
||||
|
||||
- :pass: FALSE
|
||||
:should: 'handle the situation where we did not expect nulls to pointers but got null'
|
||||
:code: |
|
||||
@@ -107,10 +108,10 @@
|
||||
POINT_T ex = {1, 2};
|
||||
bar_ExpectAndReturn(NULL);
|
||||
foo_Expect(&ex);
|
||||
|
||||
|
||||
function_a();
|
||||
}
|
||||
|
||||
|
||||
- :pass: FALSE
|
||||
:should: 'handle the situation where we pass single object with expect and it is wrong'
|
||||
:code: |
|
||||
@@ -120,10 +121,10 @@
|
||||
POINT_T ex = {1, 3};
|
||||
bar_ExpectAndReturn(&pt);
|
||||
foo_Expect(&ex);
|
||||
|
||||
|
||||
function_a();
|
||||
}
|
||||
|
||||
|
||||
- :pass: TRUE
|
||||
:should: 'handle the situation where we pass single object with expect and use array handler'
|
||||
:code: |
|
||||
@@ -133,10 +134,10 @@
|
||||
POINT_T ex = {1, 2};
|
||||
bar_ExpectAndReturn(&pt);
|
||||
foo_ExpectWithArray(&ex, 1);
|
||||
|
||||
|
||||
function_a();
|
||||
}
|
||||
|
||||
|
||||
- :pass: FALSE
|
||||
:should: 'handle the situation where we pass single object with expect and use array handler and it is wrong'
|
||||
:code: |
|
||||
@@ -146,10 +147,10 @@
|
||||
POINT_T ex = {1, 3};
|
||||
bar_ExpectAndReturn(&pt);
|
||||
foo_ExpectWithArray(&ex, 1);
|
||||
|
||||
|
||||
function_a();
|
||||
}
|
||||
|
||||
|
||||
- :pass: TRUE
|
||||
:should: 'handle the situation where we pass multiple objects with expect and use array handler'
|
||||
:code: |
|
||||
@@ -159,10 +160,10 @@
|
||||
POINT_T ex[] = {{1, 2}, {3, 4}, {5, 6}};
|
||||
bar_ExpectAndReturn(pt);
|
||||
foo_ExpectWithArray(ex, 3);
|
||||
|
||||
|
||||
function_a();
|
||||
}
|
||||
|
||||
|
||||
- :pass: FALSE
|
||||
:should: 'handle the situation where we pass multiple objects with expect and use array handler and it is wrong at end'
|
||||
:code: |
|
||||
@@ -172,7 +173,7 @@
|
||||
POINT_T ex[] = {{1, 2}, {3, 4}, {5, 9}};
|
||||
bar_ExpectAndReturn(pt);
|
||||
foo_ExpectWithArray(ex, 3);
|
||||
|
||||
|
||||
function_a();
|
||||
}
|
||||
|
||||
@@ -185,7 +186,7 @@
|
||||
POINT_T ex = {1, 2};
|
||||
bar_ExpectAndReturn(&pt);
|
||||
fooa_Expect(&ex);
|
||||
|
||||
|
||||
function_b();
|
||||
}
|
||||
|
||||
@@ -196,10 +197,10 @@
|
||||
{
|
||||
bars_ExpectAndReturn("This is a\0 silly string");
|
||||
foos_Expect("This is a\0 wacky string");
|
||||
|
||||
|
||||
function_c();
|
||||
}
|
||||
|
||||
|
||||
- :pass: FALSE
|
||||
:should: 'handle standard c string as null terminated and not do crappy memory compares of a byte, finding failures'
|
||||
:code: |
|
||||
@@ -207,7 +208,7 @@
|
||||
{
|
||||
bars_ExpectAndReturn("This is a silly string");
|
||||
foos_Expect("This is a wacky string");
|
||||
|
||||
|
||||
function_c();
|
||||
}
|
||||
|
||||
@@ -219,7 +220,7 @@
|
||||
int expect_list[] = { 1, 9 };
|
||||
no_pointers_Expect(1, "silly");
|
||||
mixed_ExpectAndReturn(6, expect_list, 7, 13);
|
||||
|
||||
|
||||
TEST_ASSERT_EQUAL(13, function_d());
|
||||
}
|
||||
|
||||
@@ -231,7 +232,7 @@
|
||||
int expect_list[] = { 9, 1 };
|
||||
no_pointers_Expect(1, "silly");
|
||||
mixed_ExpectAndReturn(6, expect_list, 7, 13);
|
||||
|
||||
|
||||
TEST_ASSERT_EQUAL(13, function_d());
|
||||
}
|
||||
|
||||
@@ -243,7 +244,7 @@
|
||||
int expect_list[] = { 1, 2, 3, 4, 6 };
|
||||
no_pointers_Expect(1, "silly");
|
||||
mixed_ExpectWithArrayAndReturn(6, expect_list, 4, 7, 13);
|
||||
|
||||
|
||||
TEST_ASSERT_EQUAL(13, function_d());
|
||||
}
|
||||
|
||||
@@ -255,7 +256,7 @@
|
||||
int expect_list[] = { 1, 2, 3, 4, 6 };
|
||||
no_pointers_Expect(1, "silly");
|
||||
mixed_ExpectWithArrayAndReturn(6, expect_list, 5, 7, 13);
|
||||
|
||||
|
||||
TEST_ASSERT_EQUAL(13, function_d());
|
||||
}
|
||||
|
||||
@@ -267,7 +268,7 @@
|
||||
bars_ExpectAndReturn("This is a\0 silly string");
|
||||
foos_ExpectAndThrow("This is a\0 wacky string", 55);
|
||||
foos_Expect("err");
|
||||
|
||||
|
||||
function_c();
|
||||
}
|
||||
|
||||
@@ -279,7 +280,7 @@
|
||||
bars_ExpectAndReturn("This is a\0 silly string");
|
||||
foos_ExpectAndThrow("This is a\0 wacky string", 55);
|
||||
foos_Expect("wrong error");
|
||||
|
||||
|
||||
function_c();
|
||||
}
|
||||
|
||||
@@ -291,7 +292,7 @@
|
||||
int expect_list[] = { 1, 2, 3, 4, 6 };
|
||||
mixed_ExpectWithArrayAndReturn(6, expect_list, 4, 7, 13);
|
||||
no_pointers_Expect(1, "silly");
|
||||
|
||||
|
||||
TEST_ASSERT_EQUAL(13, function_d());
|
||||
}
|
||||
|
||||
@@ -303,7 +304,7 @@
|
||||
int expect_list[] = { 1, 2, 3, 4, 6 };
|
||||
mixed_ExpectWithArrayAndReturn(6, expect_list, 4, 7, 13);
|
||||
no_pointers_Ignore();
|
||||
|
||||
|
||||
TEST_ASSERT_EQUAL(13, function_d());
|
||||
}
|
||||
|
||||
@@ -314,7 +315,7 @@
|
||||
{
|
||||
mixed_IgnoreAndReturn(13);
|
||||
no_pointers_Expect(1, "silly");
|
||||
|
||||
|
||||
TEST_ASSERT_EQUAL(13, function_d());
|
||||
}
|
||||
|
||||
@@ -324,7 +325,7 @@
|
||||
test()
|
||||
{
|
||||
foos_Ignore();
|
||||
|
||||
|
||||
function_e();
|
||||
}
|
||||
|
||||
@@ -338,7 +339,7 @@
|
||||
bar_ExpectAndReturn(&pt1);
|
||||
foo_Expect(&pt2);
|
||||
foo_StubWithCallback((CMOCK_foo_CALLBACK)my_foo_callback);
|
||||
|
||||
|
||||
function_a();
|
||||
}
|
||||
|
||||
@@ -350,7 +351,7 @@
|
||||
POINT_T pt = {2, 3};
|
||||
bar_ExpectAndReturn(&pt);
|
||||
foo_StubWithCallback((CMOCK_foo_CALLBACK)my_foo_callback);
|
||||
|
||||
|
||||
function_a();
|
||||
}
|
||||
|
||||
@@ -364,7 +365,7 @@
|
||||
bar_ExpectAndReturn(&pt1);
|
||||
foo_Expect(&pt2);
|
||||
foo_StubWithCallback((CMOCK_foo_CALLBACK)my_foo_callback);
|
||||
|
||||
|
||||
function_a();
|
||||
}
|
||||
|
||||
@@ -377,7 +378,7 @@
|
||||
bar_ExpectAndReturn(&pt);
|
||||
foo_Expect(&pt);
|
||||
foo_StubWithCallback((CMOCK_foo_CALLBACK)my_foo_callback);
|
||||
|
||||
|
||||
function_a();
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user