//--------------------------------------------------------------------+ // BULK TRANSFER //--------------------------------------------------------------------+ void verify_qtd(ehci_qtd_t *p_qtd, uint8_t p_data[], uint16_t length) { TEST_ASSERT_TRUE(p_qtd->alternate.terminate); // not used, always invalid //------------- status -------------// TEST_ASSERT_FALSE(p_qtd->pingstate_err); TEST_ASSERT_FALSE(p_qtd->non_hs_split_state); TEST_ASSERT_FALSE(p_qtd->non_hs_period_missed_uframe); TEST_ASSERT_FALSE(p_qtd->xact_err); TEST_ASSERT_FALSE(p_qtd->babble_err); TEST_ASSERT_FALSE(p_qtd->buffer_err); TEST_ASSERT_FALSE(p_qtd->halted); TEST_ASSERT_TRUE(p_qtd->active); TEST_ASSERT_FALSE(p_qtd->data_toggle); TEST_ASSERT_EQUAL(3, p_qtd->cerr); TEST_ASSERT_EQUAL(0, p_qtd->current_page); TEST_ASSERT_EQUAL(length, p_qtd->total_bytes); TEST_ASSERT_EQUAL(length, p_qtd->expected_bytes); TEST_ASSERT_TRUE(p_qtd->used); TEST_ASSERT_EQUAL_HEX( p_data, p_qtd->buffer[0] ); for(uint8_t i=1; i<5; i++) { TEST_ASSERT_EQUAL_HEX( align4k((uint32_t) (p_data+4096*i)), align4k(p_qtd->buffer[i]) ); } }
void test_bulk_xfer_double(void) { //------------- Code Under Test -------------// TEST_ASSERT_STATUS( hcd_pipe_xfer(pipe_hdl_bulk, xfer_data, sizeof(xfer_data), false) ); TEST_ASSERT_STATUS( hcd_pipe_xfer(pipe_hdl_bulk, data2, sizeof(data2), true) ); ehci_qtd_t* p_head = p_qhd_bulk->p_qtd_list_head; ehci_qtd_t* p_tail = p_qhd_bulk->p_qtd_list_tail; //------------- list head -------------// TEST_ASSERT_NOT_NULL(p_head); verify_qtd(p_head, xfer_data, sizeof(xfer_data)); TEST_ASSERT_EQUAL_HEX(p_qhd_bulk->qtd_overlay.next.address, p_head); TEST_ASSERT_EQUAL(EHCI_PID_IN, p_head->pid); TEST_ASSERT_FALSE(p_head->next.terminate); TEST_ASSERT_FALSE(p_head->int_on_complete); //------------- list tail -------------// TEST_ASSERT_NOT_NULL(p_tail); verify_qtd(p_tail, data2, sizeof(data2)); TEST_ASSERT_EQUAL_HEX( align32(p_head->next.address), p_tail); TEST_ASSERT_EQUAL(EHCI_PID_IN, p_tail->pid); TEST_ASSERT_TRUE(p_tail->next.terminate); TEST_ASSERT_TRUE(p_tail->int_on_complete); }
void test_initialization() { TEST_ASSERT_EQUAL_HEX(_BV(TWEN) | _BV(TWIE), TWCR); TEST_ASSERT_EQUAL_HEX(0x00, TWDR); BOOL res = twi_init(testPin1, testPin2); TEST_ASSERT_FALSE_MESSAGE(res, "Second initialization of twi master should not be possible"); TEST_ASSERT_EQUAL(PinTwiIO, pinOccupation(testPin1)); TEST_ASSERT_EQUAL(PinTwiIO, pinOccupation(testPin2)); }
void test_FunctionWhichReturnsLocalVariable_ShouldReturnTheCurrentCounterValue(void) { //This should be true because setUp set this up for us before this test TEST_ASSERT_EQUAL_HEX(0x5a5a, FunctionWhichReturnsLocalVariable()); //This should be true because we can still change our answer Counter = 0x1234; TEST_ASSERT_EQUAL_HEX(0x1234, FunctionWhichReturnsLocalVariable()); }
void test_MemNewWillReturnNullIfGivenIllegalSizes(void) { TEST_ASSERT_EQUAL_HEX( CMOCK_GUTS_NONE, CMock_Guts_MemNew(0) ); TEST_ASSERT_EQUAL_HEX( CMOCK_GUTS_NONE, CMock_Guts_MemNew(CMOCK_MEM_SIZE - TEST_MEM_INDEX_SIZE + 1) ); TEST_ASSERT_NULL( CMock_Guts_GetAddressFor(CMOCK_GUTS_NONE) ); //verify we're cleared still TEST_ASSERT_EQUAL(0, CMock_Guts_MemBytesUsed()); TEST_ASSERT_EQUAL(CMOCK_MEM_SIZE, CMock_Guts_MemBytesFree()); }
void test_MemNextWillReturnNullIfGivenABadRoot(void) { TEST_ASSERT_EQUAL_HEX( CMOCK_GUTS_NONE, CMock_Guts_MemNext(0) ); TEST_ASSERT_EQUAL_HEX( CMOCK_GUTS_NONE, CMock_Guts_MemNext(2) ); TEST_ASSERT_EQUAL_HEX( CMOCK_GUTS_NONE, CMock_Guts_MemNext(CMOCK_MEM_SIZE - 4) ); //verify we're cleared still TEST_ASSERT_EQUAL(0, CMock_Guts_MemBytesUsed()); TEST_ASSERT_EQUAL(CMOCK_MEM_SIZE, CMock_Guts_MemBytesFree()); }
void test_MemChainWillReturnNullAndDoNothingIfGivenIllegalInformation(void) { CMOCK_MEM_INDEX_TYPE next = CMock_Guts_MemNew(4); TEST_ASSERT_EQUAL(4 + TEST_MEM_INDEX_SIZE, CMock_Guts_MemBytesUsed()); TEST_ASSERT_EQUAL(CMOCK_MEM_SIZE - 4 - TEST_MEM_INDEX_SIZE, CMock_Guts_MemBytesFree()); TEST_ASSERT_EQUAL_HEX( CMOCK_GUTS_NONE, CMock_Guts_MemChain(next + CMOCK_MEM_SIZE, next) ); TEST_ASSERT_EQUAL_HEX( CMOCK_GUTS_NONE, CMock_Guts_MemChain(next, next + CMOCK_MEM_SIZE) ); //verify we're still the same TEST_ASSERT_EQUAL(4 + TEST_MEM_INDEX_SIZE, CMock_Guts_MemBytesUsed()); TEST_ASSERT_EQUAL(CMOCK_MEM_SIZE - 4 - TEST_MEM_INDEX_SIZE, CMock_Guts_MemBytesFree()); }
void test_ThatWeCanAskForAllSortsOfSizes(void) { unsigned int i; CMOCK_MEM_INDEX_TYPE first = CMOCK_GUTS_NONE; CMOCK_MEM_INDEX_TYPE 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_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] + 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_EQUAL_HEX(CMOCK_GUTS_NONE, CMock_Guts_MemNew(12)); TEST_ASSERT_EQUAL_HEX(CMOCK_GUTS_NONE, CMock_Guts_MemNew(5)); //but we CAN ask for something that will still fit next = CMock_Guts_MemNew(4); 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 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_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); }
void check_int_endpoint_link(ehci_qhd_t *p_prev, ehci_qhd_t *p_qhd) { //------------- period list check -------------// TEST_ASSERT_EQUAL_HEX((uint32_t) p_qhd, align32(p_prev->next.address)); TEST_ASSERT_FALSE(p_prev->next.terminate); TEST_ASSERT_EQUAL(EHCI_QUEUE_ELEMENT_QHD, p_prev->next.type); }
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); }
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); }
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()); }
void test_ThatCMockStopsReturningMoreDataWhenItRunsOutOfMemory(void) { unsigned int i; CMOCK_MEM_INDEX_TYPE first = CMOCK_GUTS_NONE; CMOCK_MEM_INDEX_TYPE 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_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 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_EQUAL_HEX(CMOCK_GUTS_NONE, CMock_Guts_MemNew(1)); TEST_ASSERT_EQUAL_HEX(CMOCK_GUTS_NONE, CMock_Guts_MemNew(1)); TEST_ASSERT_EQUAL_HEX(CMOCK_GUTS_NONE, 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_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); }
void test_bulk_xfer(void) { //------------- Code Under Test -------------// TEST_ASSERT_STATUS( hcd_pipe_xfer(pipe_hdl_bulk, xfer_data, sizeof(xfer_data), true) ); ehci_qtd_t* p_qtd = p_qhd_bulk->p_qtd_list_head; TEST_ASSERT_NOT_NULL(p_qtd); verify_qtd( p_qtd, xfer_data, sizeof(xfer_data)); TEST_ASSERT_EQUAL_HEX(p_qhd_bulk->qtd_overlay.next.address, p_qtd); TEST_ASSERT_TRUE(p_qtd->next.terminate); TEST_ASSERT_EQUAL(EHCI_PID_IN, p_qtd->pid); TEST_ASSERT_TRUE(p_qtd->int_on_complete); }
//--------------------------------------------------------------------+ // PIPE CLOSE //--------------------------------------------------------------------+ void test_interrupt_close(void) { pipe_hdl = hcd_pipe_open(dev_addr, &desc_ept_interrupt_out, TUSB_CLASS_HID); p_int_qhd = qhd_get_from_pipe_handle(pipe_hdl); //------------- Code Under TEST -------------// TEST_ASSERT_EQUAL(TUSB_ERROR_NONE, hcd_pipe_close(pipe_hdl) ); TEST_ASSERT(p_int_qhd->is_removing); TEST_ASSERT( align32(period_head_arr->next.address) != (uint32_t) p_int_qhd ); TEST_ASSERT_EQUAL_HEX( (uint32_t) period_head_arr, align32(p_int_qhd->next.address ) ); TEST_ASSERT_EQUAL(EHCI_QUEUE_ELEMENT_QHD, p_int_qhd->next.type); }
void test_interrupt_256ms_close(void) { tusb_descriptor_endpoint_t int_edp_interval = desc_ept_interrupt_out; int_edp_interval.bInterval = 9; pipe_hdl = hcd_pipe_open(dev_addr, &int_edp_interval, TUSB_CLASS_HID); p_int_qhd = qhd_get_from_pipe_handle(pipe_hdl); //------------- Code Under TEST -------------// TEST_ASSERT_EQUAL(TUSB_ERROR_NONE, hcd_pipe_close(pipe_hdl) ); TEST_ASSERT(p_int_qhd->is_removing); TEST_ASSERT( align32(get_period_head(hostid, 8)->address) != (uint32_t) p_int_qhd ); TEST_ASSERT_EQUAL_HEX( (uint32_t) get_period_head(hostid, 8), align32(p_int_qhd->next.address ) ); TEST_ASSERT_EQUAL(EHCI_QUEUE_ELEMENT_QHD, p_int_qhd->next.type); }
tusb_error_t stub_hidd_init(uint8_t coreid, tusb_descriptor_interface_t const* p_interface_desc, uint16_t* p_length, int num_call) { switch(num_call) { case 0: TEST_ASSERT_EQUAL_HEX(&app_tusb_desc_configuration.keyboard_interface, p_interface_desc); break; case 1: TEST_ASSERT_EQUAL_HEX32(&app_tusb_desc_configuration.mouse_interface, p_interface_desc); break; default: TEST_FAIL(); return TUSB_ERROR_FAILED; } return TUSB_ERROR_NONE; }
void stub_sem_wait_success(osal_semaphore_handle_t const sem_hdl, uint32_t msec, tusb_error_t *p_error, int num_call) { TEST_ASSERT_EQUAL_HEX(p_rndis->sem_notification_hdl, sem_hdl); (*p_error) = TUSB_ERROR_NONE; }
TEST(create_hashtable, then_hash_key_len_and_val_len_must_be_set) { TEST_ASSERT_EQUAL_HEX(tbl->keyLen, 123); TEST_ASSERT_EQUAL_HEX(tbl->valLen, 1034); }
void test_FunctionWhichReturnsLocalVariable_ShouldReturnCurrentCounter_ButFailsBecauseThisTestIsActuallyFlawed(void) { //Sometimes you get the test wrong. When that happens, you get a failure too... and a quick look should tell // you what actually happened...which in this case was a failure to setup the initial condition. TEST_ASSERT_EQUAL_HEX(0x1234, FunctionWhichReturnsLocalVariable()); }
void test_FunctionWhichReturnsLocalVariable_ShouldReturnTheCurrentCounterValueAgain(void) { //This should be true again because setup was rerun before this test (and after we changed it to 0x1234) TEST_ASSERT_EQUAL_HEX(0x5a5a, FunctionWhichReturnsLocalVariable()); }
void test_ThatWeCanClaimAndChainAFewElementsTogether(void) { unsigned int i; CMOCK_MEM_INDEX_TYPE next; CMOCK_MEM_INDEX_TYPE first = CMOCK_GUTS_NONE; CMOCK_MEM_INDEX_TYPE element[4]; //verify we're cleared first TEST_ASSERT_EQUAL(0, CMock_Guts_MemBytesUsed()); TEST_ASSERT_EQUAL(CMOCK_MEM_SIZE, CMock_Guts_MemBytesFree()); //first element element[0] = CMock_Guts_MemNew(sizeof(unsigned int)); TEST_ASSERT_MESSAGE(element[0] != CMOCK_GUTS_NONE, "Should Not Have Returned CMOCK_GUTS_NONE"); first = CMock_Guts_MemChain(first, element[0]); TEST_ASSERT_EQUAL(element[0], first); *((unsigned int*)CMock_Guts_GetAddressFor(element[0])) = 0; //verify we're using the right amount of memory TEST_ASSERT_EQUAL(1 * (TEST_MEM_INDEX_SIZE + 4), CMock_Guts_MemBytesUsed()); TEST_ASSERT_EQUAL(CMOCK_MEM_SIZE - 1 * (TEST_MEM_INDEX_SIZE + 4), CMock_Guts_MemBytesFree()); //second element element[1] = CMock_Guts_MemNew(sizeof(unsigned int)); TEST_ASSERT_MESSAGE(element[1] != CMOCK_GUTS_NONE, "Should Not Have Returned CMOCK_GUTS_NONE"); TEST_ASSERT_NOT_EQUAL(element[0], element[1]); TEST_ASSERT_EQUAL(first, CMock_Guts_MemChain(first, element[1])); *((unsigned int*)CMock_Guts_GetAddressFor(element[1])) = 1; //verify we're using the right amount of memory TEST_ASSERT_EQUAL(2 * (TEST_MEM_INDEX_SIZE + 4), CMock_Guts_MemBytesUsed()); TEST_ASSERT_EQUAL(CMOCK_MEM_SIZE - 2 * (TEST_MEM_INDEX_SIZE + 4), CMock_Guts_MemBytesFree()); //third element element[2] = CMock_Guts_MemNew(sizeof(unsigned int)); TEST_ASSERT_MESSAGE(element[2] != CMOCK_GUTS_NONE, "Should Not Have Returned CMOCK_GUTS_NONE"); TEST_ASSERT_NOT_EQUAL(element[0], element[2]); TEST_ASSERT_NOT_EQUAL(element[1], element[2]); TEST_ASSERT_EQUAL(first, CMock_Guts_MemChain(first, element[2])); *((unsigned int*)CMock_Guts_GetAddressFor(element[2])) = 2; //verify we're using the right amount of memory TEST_ASSERT_EQUAL(3 * (TEST_MEM_INDEX_SIZE + 4), CMock_Guts_MemBytesUsed()); TEST_ASSERT_EQUAL(CMOCK_MEM_SIZE - 3 * (TEST_MEM_INDEX_SIZE + 4), CMock_Guts_MemBytesFree()); //fourth element element[3] = CMock_Guts_MemNew(sizeof(unsigned int)); TEST_ASSERT_MESSAGE(element[3] != CMOCK_GUTS_NONE, "Should Not Have Returned CMOCK_GUTS_NONE"); TEST_ASSERT_NOT_EQUAL(element[0], element[3]); TEST_ASSERT_NOT_EQUAL(element[1], element[3]); TEST_ASSERT_NOT_EQUAL(element[2], element[3]); TEST_ASSERT_EQUAL(first, CMock_Guts_MemChain(first, element[3])); *((unsigned int*)CMock_Guts_GetAddressFor(element[3])) = 3; //verify we're using the right amount of memory TEST_ASSERT_EQUAL(4 * (TEST_MEM_INDEX_SIZE + 4), CMock_Guts_MemBytesUsed()); TEST_ASSERT_EQUAL(CMOCK_MEM_SIZE - 4 * (TEST_MEM_INDEX_SIZE + 4), CMock_Guts_MemBytesFree()); //traverse list next = first; for (i = 0; i < 4; i++) { TEST_ASSERT_EQUAL(element[i], next); TEST_ASSERT_EQUAL(i, *((unsigned int*)CMock_Guts_GetAddressFor(element[i]))); next = CMock_Guts_MemNext(next); } //verify we get a null at the end of the list TEST_ASSERT_EQUAL_HEX(CMOCK_GUTS_NONE, next); //verify we're using the right amount of memory TEST_ASSERT_EQUAL(4 * (TEST_MEM_INDEX_SIZE + 4), CMock_Guts_MemBytesUsed()); TEST_ASSERT_EQUAL(CMOCK_MEM_SIZE - 4 * (TEST_MEM_INDEX_SIZE + 4), CMock_Guts_MemBytesFree()); //Free it all CMock_Guts_MemFreeAll(); //verify we're cleared TEST_ASSERT_EQUAL(0, CMock_Guts_MemBytesUsed()); TEST_ASSERT_EQUAL(CMOCK_MEM_SIZE, CMock_Guts_MemBytesFree()); }
TEST(create_hashtable, then_hash_func_and_cmp_must_be_set) { TEST_ASSERT_EQUAL_HEX(tbl->hashFunc, hashFuncTest); TEST_ASSERT_EQUAL_HEX(tbl->hashCmp, hashCmpFuncTest); }