# executor-sample-c **Repository Path**: CAUCHY2932/executor-sample-c ## Basic Information - **Project Name**: executor-sample-c - **Description**: No description available - **Primary Language**: Unknown - **License**: MIT - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 0 - **Created**: 2021-09-04 - **Last Updated**: 2024-10-22 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README # executor-sample-c ## ctags install failed brew install ctags-exuberant ## compile ``` mkdir build cd build cmake .. make ``` ## reference ### cmake https://cmake.org/cmake/help/latest/command/target_link_directories.html ### gtest https://www.cnblogs.com/coderzh/archive/2009/04/06/1430396.html ## 编码 先写用例 再写接口 再实现细节 ## 流程 - 编译二进制,主要是业务代码的lib库 -c - 编译gtest -u - 编译用例二进制 -b - 执行 -t ## 多平台兼容 https://blog.csdn.net/yushulx/article/details/78529934 ? link_directories(/Users/zhoumeixu/Documents/cmakedemoa/build) ## googletest https://google.github.io/googletest/ ## google style https://google.github.io/styleguide/cppguide.html#Operator_Overloading link_directories 和下面的功能相同 target_link_directories 老版cmake不支持 ## mockcpp https://blog.csdn.net/xunye_dream/article/details/81055215 https://www.cnblogs.com/sinojelly/archive/2010/11/24/1886925.html ```c TEST(mockcpp detail sample) { MOCKER(function) / MOCK_METHOD(mocker, method) .stubs() / defaults() / expects(never() | once() | exactly(3) | atLeast(3) | atMost(3) ) [.before("some-mocker-id")] [.with( any() | eq(3) | neq(3) | gt(3) | lt(3) | spy(var_out) | check(check_func) | outBound(var_out) | outBoundP(var_out_addr, var_size) | mirror(var_in_addr, var_size) | smirror(string) | contains(string) | startWith(string) | endWith(string) )] [.after("some-mocker-id")] .will( returnValue(1) | repeat(1, 20) | returnObjectList(r1, r2) | invoke(func_stub) | ignoreReturnValue() | increase(from, to) | increase(from) | throws(exception)) [.then(returnValue(2))] [.id("some-mocker-id")] } 注: 1、扩展关键字分类: expects里面的叫匹配关键字(Matcher); with里面的叫约束关键字(Constraint); will/then里面的叫桩关键字(Stub)。 2、spy的作用是监视执行该被mock的函数function被调用时传入的值,会保存在var_out中,供用例中其它地方使用。 3、outBound的作用是设置函数function的出参的值。多半是把该值作为后面部分被测代码的输入。(注意与spy区别) 4、outBoundP,与outBound作用相同,只是用于数组的情况。 5、mirror的作用是对数组类型的入参进行检查。(outBoundP是设置出参的值,两者是不同的) 6、check的作用是进行定制化的入参检查,比如只检查结构体的部分成员。可以通过函数指针或者仿函数的方式指定,用仿函数还能预先保存一些值,非常方便。 7、check也能够用于设置出参的情况。 ``` ctrl - t 回跳代码 https://www.cnblogs.com/solanin315/p/13414071.html https://www.cnblogs.com/zhangxuan/p/6430034.html https://blog.csdn.net/dansen_xu/archive/2007/08/13/1768524.aspx https://www.cnblogs.com/porkerface/p/12397015.html ## gcc include ```bash gcc main.c add.c -I add.h gcc main.c add.c -I ./ ```