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