c++ - googletest 错误:“HasSubstr”没有依赖于模板参数的参数
问题描述
我正在使用googletest
我的程序(C++
)测试。在其中一个测试中,我必须检查一个字符串是否存在于另一个字符串中,例如:
#include <gtest/gtest.h>
TEST_F(TestSet, substringCheck)
{
string s1 = "the fruit is apple";
string s2 = "apple";
EXPECT_THAT(s1, HasSubstr(s2));
}
但它给了我这个错误:
error: there are no arguments to ‘HasSubstr’ that depend on a template parameter, so a declaration of ‘HasSubstr’ must be available
我不认为 googletest 有任何其他直接的方法来检查子字符串,所以我正在使用HasSubstr
这个测试,任何人都可以指导:
- 错误提示什么?
- 如何解决?
解决方案
推荐阅读
- javascript - 映射数组时在JS中解构对象的正确语法是什么?
- vba - 有没有办法以编程方式获取子项目的种子值?
- algorithm - Leetcode 1449,动态规划
- c# - 我需要获取列表框选定项 wpf 的属性
- c - C - 不同文件中全局定义的变量,显示没有外部链接的外部链接
- python - 使用代理请求时出现 AttributeError
- stata - Converting day and month variables into Numerical values (Stata)
- spring-boot - 如何在前端访问安全的 API?
- python - C# CNTK 如何替换/重塑输入层
- flutter - 在登录和仪表板屏幕之间导航的正确方法?