Coverage for /Syzygy/version/syzygy_version.cc

CoverageLines executed / instrumented / missingexe / inst / missLanguageGroup
100.0%38380.C++source

Line-by-line coverage:

   1    :  // Copyright 2011 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/version/syzygy_version.h"
  16    :  
  17    :  #include "base/strings/stringprintf.h"
  18    :  
  19    :  namespace version {
  20    :  
  21  E :  const SyzygyVersion kSyzygyVersion(SYZYGY_MAJOR, SYZYGY_MINOR, SYZYGY_BUILD,
  22  E :                                     SYZYGY_PATCH, SYZYGY_LASTCHANGE_FULL);
  23    :  
  24    :  SyzygyVersion::SyzygyVersion()
  25  E :      : major_(0),
  26  E :        minor_(0),
  27  E :        build_(0),
  28  E :        patch_(0) {
  29  E :  }
  30    :  
  31    :  SyzygyVersion::SyzygyVersion(uint16_t major,
  32    :                               uint16_t minor,
  33    :                               uint16_t build,
  34    :                               uint16_t patch,
  35    :                               const char* last_change)
  36  E :      : major_(major),
  37  E :        minor_(minor),
  38  E :        build_(build),
  39  E :        patch_(patch),
  40  E :        last_change_(last_change) {
  41  E :    DCHECK(last_change != NULL);
  42  E :  }
  43    :  
  44  E :  int SyzygyVersion::CompareOctet(const SyzygyVersion& rhs) const {
  45  E :    int c = static_cast<int>(major_) - rhs.major_;
  46  E :    if (c != 0)
  47  E :      return c;
  48    :  
  49  E :    c = static_cast<int>(minor_) - rhs.minor_;
  50  E :    if (c != 0)
  51  E :      return c;
  52    :  
  53  E :    c = static_cast<int>(build_) - rhs.build_;
  54  E :    if (c != 0)
  55  E :      return c;
  56    :  
  57  E :    return static_cast<int>(patch_) - rhs.patch_;
  58  E :  }
  59    :  
  60  E :  bool SyzygyVersion::operator==(const SyzygyVersion& rhs) const {
  61  E :    return major_ == rhs.major_ && minor_ == rhs.minor_ &&
  62    :        build_ == rhs.build_ && patch_ == rhs.patch_ &&
  63    :        last_change_ == rhs.last_change_;
  64  E :  }
  65    :  
  66  E :  bool SyzygyVersion::IsCompatible(const SyzygyVersion& rhs) const {
  67    :    // Eventually, we may have reason to be less strict here.
  68  E :    return *this == rhs;
  69  E :  }
  70    :  
  71  E :  std::string SyzygyVersion::GetVersionString() const {
  72    :    std::string version =
  73  E :        base::StringPrintf("%d.%d.%d.%d", major_, minor_, build_, patch_);
  74    :    // Only append the last-change string if it is not empty.
  75  E :    if (!last_change_.empty()) {
  76  E :      version += base::StringPrintf(" (%.7s)", last_change_.c_str());
  77    :    }
  78  E :    return version;
  79  E :  }
  80    :  
  81    :  }  // namespace version

Coverage information generated Fri Jul 29 11:00:21 2016.