使用 QVariant 进行单元测试
我想对返回 qvariant 的函数进行单元测试,以确保 qvariant 是否持有正确的 vlaue 请给我一些想法,我应该如何进行?
I want to make a unit-test for a function returning a qvariant to make sure if the qvariant is holding the right vlaue or not
Please give me some idea to how should i proceed?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
创建一个包含您期望的值的 QVariant,然后将其与返回值进行比较。为什么您认为这与测试任何其他返回类型不同?
Create a QVariant containing the value you're expecting and then compare it with the return value. Why do you think this is different to testing any other return type?
方法 QVariant::type() 和 QVariant::typename() 应该为您提供足够的信息。
The methos QVariant::type() and QVariant::typename() should give you enough information.