tensorflow/core/lib/gtl/int_type_test.cc
// Tests the use of the templatized value accessor that performs static_casts.
// We use -1 to force casting in unsigned integers.
Tests the use of the templatized value accessor that performs static_casts.
We use -1 to force casting in unsigned integers.
Tests the use of the templatized value accessor that performs static_casts . We use - 1 to force casting in unsigned integers .
TYPED_TEST(IntTypeTest, TestValueAccessor) {
  constexpr typename TypeParam::ValueType i = -1;
  constexpr TypeParam int_type(i);
  EXPECT_EQ(i, int_type.value());
  static_assert(int_type.value() == i, "value() failed");
  EXPECT_EQ(static_cast<int>(i), int_type.template value<int>());
  EXPECT_EQ(static_cast<int8>(i), int_type.template value<int8>());
  EXPECT_EQ(static_cast<int16>(i), int_type.template value<int16>());
  EXPECT_EQ(static_cast<int32>(i), int_type.template value<int32>());
  EXPECT_EQ(static_cast<uint32>(i), int_type.template value<uint32>());
  EXPECT_EQ(static_cast<int64_t>(i), int_type.template value<int64_t>());
  EXPECT_EQ(static_cast<uint64>(i), int_type.template value<uint64>());
  EXPECT_EQ(static_cast<long>(i), int_type.template value<long>());  
  static_assert(int_type.template value<int>() == static_cast<int>(i),
                "value<Value>() failed");
}
TYPED_TEST ( IntTypeTest , TestValueAccessor ) { constexpr typename TypeParam :: ValueType i = -1 ; constexpr TypeParam int_type ( i ) ; EXPECT_EQ ( i , int_type . value ( ) ) ; static_assert ( int_type . value ( ) == i , " " ) ; EXPECT_EQ ( static_cast < int > ( i ) , int_type . template value < int > ( ) ) ; EXPECT_EQ ( static_cast < int8 > ( i ) , int_type . template value < int8 > ( ) ) ; EXPECT_EQ ( static_cast < int16 > ( i ) , int_type . template value < int16 > ( ) ) ; EXPECT_EQ ( static_cast < int32 > ( i ) , int_type . template value < int32 > ( ) ) ; EXPECT_EQ ( static_cast < uint32 > ( i ) , int_type . template value < uint32 > ( ) ) ; EXPECT_EQ ( static_cast < int64_t > ( i ) , int_type . template value < int64_t > ( ) ) ; EXPECT_EQ ( static_cast < uint64 > ( i ) , int_type . template value < uint64 > ( ) ) ; EXPECT_EQ ( static_cast < long > ( i ) , int_type . template value < long > ( ) ) ; static_assert ( int_type . template value < int > ( ) == static_cast < int > ( i ) , " " ) ; }
Tests the use of the templatized value accessor that performs static_casts.
Tests the use of the templatized value accessor that performs static_casts .
// The use of the keyword 'template' (suggested by Clang) is only necessary // as this code is part of a template class.  Weird syntax though.  Good news // is that only int_type.value<int>() is needed in most code. // NOLINT