We don’t allow questions seeking recommendations for software libraries, tutorials, tools, books, or other off-site resources. You can edit the question so it can be answered with facts and citations.
Closed 9 years ago.
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
接受
或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
发布评论
评论(1)
查看 TAP 进行单元测试。 Perl 使用它来测试 Perl 的内部结构(特别是 CPAN 提交),CCAN 采用了它。我假设是 C(你确实说过
a.out
)。然后,如果NDEBUG
未定义,则在读取2,2
(暗示 3 个字节)时,只需使读取函数失败。您可以使用其他东西,例如
-DUNIT_TESTS_RUNNING
,只需注意依赖关系。再说一遍,如果您正在测试的函数返回一个字符串..无需打扰预处理器,让测试弄清楚这一点。
TAP 确实非常容易集成。您可以在此处找到我的临时Valgrind 感知版本< /a>.请注意,这是不正确的,该存储库一团糟,但值得展示的是让其他工具与 TAP 一起工作是多么容易。
顺便说一句, TAP : (T)est (A)nything (P)rotocol
如果这不是 C,您需要重新标记您的问题。
Have a look at TAP for unit testing. Its what Perl uses for testing the innards of Perl (specifically CPAN submissions), CCAN adopted it. I'm assuming C (you did say
a.out
). Then, simply make your read function fail if2,2
is read (hinting on 3 bytes) ifNDEBUG
is not defined.You could use something else, like
-DUNIT_TESTS_RUNNING
, just watch out for dependencies.Then again, if the function you are testing returns a string .. no need to bother the preprocessor, let the test figure that out.
TAP is really, really easy to integrate. You can find my ad-hoc Valgrind aware version here. Note, that is not proper, that repo is a mess, but worth showing how easy it is to make other tools work with TAP.
Incidentally, TAP : (T)est (A)nything (P)rotocol
If this is NOT C, you need to re-tag your question.