????????????????? ????????
???????????? ???????[ 2012/9/27 11:08:08 ] ????????
?????????Cmockery?????????????????????????????????????????ио???
stub_dll.c
dll_node_t *dll_pop_head (dll_t *_p_dll)
{
return (dll_node_t *)mock ();
}
test_mpool.c
void test_mpool_buffer_alloc ()
{
mpool_node_t mnode;
// set up test environment
mnode.addr_ = 0x5A5A5A5A;
mnode.in_use_ = false;
// do test
will_return (dll_pop_head?? &mnode.node_);
assert_int_equal (mpool_buffer_alloc (handler)?? 0x5A5A5A5A);
will_return (dll_pop_head?? 0);
assert_int_equal (mpool_buffer_alloc (handler)?? 0);
}
????????????????????????????????????????饗State Verification??????????????????饗Behavior Verification????????????????????????????????????????飩???????????????????????????????????μ?Martin Fowler???Mocks aren’t Stubs????
??????????е????????????????????????????????????????????????????????е?????????????????????????????????????????????????????????????????滻??????????????????????????Ч?????????????????????????????????£????????????????滻???????????????????????????????????£?????????????????????????????????????????????????????????????????????????????????????????????????????????顣???????????????????????????????????????????????????????滮???????е??????????????м????????????????????????????????????????????????????????????????????????????????????????????????СС???????? — ?????????
????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????2????????????????????????????????????????????滻???????????????????????????????????????dll_pop_head??????????
dll.c
dll_node_t *dll_pop_head (dll_t *_p_dll)
{
dll_node_t *p_node = _p_dll->head_;
#ifdef UNIT_TESTING
{
dll_node_t *p_node;
error_t ecode = injected_error_get (
INJECTION_POINT_DLL_POP_HEAD?? &p_node);
if (ecode != 0) {
return p_node;
}
}
#endif
if (p_node != 0) {
_p_dll->count_--;
_p_dll->head_ = p_node->next_;
if (0 == _p_dll->head_) {
_p_dll->tail_ = 0;
}
else {
p_node->next_->prev_ = 0;
}
p_node->next_ = 0;
p_node->prev_ = 0;
}
return p_node;
}
??????
???·???
??????????????????
2023/3/23 14:23:39???д?ò??????????
2023/3/22 16:17:39????????????????????Щ??
2022/6/14 16:14:27??????????????????????????
2021/10/18 15:37:44???????????????
2021/9/17 15:19:29???·???????·
2021/9/14 15:42:25?????????????
2021/5/28 17:25:47??????APP??????????
2021/5/8 17:01:11