- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我对库进行了一些更改,以使其与项目保持一致。我进行了测试,一切仍然通过,但覆盖率不再是100%。我调查了一下,发现代码没有被执行。但是我不知道为什么gcov在执行时没有报告该行的覆盖范围。
这是代码:
int32_t PreviouslyEncountered(uint32_t n)
{
uint32_t i;
/* Search thru all the numbers encoountered so far see if there is a match */
for(i = 0; i < xcount; i++)
{
if(n == collection[i])
{
return 1; /* This value has been seen before */
}
}
/* Add the number to encountered values if there is space */
if(xcount < NUMBERTRACKERMAX )
{
collection[xcount] = n;
xcount++;
}
else
{
return NUMBERTRACKERMAX ;
}
return 0;
}
/* Fill with 10000 elements */
for(i = 0; i < NUMBERTRACKERMAX; i++)
{
assert(PreviouslyEncountered(i) == 0);
}
/* Test that all 10000 elements are present */
for(i = 0; i < NUMBERTRACKERMAX; i++)
{
assert(PreviouslyEncountered(i) == 1);
}
-: 51:int32_t PreviouslyEncountered(uint32_t n)
function PreviouslyEncountered called 201 returned 100% blocks executed 90%
201: 52:{
201: 53: uint32_t i;
-: 54:
-: 55: /* Search thru all the numbers encoountered so far see if there is a match */
20101: 56: for(i = 0; i < xcount; i++)
-: 57: {
19900: 58: if(n == collection[i])
-: 59: {
#####: 60: return 1; /* This value has been seen before */
-: 61: }
-: 62: }
-: 63:
-: 64: /* Add the number to encountered values if there is space */
201: 65: if(xcount < NUMBERTRACKERMAX )
-: 66: {
200: 67: collection[xcount] = n;
200: 68: xcount++;
-: 69: }
-: 70: else
-: 71: {
1: 72: return NUMBERTRACKERMAX ;
-: 73: }
-: 74:
200: 75: return 0;
-: 76:
-: 77:}
return 1;
之前执行添加打印。它不会获得覆盖,但是
return 1
现在将具有覆盖。有任何想法吗?除了手册页之外,我什么也找不到。
PreviouslyEncountered
的测试将为该功能提供100%的覆盖率。运行其他测试将重置此设置。
最佳答案
我能够重构导致问题的代码,因此我再次获得了100%的覆盖率。我不知道问题出在哪里。也许我会再检查一次。
关于c - Gcov报告意外的覆盖结果,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1294454/
我使用 gcc -fprofile-arcs -ftest-coverage [filenames] 在一些 .c 文件上运行 gcov 工具。命令 但向该命令提供文件名是一项非常繁琐的工作。 相反,
我可以在 Windows 中安装 gcov 工具吗? 或者我可以在windows的eclipse中使用这个工具的插件吗? 我对这个工具很陌生。我对这个工具没有任何想法。请帮我获取这个工具的信息。 请告
我在 RHEL 上运行 gcov/gcc 4.1.2。 当我想为 gcov 文件指定一个目录时。关于如何执行此操作的任何想法? 最佳答案 从要创建其文件的目录运行 gcov。您必须使用 -o 参数来告
我正在尝试使用 gcov-tool 为多个源文件合并一些现有的覆盖率数据(不是我自己创建的)。但是当我调用 gcov-tool merge dir1 dir2 时,dir1 和 dir2 是包含 .g
我正在运行 gcov 来测量覆盖率,但对于我在 C 代码中使用的每个函数,我都收到“有来自退出 block 的弧”消息。这条消息有什么问题吗?我应该忽略它们吗? 最佳答案 这可能意味着您的 gcno
我正在尝试使用 gcc 4.8.2 和 lcov 1.10 获取 html 覆盖率以进行测试。我确定我的源文件、对象和 gcov 文件位于同一位置,并且我正在从我运行编译器的目录中运行 lcov。 我
我在远程服务器上用 gcov 标志编译了我的源文件。 CFLAGS += -fprofile-arcs -ftest-coverage -lgcov -coverage 编译工作正常。 gcc 4.7
在使用 gcov 支持编译我的项目时,我面临以下错误 以下是我在编译时的标志信息 编译器标志: CXXFLAGS="-Wno-deprecated -g -ggdb -fprofile-arcs -f
我正在尝试在 iPhone 项目上使用 gcov 并遵循 Apple 的说明 here ,但它不起作用。 当我构建并配置项目时,会为每个目标文件创建 .gcda 文件。但没有执行的行记录到 .gcda
我尝试使用 gcov 编译一个简单的应用程序并收到以下链接错误: gcc AllTests.o CuTestTest.o CuTest.o -o TestTest AllTests.o: In fun
资料夹结构 〜/沙盒/ dev 〜/沙盒/测试 我在dev目录中有main.cpp。我使用--coverage标志编译了代码以生成代码覆盖率。 现在,将生成a.out和main.gcno文件。 现在我
我正在使用 gcov 来获取我们项目的代码覆盖率,但它经常报告 50% 的普通函数调用的条件覆盖率。函数是否接受任何参数或返回任何数据都没有任何区别。我在 Jenkins 中使用 gcovr 和 Co
无法使用我的 C/C++ Makefile 项目在 Windows 上使用 mingw32 的 googletest 获取 gcov 覆盖文件完整源代码位于https://github.com/rus
我正在使用 gcov这是我第一次遇到与此 thread 中报告的问题类似的问题.但是,根据该线程中的评论,我无法解决我的问题。 我正在尝试测量 KMyMoney-4.6.4 中具体测试用例的覆盖率,即
我正在使用 eclipse indigo 和 linux 工具。其中一个工具是 gcov 的插件。我有一个项目是 statis lib(点一个文件)和另一个项目是一个单元测试,它与这个 lib 链接并
我在 32 位机器上使用 -fprofile-arcs -ftest-coverage 标志交叉编译我的可执行文件以覆盖。我在 64 位目标机器上运行生成的可执行文件。 当我运行可执行文件时,它不会生
是否可以使用 gcov 进行多线程应用程序的覆盖测试? 我已经对我们的代码库进行了一些简单的测试,但如果能对我们正在实现的覆盖范围有一些了解就更好了。如果 gcov 不合适,任何人都可以推荐一个替代工
我正在使用 gcov 来衡量我贡献的 c++ 库的测试覆盖率。出于某种原因,gcov 无法将许多文件中的行识别为可执行文件。在给定文件的 160 多行中,它会说其中 40 行是可执行的。例如:
MWE #include struct Foo { Foo() { std::cout << "Constructing Foo " << this << std::endl; }
我正在使用 gcov 测量我的 C++ 代码中的覆盖率。我希望能够标记某些源代码行,以便在使用 gcovr 时将它们排除在覆盖率报告之外。我知道它们存在,因为我曾经偶然发现过它们,但现在我找不到看到它
我是一名优秀的程序员,十分优秀!