Coverage for /Syzygy/common/syzygy_version.cc

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

Coverage information generated Tue Jun 25 13:56:24 2013.