Coverage for /Syzygy/grinder/coverage_data_unittest.cc

CoverageLines executed / instrumented / missingexe / inst / missLanguageGroup
100.0%27270.C++test

Line-by-line coverage:

   1    :  // Copyright 2012 Google Inc. All Rights Reserved.
   2    :  //
   3    :  // Licensed under the Apache License, Version 2.0 (the "License");
   4    :  // you may not use this file except in compliance with the License.
   5    :  // You may obtain a copy of the License at
   6    :  //
   7    :  //     http://www.apache.org/licenses/LICENSE-2.0
   8    :  //
   9    :  // Unless required by applicable law or agreed to in writing, software
  10    :  // distributed under the License is distributed on an "AS IS" BASIS,
  11    :  // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  12    :  // See the License for the specific language governing permissions and
  13    :  // limitations under the License.
  14    :  
  15    :  #include "syzygy/grinder/coverage_data.h"
  16    :  
  17    :  #include "gmock/gmock.h"
  18    :  #include "gtest/gtest.h"
  19    :  
  20    :  namespace grinder {
  21    :  
  22    :  namespace {
  23    :  
  24    :  using testing::ContainerEq;
  25    :  
  26    :  class TestLineInfo : public LineInfo {
  27    :   public:
  28    :    using LineInfo::source_files_;
  29    :    using LineInfo::source_lines_;
  30    :  
  31  E :    void InitDummyLineInfoFoo() {
  32    :      LineInfo::SourceFileSet::iterator file_it =
  33  E :          source_files_.insert("foo.cc").first;
  34  E :      const std::string* file_name = &(*file_it);
  35    :  
  36    :      source_lines_.push_back(LineInfo::SourceLine(
  37  E :          file_name, 1, core::RelativeAddress(0), 1));
  38    :      source_lines_.push_back(LineInfo::SourceLine(
  39  E :          file_name, 2, core::RelativeAddress(1), 1));
  40    :      source_lines_.push_back(LineInfo::SourceLine(
  41  E :          file_name, 3, core::RelativeAddress(2), 1));
  42    :  
  43    :      // Visits lines 1 and 2.
  44  E :      Visit(core::RelativeAddress(0), 2, 1);
  45  E :    }
  46    :  };
  47    :  
  48    :  }  // namespace
  49    :  
  50    :  // We provide this so that we can use ContainerEq. It must be outside of the
  51    :  // anonymous namespace for this to compile.
  52    :  bool operator==(const CoverageData::SourceFileCoverageData& lhs,
  53  E :                  const CoverageData::SourceFileCoverageData& rhs) {
  54  E :    return lhs.line_execution_count_map == rhs.line_execution_count_map;
  55  E :  }
  56    :  
  57  E :  TEST(CoverageDataTest, Construct) {
  58  E :    CoverageData coverage;
  59  E :    EXPECT_TRUE(coverage.source_file_coverage_data_map().empty());
  60  E :  }
  61    :  
  62  E :  TEST(CoverageDataTest, Add) {
  63  E :    TestLineInfo line_info;
  64  E :    ASSERT_NO_FATAL_FAILURE(line_info.InitDummyLineInfoFoo());
  65    :  
  66  E :    CoverageData coverage;
  67  E :    EXPECT_TRUE(coverage.Add(line_info));
  68    :  
  69  E :    CoverageData::SourceFileCoverageDataMap expected_coverage_info_map;
  70    :    CoverageData::LineExecutionCountMap& expected_line_exec =
  71  E :        expected_coverage_info_map["foo.cc"].line_execution_count_map;
  72  E :    expected_line_exec[1] = 1;
  73  E :    expected_line_exec[2] = 1;
  74  E :    expected_line_exec[3] = 0;
  75    :  
  76    :    EXPECT_THAT(expected_coverage_info_map,
  77  E :                ContainerEq(coverage.source_file_coverage_data_map()));
  78  E :  }
  79    :  
  80    :  }  // namespace grinder

Coverage information generated Thu Jan 14 17:40:38 2016.