本文整理汇总了C++中CMock_Guts_MemNew函数的典型用法代码示例。如果您正苦于以下问题:C++ CMock_Guts_MemNew函数的具体用法?C++ CMock_Guts_MemNew怎么用?C++ CMock_Guts_MemNew使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了CMock_Guts_MemNew函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: test_MemNewWillReturnNullIfGivenIllegalSizes
void test_MemNewWillReturnNullIfGivenIllegalSizes(void)
{
TEST_ASSERT_NULL( CMock_Guts_MemNew(0) );
TEST_ASSERT_NULL( CMock_Guts_MemNew(CMOCK_MEM_SIZE - TEST_MEM_INDEX_SIZE + 1) );
//verify we're cleared still
TEST_ASSERT_EQUAL(0, CMock_Guts_MemBytesUsed());
TEST_ASSERT_EQUAL(CMOCK_MEM_SIZE, CMock_Guts_MemBytesFree());
}
示例2: test_ThatWeCanAskForAllSortsOfSizes
void test_ThatWeCanAskForAllSortsOfSizes(void)
{
unsigned int i;
unsigned int* first = NULL;
unsigned int* next;
unsigned int sizes[5] = {3, 1, 80, 5, 4};
unsigned int sizes_buffered[5] = {4, 4, 80, 8, 4};
unsigned int sum = 0;
for (i = 0; i < 5; i++)
{
next = CMock_Guts_MemNew(sizes[i]);
TEST_ASSERT_NOT_NULL(next);
first = CMock_Guts_MemChain(first, next);
TEST_ASSERT_NOT_NULL(first);
sum += sizes_buffered[i] + 4;
TEST_ASSERT_EQUAL(sum, CMock_Guts_MemBytesUsed());
TEST_ASSERT_EQUAL(CMOCK_MEM_SIZE - sum, CMock_Guts_MemBytesFree());
}
//show that we can't ask for too much memory
TEST_ASSERT_NULL(CMock_Guts_MemNew(12));
TEST_ASSERT_NULL(CMock_Guts_MemNew(5));
//but we CAN ask for something that will still fit
next = CMock_Guts_MemNew(4);
TEST_ASSERT_NOT_NULL(next);
first = CMock_Guts_MemChain(first, next);
TEST_ASSERT_NOT_NULL(first);
//verify we're used up now
TEST_ASSERT_EQUAL(CMOCK_MEM_SIZE, CMock_Guts_MemBytesUsed());
TEST_ASSERT_EQUAL(0, CMock_Guts_MemBytesFree());
//verify we can still walk through the elements allocated
next = first;
for (i = 0; i < 6; i++)
{
TEST_ASSERT_NOT_NULL(next);
next = CMock_Guts_MemNext(next);
}
//there aren't any after that
TEST_ASSERT_NULL(next);
}
示例3: test_ThatWeCanAskForAllSortsOfSizes
void test_ThatWeCanAskForAllSortsOfSizes(void)
{
unsigned int i;
CMOCK_MEM_INDEX_TYPE first = CMOCK_GUTS_NONE;
CMOCK_MEM_INDEX_TYPE next;
unsigned int sizes[10] = {3, 1, 80, 5, 8, 31, 7, 911, 2, 80};
unsigned int sizes_buffered[10] = {16, 16, 88, 16, 16, 40, 16, 920, 16, 88}; //includes counter
unsigned int sum = 0;
unsigned int cap;
for (i = 0; i < 10; i++)
{
next = CMock_Guts_MemNew(sizes[i]);
TEST_ASSERT_MESSAGE(next != CMOCK_GUTS_NONE, "Should Not Have Returned CMOCK_GUTS_NONE");
first = CMock_Guts_MemChain(first, next);
TEST_ASSERT_MESSAGE(first != CMOCK_GUTS_NONE, "Should Not Have Returned CMOCK_GUTS_NONE");
sum += sizes_buffered[i];
cap = (StartingSize > (sum + CMOCK_MEM_SIZE)) ? StartingSize : (sum + CMOCK_MEM_SIZE);
TEST_ASSERT_EQUAL(sum, CMock_Guts_MemBytesUsed());
TEST_ASSERT(cap >= CMock_Guts_MemBytesFree());
}
//verify we can still walk through the elements allocated
next = first;
for (i = 0; i < 10; i++)
{
TEST_ASSERT_MESSAGE(next != CMOCK_GUTS_NONE, "Should Not Have Returned CMOCK_GUTS_NONE");
next = CMock_Guts_MemNext(next);
}
//there aren't any after that
TEST_ASSERT_EQUAL_HEX( CMOCK_GUTS_NONE, next);
}
示例4: test_ThatCMockStopsReturningMoreDataWhenAskForMoreThanItHasLeftEvenIfNotAtExactEnd
void test_ThatCMockStopsReturningMoreDataWhenAskForMoreThanItHasLeftEvenIfNotAtExactEnd(void)
{
unsigned int i;
CMOCK_MEM_INDEX_TYPE first = CMOCK_GUTS_NONE;
CMOCK_MEM_INDEX_TYPE next;
//we're asking for 12 bytes each time now (4 for index, 8 for data).
//10 requests will give us 120 bytes used, which isn't enough for another 12 bytes if total memory is 128
for (i = 0; i < 10; i++)
{
TEST_ASSERT_EQUAL(i*12, CMock_Guts_MemBytesUsed());
TEST_ASSERT_EQUAL(CMOCK_MEM_SIZE - i*12, CMock_Guts_MemBytesFree());
next = CMock_Guts_MemNew(8);
TEST_ASSERT_MESSAGE(next != CMOCK_GUTS_NONE, "Should Not Have Returned CMOCK_GUTS_NONE");
first = CMock_Guts_MemChain(first, next);
TEST_ASSERT_MESSAGE(first != CMOCK_GUTS_NONE, "Should Not Have Returned CMOCK_GUTS_NONE");
//verify writing data won't screw us up
*((unsigned int*)CMock_Guts_GetAddressFor(next)) = i;
}
//verify we're at top of memory
TEST_ASSERT_EQUAL(CMOCK_MEM_SIZE - 8, CMock_Guts_MemBytesUsed());
TEST_ASSERT_EQUAL(8, CMock_Guts_MemBytesFree());
//The very next call will return a NONE, and any after that
TEST_ASSERT_EQUAL_HEX(CMOCK_GUTS_NONE, CMock_Guts_MemNew(8));
TEST_ASSERT_EQUAL_HEX(CMOCK_GUTS_NONE, CMock_Guts_MemNew(5));
//verify nothing has changed
TEST_ASSERT_EQUAL(CMOCK_MEM_SIZE - 8, CMock_Guts_MemBytesUsed());
TEST_ASSERT_EQUAL(8, CMock_Guts_MemBytesFree());
//verify we can still walk through the elements allocated
next = first;
for (i = 0; i < 10; i++)
{
TEST_ASSERT_MESSAGE(next != CMOCK_GUTS_NONE, "Should Not Have Returned CMOCK_GUTS_NONE");
TEST_ASSERT_EQUAL(i, *((unsigned int*)CMock_Guts_GetAddressFor(next)));
next = CMock_Guts_MemNext(next);
}
//there aren't any after that
TEST_ASSERT_EQUAL_HEX(CMOCK_GUTS_NONE, next);
}
示例5: test_MemNewWillReturnNullIfGivenIllegalSizes
void test_MemNewWillReturnNullIfGivenIllegalSizes(void)
{
TEST_ASSERT_EQUAL_HEX( CMOCK_GUTS_NONE, CMock_Guts_MemNew(0) );
//verify we're cleared still
TEST_ASSERT_EQUAL(0, CMock_Guts_MemBytesUsed());
TEST_ASSERT_EQUAL(0, CMock_Guts_MemBytesFree());
}
示例6: qeocore_remote_registration_init_cond_CMockExpect
void qeocore_remote_registration_init_cond_CMockExpect(UNITY_LINE_TYPE cmock_line)
{
CMOCK_MEM_INDEX_TYPE cmock_guts_index = CMock_Guts_MemNew(sizeof(CMOCK_qeocore_remote_registration_init_cond_CALL_INSTANCE));
CMOCK_qeocore_remote_registration_init_cond_CALL_INSTANCE* cmock_call_instance = (CMOCK_qeocore_remote_registration_init_cond_CALL_INSTANCE*)CMock_Guts_GetAddressFor(cmock_guts_index);
UNITY_TEST_ASSERT_NOT_NULL(cmock_call_instance, cmock_line, "CMock has run out of memory. Please allocate more.");
Mock.qeocore_remote_registration_init_cond_CallInstance = CMock_Guts_MemChain(Mock.qeocore_remote_registration_init_cond_CallInstance, cmock_guts_index);
cmock_call_instance->LineNumber = cmock_line;
}
示例7: Adc_StartTemperatureSensorConversion_CMockExpect
void Adc_StartTemperatureSensorConversion_CMockExpect(UNITY_LINE_TYPE cmock_line)
{
CMOCK_MEM_INDEX_TYPE cmock_guts_index = CMock_Guts_MemNew(sizeof(CMOCK_Adc_StartTemperatureSensorConversion_CALL_INSTANCE));
CMOCK_Adc_StartTemperatureSensorConversion_CALL_INSTANCE* cmock_call_instance = (CMOCK_Adc_StartTemperatureSensorConversion_CALL_INSTANCE*)CMock_Guts_GetAddressFor(cmock_guts_index);
UNITY_TEST_ASSERT_NOT_NULL(cmock_call_instance, cmock_line, "CMock has run out of memory. Please allocate more.");
Mock.Adc_StartTemperatureSensorConversion_CallInstance = CMock_Guts_MemChain(Mock.Adc_StartTemperatureSensorConversion_CallInstance, cmock_guts_index);
cmock_call_instance->LineNumber = cmock_line;
}
示例8: test_ThatCMockStopsReturningMoreDataWhenItRunsOutOfMemory
void test_ThatCMockStopsReturningMoreDataWhenItRunsOutOfMemory(void)
{
unsigned int i;
unsigned int* first = NULL;
unsigned int* next;
//even though we are asking for one byte, we've told it to align to closest 4 bytes, therefore it will waste a byte each time
//so each call will use 8 bytes (4 for the index, 1 for the data, and 3 wasted).
//therefore we can safely allocated total/8 times.
for (i = 0; i < (CMOCK_MEM_SIZE / 8); i++)
{
TEST_ASSERT_EQUAL(i*8, CMock_Guts_MemBytesUsed());
TEST_ASSERT_EQUAL(CMOCK_MEM_SIZE - i*8, CMock_Guts_MemBytesFree());
next = CMock_Guts_MemNew(1);
TEST_ASSERT_NOT_NULL(next);
first = CMock_Guts_MemChain(first, next);
TEST_ASSERT_NOT_NULL(first);
}
//verify we're at top of memory
TEST_ASSERT_EQUAL(CMOCK_MEM_SIZE, CMock_Guts_MemBytesUsed());
TEST_ASSERT_EQUAL(0, CMock_Guts_MemBytesFree());
//The very next call will return a NULL, and any after that
TEST_ASSERT_NULL(CMock_Guts_MemNew(1));
TEST_ASSERT_NULL(CMock_Guts_MemNew(1));
TEST_ASSERT_NULL(CMock_Guts_MemNew(1));
//verify nothing has changed
TEST_ASSERT_EQUAL(CMOCK_MEM_SIZE, CMock_Guts_MemBytesUsed());
TEST_ASSERT_EQUAL(0, CMock_Guts_MemBytesFree());
//verify we can still walk through the elements allocated
next = first;
for (i = 0; i < (CMOCK_MEM_SIZE / 8); i++)
{
TEST_ASSERT_NOT_NULL(next);
next = CMock_Guts_MemNext(next);
}
//there aren't any after that
TEST_ASSERT_NULL(next);
}
示例9: getFileSystemsInfo_CMockExpectAndReturn
void getFileSystemsInfo_CMockExpectAndReturn(UNITY_LINE_TYPE cmock_line, diskSpaceStatParce* cmock_to_return)
{
CMOCK_MEM_INDEX_TYPE cmock_guts_index = CMock_Guts_MemNew(sizeof(CMOCK_getFileSystemsInfo_CALL_INSTANCE));
CMOCK_getFileSystemsInfo_CALL_INSTANCE* cmock_call_instance = (CMOCK_getFileSystemsInfo_CALL_INSTANCE*)CMock_Guts_GetAddressFor(cmock_guts_index);
UNITY_TEST_ASSERT_NOT_NULL(cmock_call_instance, cmock_line, "CMock has run out of memory. Please allocate more.");
Mock.getFileSystemsInfo_CallInstance = CMock_Guts_MemChain(Mock.getFileSystemsInfo_CallInstance, cmock_guts_index);
cmock_call_instance->LineNumber = cmock_line;
cmock_call_instance->ReturnVal = cmock_to_return;
}
示例10: qeo_deviceinfo_destruct_CMockExpect
void qeo_deviceinfo_destruct_CMockExpect(UNITY_LINE_TYPE cmock_line, qeo_factory_t* factory)
{
CMOCK_MEM_INDEX_TYPE cmock_guts_index = CMock_Guts_MemNew(sizeof(CMOCK_qeo_deviceinfo_destruct_CALL_INSTANCE));
CMOCK_qeo_deviceinfo_destruct_CALL_INSTANCE* cmock_call_instance = (CMOCK_qeo_deviceinfo_destruct_CALL_INSTANCE*)CMock_Guts_GetAddressFor(cmock_guts_index);
UNITY_TEST_ASSERT_NOT_NULL(cmock_call_instance, cmock_line, "CMock has run out of memory. Please allocate more.");
Mock.qeo_deviceinfo_destruct_CallInstance = CMock_Guts_MemChain(Mock.qeo_deviceinfo_destruct_CallInstance, cmock_guts_index);
cmock_call_instance->LineNumber = cmock_line;
CMockExpectParameters_qeo_deviceinfo_destruct(cmock_call_instance, factory);
}
示例11: test_MemNewWillNowSupportSizesGreaterThanTheDefinesCMockSize
void test_MemNewWillNowSupportSizesGreaterThanTheDefinesCMockSize(void)
{
TEST_ASSERT_EQUAL(0, CMock_Guts_MemBytesFree());
TEST_ASSERT_MESSAGE(CMock_Guts_MemNew(CMOCK_MEM_SIZE - TEST_MEM_INDEX_SIZE + 1) != CMOCK_GUTS_NONE, "Should Not Have Returned CMOCK_GUTS_NONE");
TEST_ASSERT_EQUAL(CMOCK_MEM_SIZE + TEST_MEM_INDEX_PAD, CMock_Guts_MemBytesUsed());
TEST_ASSERT_EQUAL(CMOCK_MEM_SIZE, CMock_Guts_MemBytesFree());
}
示例12: qeo_platform_security_update_state_CMockExpect
void qeo_platform_security_update_state_CMockExpect(UNITY_LINE_TYPE cmock_line, qeo_platform_security_context_t context, qeo_platform_security_state state, qeo_platform_security_state_reason state_reason)
{
CMOCK_MEM_INDEX_TYPE cmock_guts_index = CMock_Guts_MemNew(sizeof(CMOCK_qeo_platform_security_update_state_CALL_INSTANCE));
CMOCK_qeo_platform_security_update_state_CALL_INSTANCE* cmock_call_instance = (CMOCK_qeo_platform_security_update_state_CALL_INSTANCE*)CMock_Guts_GetAddressFor(cmock_guts_index);
UNITY_TEST_ASSERT_NOT_NULL(cmock_call_instance, cmock_line, "CMock has run out of memory. Please allocate more.");
Mock.qeo_platform_security_update_state_CallInstance = CMock_Guts_MemChain(Mock.qeo_platform_security_update_state_CallInstance, cmock_guts_index);
cmock_call_instance->LineNumber = cmock_line;
CMockExpectParameters_qeo_platform_security_update_state(cmock_call_instance, context, state, state_reason);
}
示例13: I2CWriteInit_CMockExpect
void I2CWriteInit_CMockExpect(UNITY_LINE_TYPE cmock_line)
{
CMOCK_MEM_INDEX_TYPE cmock_guts_index = CMock_Guts_MemNew(sizeof(CMOCK_I2CWriteInit_CALL_INSTANCE));
CMOCK_I2CWriteInit_CALL_INSTANCE* cmock_call_instance = (CMOCK_I2CWriteInit_CALL_INSTANCE*)CMock_Guts_GetAddressFor(cmock_guts_index);
UNITY_TEST_ASSERT_NOT_NULL(cmock_call_instance, cmock_line, "CMock has run out of memory. Please allocate more.");
Mock.I2CWriteInit_CallInstance = CMock_Guts_MemChain(Mock.I2CWriteInit_CallInstance, cmock_guts_index);
cmock_call_instance->LineNumber = cmock_line;
cmock_call_instance->CallOrder = ++GlobalExpectCount;
}
示例14: Adc_TemperatureSensorSampleReady_CMockExpectAndReturn
void Adc_TemperatureSensorSampleReady_CMockExpectAndReturn(UNITY_LINE_TYPE cmock_line, bool cmock_to_return)
{
CMOCK_MEM_INDEX_TYPE cmock_guts_index = CMock_Guts_MemNew(sizeof(CMOCK_Adc_TemperatureSensorSampleReady_CALL_INSTANCE));
CMOCK_Adc_TemperatureSensorSampleReady_CALL_INSTANCE* cmock_call_instance = (CMOCK_Adc_TemperatureSensorSampleReady_CALL_INSTANCE*)CMock_Guts_GetAddressFor(cmock_guts_index);
UNITY_TEST_ASSERT_NOT_NULL(cmock_call_instance, cmock_line, "CMock has run out of memory. Please allocate more.");
Mock.Adc_TemperatureSensorSampleReady_CallInstance = CMock_Guts_MemChain(Mock.Adc_TemperatureSensorSampleReady_CallInstance, cmock_guts_index);
cmock_call_instance->LineNumber = cmock_line;
cmock_call_instance->ReturnVal = cmock_to_return;
}
示例15: qeo_security_policy_destroy_CMockExpectAndReturn
void qeo_security_policy_destroy_CMockExpectAndReturn(UNITY_LINE_TYPE cmock_line, qeo_retcode_t cmock_to_return)
{
CMOCK_MEM_INDEX_TYPE cmock_guts_index = CMock_Guts_MemNew(sizeof(CMOCK_qeo_security_policy_destroy_CALL_INSTANCE));
CMOCK_qeo_security_policy_destroy_CALL_INSTANCE* cmock_call_instance = (CMOCK_qeo_security_policy_destroy_CALL_INSTANCE*)CMock_Guts_GetAddressFor(cmock_guts_index);
UNITY_TEST_ASSERT_NOT_NULL(cmock_call_instance, cmock_line, "CMock has run out of memory. Please allocate more.");
Mock.qeo_security_policy_destroy_CallInstance = CMock_Guts_MemChain(Mock.qeo_security_policy_destroy_CallInstance, cmock_guts_index);
cmock_call_instance->LineNumber = cmock_line;
memcpy(&cmock_call_instance->ReturnVal, &cmock_to_return, sizeof(qeo_retcode_t));
}