generating branch coverage data for lcov

后端 未结 4 579
旧巷少年郎
旧巷少年郎 2021-02-02 11:44

i\'m trying to use lcov for code coverage metrics, but I cannot get branches coverage to work.

Here\'s how i\'m using it:

g++ -ggdb3 --coverage src/read.         


        
4条回答
  •  梦谈多话
    2021-02-02 12:26

    Sorry, not so much an "idea" as a confirmation that you're doing everything correctly. Your exact commands worked on this simple code:

    #include 
    using namespace std;
    
    bool foo(int i)
    {
        if (i != 0) {
            return 12 / i;
        } else {
            return 0;
        }
    }
    
    int main(int argc, char** argv)
    {
        cout << foo(argc) << endl;
        return 0;
    }
    

    The lcov coverage table has statistics for Lines, Functions, and Branches. Maybe double-check that you're actually looking at the correct output HTML?

提交回复
热议问题