Coverage for /Syzygy/common/com_utils.cc

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

Line-by-line coverage:

   1    :  // Copyright 2014 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    :  // Utilities for COM objects, error codes etc.
  16    :  
  17    :  #include "syzygy/common/com_utils.h"
  18    :  
  19    :  #include <atlbase.h>
  20    :  #include <shlwapi.h>
  21    :  
  22    :  #include "base/strings/string_util.h"
  23    :  
  24    :  namespace common {
  25    :  
  26  E :  std::ostream& operator<<(std::ostream& os, const LogHr& hr) {
  27    :    // Looks up the human-readable system message for the HRESULT code
  28    :    // and since we're not passing any params to FormatMessage, we don't
  29    :    // want inserts expanded.
  30    :    const DWORD kFlags = FORMAT_MESSAGE_FROM_SYSTEM |
  31  E :                         FORMAT_MESSAGE_IGNORE_INSERTS;
  32  E :    char error_text[4096] = { '\0' };
  33    :    ::FormatMessageA(kFlags, 0, hr.hr_, 0, error_text, arraysize(error_text),
  34  E :                     NULL);
  35  E :    std::string error(error_text);
  36  E :    base::TrimWhitespaceASCII(error, base::TRIM_ALL, &error);
  37    :  
  38  E :    return os << "[hr=0x" << std::hex << hr.hr_ << ", msg=" << error << "]";
  39  E :  }
  40    :  
  41  E :  std::ostream& operator<<(std::ostream& os, const LogWe& we) {
  42    :    // Looks up the human-readable system message for the Windows error code
  43    :    // and since we're not passing any params to FormatMessage, we don't
  44    :    // want inserts expanded.
  45    :    const DWORD kFlags = FORMAT_MESSAGE_FROM_SYSTEM |
  46  E :                         FORMAT_MESSAGE_IGNORE_INSERTS;
  47  E :    char error_text[4096] = { '\0' };
  48    :    ::FormatMessageA(kFlags, 0, we.we_, 0, error_text, arraysize(error_text),
  49  E :                     NULL);
  50  E :    std::string error(error_text);
  51  E :    base::TrimWhitespaceASCII(error, base::TRIM_ALL, &error);
  52    :  
  53  E :    return os << "[we=" << we.we_ << ", msg=" << error << "]";
  54  E :  }
  55    :  
  56    :  }  // namespace common

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