fff:模拟从另一个模块引用返回的值

问题描述 投票:0回答:1

使用Fake Function Framework,我有这段代码(释义):

void sched_step(void) {
    event_t event;
    int status;

    status = queue_fetch(&event);
    if (status == OK) {
        do_something_with(&event);
        ...
    }
}

在为

sched
模块编写单元测试时,我想通过引用来控制queue_fetch()返回的内容,也就是说,我想伪造
event
的值,而不拖入整个
queue
模块

我一直不知道如何在 fff 中做到这一点。有人可以给我指路吗?

unit-testing mocking fake-function-framework
1个回答
0
投票

也许您可以在模拟外部依赖项的示例中找到一些灵感:https://github.com/meekrosoft/fff/blob/master/examples/embedded_ui/src/UI_test_ansic.c

自述文件包含一些关于 如何从假货返回引用的帮助。

© www.soinside.com 2019 - 2024. All rights reserved.