diff --git a/test/system/test_interactions/expect_and_return_treat_as.yml b/test/system/test_interactions/expect_and_return_treat_as.yml index e48c960..2a73273 100644 --- a/test/system/test_interactions/expect_and_return_treat_as.yml +++ b/test/system/test_interactions/expect_and_return_treat_as.yml @@ -5,6 +5,7 @@ :treat_as: MY_STRING: STRING MY_INT: INT + PTR_INT: INT* MY_HEX: HEX32 :systest: @@ -12,18 +13,23 @@ typedef char* MY_STRING; typedef int MY_INT; typedef unsigned int MY_HEX; + typedef int* PTR_INT; :mockable: | MY_INT foo(MY_HEX a); MY_INT bar(MY_HEX b); MY_STRING foo_char_strings(MY_STRING a, MY_STRING b); float float_adder(float a, float b); + MY_INT* pointer_foo(MY_HEX* a); + void pointer_bar(PTR_INT a); :source: :header: | MY_INT function_a(MY_INT a, MY_INT b); MY_STRING function_b(MY_STRING a, MY_STRING b); float function_c(float a, float b); + MY_INT function_d(MY_HEX a); + void function_e(PTR_INT a); :code: | MY_INT function_a(MY_INT a, MY_INT b) @@ -41,6 +47,18 @@ return float_adder(b, a); } + MY_INT function_d(MY_HEX a) + { + MY_HEX b = a; + MY_INT* c = pointer_foo(&b); + return *c; + } + + void function_e(PTR_INT a) + { + pointer_bar(a); + } + :tests: :common: | void setUp(void) {} @@ -101,5 +119,55 @@ float_adder_ExpectAndReturn(1.2345, 6.7892, 8.0235); TEST_ASSERT_EQUAL_FLOAT(8.0235, function_c(6.7890, 1.2345)); } + + - :pass: TRUE + :should: 'handle pointers to treat_as values just as cleanly as the treat_as itself for passes' + :code: | + test() + { + MY_HEX TestHex = (MY_HEX)45; + MY_INT TestInt = (MY_INT)33; + pointer_foo_ExpectAndReturn(&TestHex, &TestInt); + TEST_ASSERT_EQUAL_INT(33, function_d(45)); + } + + - :pass: FALSE + :should: 'handle pointers to treat_as values just as cleanly as the treat_as itself for failures' + :verify_error: 'Element 0 Expected 0x0000002D Was 0x0000002B' + :code: | + test() + { + MY_HEX TestHex = (MY_HEX)45; + MY_INT TestInt = (MY_INT)33; + pointer_foo_ExpectAndReturn(&TestHex, &TestInt); + TEST_ASSERT_EQUAL_INT(33, function_d(43)); + } + + - :pass: TRUE + :should: 'handle treat_as values containing pointers for passes' + :code: | + test() + { + MY_INT ExpInt = (MY_INT)33; + PTR_INT ExpPtr = (PTR_INT)(&ExpInt); + MY_INT ActInt = (MY_INT)33; + PTR_INT ActPtr = (PTR_INT)(&ActInt); + pointer_bar_Expect(ExpPtr); + function_e(ActPtr); + } + + - :pass: FALSE + :should: 'handle treat_as values containing pointers for failures' + :verify_error: 'Element 0 Expected 33 Was 45' + :code: | + test() + { + MY_INT ExpInt = (MY_INT)33; + PTR_INT ExpPtr = (PTR_INT)(&ExpInt); + MY_INT ActInt = (MY_INT)45; + PTR_INT ActPtr = (PTR_INT)(&ActInt); + pointer_bar_Expect(ExpPtr); + function_e(ActPtr); + } ...