Coverage for /Syzygy/bard/unittest_util.h

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

Line-by-line coverage:

   1    :  // Copyright 2015 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    :  #ifndef SYZYGY_BARD_UNITTEST_UTIL_H_
  16    :  #define SYZYGY_BARD_UNITTEST_UTIL_H_
  17    :  
  18    :  #include "base/memory/scoped_ptr.h"
  19    :  #include "gtest/gtest.h"
  20    :  #include "syzygy/bard/event.h"
  21    :  #include "syzygy/bard/trace_live_map.h"
  22    :  
  23    :  namespace testing {
  24    :  
  25    :  using bard::TraceLiveMap;
  26    :  
  27    :  template <typename T>
  28    :  void CheckTraceLiveMapContains(const TraceLiveMap<T>& const_trace_live_map,
  29    :                                 T trace,
  30  E :                                 T live) {
  31    :    TraceLiveMap<T>& trace_live_map =
  32  E :        const_cast<TraceLiveMap<T>&>(const_trace_live_map);
  33    :  
  34    :    T answer;
  35  E :    EXPECT_TRUE(trace_live_map.GetLiveFromTrace(trace, &answer));
  36  E :    EXPECT_EQ(live, answer);
  37  E :    EXPECT_TRUE(trace_live_map.GetTraceFromLive(live, &answer));
  38  E :    EXPECT_EQ(trace, answer);
  39  E :  }
  40    :  
  41    :  template <typename T>
  42    :  void CheckTraceLiveMapNotContain(const TraceLiveMap<T>& const_trace_live_map,
  43    :                                   T trace,
  44  E :                                   T live) {
  45    :    TraceLiveMap<T>& trace_live_map =
  46  E :        const_cast<TraceLiveMap<T>&>(const_trace_live_map);
  47    :  
  48    :    T answer;
  49  E :    EXPECT_FALSE(trace_live_map.GetLiveFromTrace(trace, &answer));
  50  E :    EXPECT_FALSE(trace_live_map.GetTraceFromLive(live, &answer));
  51  E :  }
  52    :  
  53    :  template <typename Event>
  54  E :  void TestEventSerialization(const Event& original_data) {
  55  E :    core::ByteVector bytes;
  56    :  
  57  E :    core::ScopedOutStreamPtr out_stream;
  58  E :    out_stream.reset(core::CreateByteOutStream(std::back_inserter(bytes)));
  59  E :    core::NativeBinaryOutArchive out_archive(out_stream.get());
  60  E :    EXPECT_TRUE(Event::Save(&original_data, &out_archive));
  61  E :    EXPECT_TRUE(out_archive.Flush());
  62    :  
  63  E :    core::ScopedInStreamPtr in_stream;
  64  E :    in_stream.reset(core::CreateByteInStream(bytes.begin(), bytes.end()));
  65  E :    core::NativeBinaryInArchive in_archive(in_stream.get());
  66  E :    scoped_ptr<Event> data_copy = Event::Load(&in_archive).Pass();
  67  E :    EXPECT_NE(static_cast<Event*>(nullptr), data_copy.get());
  68    :  
  69    :    // Expect equality.
  70  E :    EXPECT_TRUE(original_data.Equals(data_copy.get()));
  71  E :  }
  72    :  
  73    :  }  // namespace testing
  74    :  
  75    :  #endif  // SYZYGY_BARD_UNITTEST_UTIL_H_

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