Coverage for /Syzygy/bard/raw_argument_converter_unittest.cc

CoverageLines executed / instrumented / missingexe / inst / missLanguageGroup
100.0%31310.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    :  #include "syzygy/bard/raw_argument_converter.h"
  16    :  
  17    :  #include "gtest/gtest.h"
  18    :  
  19    :  namespace bard {
  20    :  
  21    :  class RawArgumentConverterTest : public testing::Test {
  22    :   public:
  23  E :    RawArgumentConverterTest() : ui8_(0u), ui16_(0u), ui32_(0u) {}
  24    :  
  25    :    uint8_t ui8_;
  26    :    uint16_t ui16_;
  27    :    uint32_t ui32_;
  28    :  };
  29    :  
  30  E :  TEST_F(RawArgumentConverterTest, TestOneByte) {
  31  E :    uint8_t value = 234;
  32  E :    uint32_t size = sizeof(value);
  33  E :    uint8_t* ptr = &value;
  34    :  
  35  E :    RawArgumentConverter arg(ptr, size);
  36    :  
  37  E :    EXPECT_TRUE(arg.RetrieveAs(&ui8_));
  38  E :    EXPECT_EQ(value, ui8_);
  39  E :    EXPECT_FALSE(arg.RetrieveAs(&ui16_));
  40  E :    EXPECT_FALSE(arg.RetrieveAs(&ui32_));
  41  E :  }
  42    :  
  43  E :  TEST_F(RawArgumentConverterTest, TestTwoBytes) {
  44  E :    uint16_t value = 60123;
  45  E :    uint32_t size = sizeof(value);
  46  E :    uint8_t* ptr = reinterpret_cast<uint8_t*>(&value);
  47    :  
  48  E :    RawArgumentConverter arg(ptr, size);
  49    :  
  50  E :    EXPECT_FALSE(arg.RetrieveAs(&ui8_));
  51  E :    EXPECT_TRUE(arg.RetrieveAs(&ui16_));
  52  E :    EXPECT_EQ(value, ui16_);
  53  E :    EXPECT_FALSE(arg.RetrieveAs(&ui32_));
  54  E :  }
  55    :  
  56  E :  TEST_F(RawArgumentConverterTest, TestFourBytes) {
  57  E :    uint32_t value = 4294912345;
  58  E :    uint32_t size = sizeof(value);
  59  E :    uint8_t* ptr = reinterpret_cast<uint8_t*>(&value);
  60    :  
  61  E :    RawArgumentConverter arg(ptr, size);
  62    :  
  63  E :    EXPECT_FALSE(arg.RetrieveAs(&ui8_));
  64  E :    EXPECT_FALSE(arg.RetrieveAs(&ui16_));
  65  E :    EXPECT_TRUE(arg.RetrieveAs(&ui32_));
  66  E :    EXPECT_EQ(value, ui32_);
  67  E :  }
  68    :  
  69    :  }  // namespace bard

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