mirror of
https://github.com/ThrowTheSwitch/CMock.git
synced 2026-10-29 20:13:35 +00:00
- handles pointers (but not yet arrays)
git-svn-id: http://cmock.svn.sourceforge.net/svnroot/cmock/trunk@63 bf332499-1b4d-0410-844d-d2d48d5cc64c
This commit is contained in:
@@ -25,3 +25,18 @@ bool AdcConductor_JustHereToTest(void)
|
||||
|
||||
return AdcModel_DoNothingExceptTestASpecialType(ExampleStruct);
|
||||
}
|
||||
|
||||
bool AdcConductor_AlsoHereToTest(void)
|
||||
{
|
||||
EXAMPLE_STRUCT_T example = AdcModel_DoNothingExceptReturnASpecialType();
|
||||
|
||||
return ((example.x == 99) && (example.y == 1));
|
||||
}
|
||||
|
||||
bool AdcConductor_YetAnotherTest(void)
|
||||
{
|
||||
uint32 example = 3;
|
||||
|
||||
return AdModel_DoNothingExceptTestPointers(&example);
|
||||
}
|
||||
|
||||
|
||||
@@ -5,5 +5,7 @@ void AdcConductor_Init(void);
|
||||
void AdcConductor_Run(void);
|
||||
|
||||
bool AdcConductor_JustHereToTest(void);
|
||||
bool AdcConductor_AlsoHereToTest(void);
|
||||
bool AdcConductor_YetAnotherTest(void);
|
||||
|
||||
#endif // _ADCCONDUCTOR_H
|
||||
|
||||
@@ -18,3 +18,15 @@ bool AdcModel_DoNothingExceptTestASpecialType(EXAMPLE_STRUCT_T ExampleStruct)
|
||||
{
|
||||
//This doesn't really do anything. it's only here to make sure I can compare a struct.
|
||||
}
|
||||
bool AdModel_DoNothingExceptTestPointers(uint32* pExample)
|
||||
{
|
||||
//This doesn't really do anything. it's only here to make sure I can compare a pointer value.
|
||||
}
|
||||
|
||||
EXAMPLE_STRUCT_T AdcModel_DoNothingExceptReturnASpecialType(void)
|
||||
{
|
||||
EXAMPLE_STRUCT_T example; //again, this just is here to test that I can return a struct
|
||||
example.x = 99;
|
||||
example.y = 1;
|
||||
return example;
|
||||
}
|
||||
|
||||
@@ -5,5 +5,7 @@ bool AdcModel_DoGetSample(void);
|
||||
void AdcModel_ProcessInput(uint16 millivolts);
|
||||
|
||||
bool AdcModel_DoNothingExceptTestASpecialType(EXAMPLE_STRUCT_T ExampleStruct);
|
||||
bool AdModel_DoNothingExceptTestPointers(uint32* pExample);
|
||||
EXAMPLE_STRUCT_T AdcModel_DoNothingExceptReturnASpecialType(void);
|
||||
|
||||
#endif // _ADCMODEL_H
|
||||
|
||||
@@ -79,3 +79,43 @@ void testJustHereToTest_Should_ProperlyPassAStructAndVerifyIt(void)
|
||||
// TEST_ASSERT_TRUE(AdcConductor_JustHereToTest());
|
||||
//}
|
||||
|
||||
void test_AdcConductor_AlsoHereToTest_Should_ProperlyReturnAStructAsExpected1(void)
|
||||
{
|
||||
EXAMPLE_STRUCT_T TestStruct;
|
||||
TestStruct.x = 99;
|
||||
TestStruct.y = 1;
|
||||
|
||||
AdcModel_DoNothingExceptReturnASpecialType_ExpectAndReturn(TestStruct);
|
||||
|
||||
TEST_ASSERT_TRUE(AdcConductor_AlsoHereToTest());
|
||||
}
|
||||
|
||||
void test_AdcConductor_AlsoHereToTest_Should_ProperlyReturnAStructAsExpected2(void)
|
||||
{
|
||||
EXAMPLE_STRUCT_T TestStruct;
|
||||
TestStruct.x = 98;
|
||||
TestStruct.y = 1;
|
||||
|
||||
AdcModel_DoNothingExceptReturnASpecialType_ExpectAndReturn(TestStruct);
|
||||
|
||||
TEST_ASSERT_FALSE(AdcConductor_AlsoHereToTest());
|
||||
}
|
||||
|
||||
void test_AdcConductor_YetAnotherTest_Should_VerifyThatPointersToStructsAreTestable(void)
|
||||
{
|
||||
uint32 TestNum = 3;
|
||||
|
||||
AdModel_DoNothingExceptTestPointers_ExpectAndReturn(&TestNum, TRUE);
|
||||
|
||||
TEST_ASSERT_TRUE(AdcConductor_YetAnotherTest());
|
||||
}
|
||||
|
||||
//void test_AdcConductor_YetAnotherTest_Should_FailIfYouUncommentThisTestBecauseTheValuePointedToIsWrong(void)
|
||||
//{
|
||||
// uint32 TestNum = 7;
|
||||
//
|
||||
// AdModel_DoNothingExceptTestPointers_ExpectAndReturn(&TestNum, FALSE);
|
||||
//
|
||||
// TEST_ASSERT_FALSE(AdcConductor_YetAnotherTest());
|
||||
//}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user