src/base/containers/checked_iterators_unittest.cc
TEST(CheckedContiguousIterator, OptimizedCopy) {
  using Iter = DisableDerefAndIncr<CheckedContiguousIterator<int>>;

  int arr_in[5] = {1, 2, 3, 4, 5};
  int arr_out[5];

  Iter in_begin(std::begin(arr_in), std::end(arr_in));
  Iter in_end(std::begin(arr_in), std::end(arr_in), std::end(arr_in));
  Iter out_begin(std::begin(arr_out), std::end(arr_out));
  Iter out_end = std::copy(in_begin, in_end, out_begin);
  EXPECT_EQ(out_end, out_begin + (in_end - in_begin));

  EXPECT_TRUE(std::equal(std::begin(arr_in), std::end(arr_in),
                         std::begin(arr_out), std::end(arr_out)));
}
// Tests that using std::copy with CheckedContiguousIterator<int> results in an
// optimized code-path that does not invoke the iterator's dereference and
// increment operations. This would fail at runtime if std::copy was not
// optimized.
Tests that using std::copy with CheckedContiguousIterator results in an
optimized code-path that does not invoke the iterator's dereference and
increment operations. This would fail at runtime if std::copy was not
optimized.
Tests that using std :: copy with CheckedContiguousIterator results in an optimized code - path that does not invoke the iterator ' s dereference and increment operations . This would fail at runtime if std :: copy was not optimized .
TEST(CheckedContiguousIterator, OptimizedCopy) {
  using Iter = DisableDerefAndIncr<CheckedContiguousIterator<int>>;
  int arr_in[5] = {1, 2, 3, 4, 5};
  int arr_out[5];
  Iter in_begin(std::begin(arr_in), std::end(arr_in));
  Iter in_end(std::begin(arr_in), std::end(arr_in), std::end(arr_in));
  Iter out_begin(std::begin(arr_out), std::end(arr_out));
  Iter out_end = std::copy(in_begin, in_end, out_begin);
  EXPECT_EQ(out_end, out_begin + (in_end - in_begin));
  EXPECT_TRUE(std::equal(std::begin(arr_in), std::end(arr_in),
                         std::begin(arr_out), std::end(arr_out)));
}
TEST ( CheckedContiguousIterator , OptimizedCopy ) { using Iter = DisableDerefAndIncr < CheckedContiguousIterator < int > > ; int arr_in [ 5 ] = { 1 , 2 , 3 , 4 , 5 } ; int arr_out [ 5 ] ; Iter in_begin ( std :: begin ( arr_in ) , std :: end ( arr_in ) ) ; Iter in_end ( std :: begin ( arr_in ) , std :: end ( arr_in ) , std :: end ( arr_in ) ) ; Iter out_begin ( std :: begin ( arr_out ) , std :: end ( arr_out ) ) ; Iter out_end = std :: copy ( in_begin , in_end , out_begin ) ; EXPECT_EQ ( out_end , out_begin + ( in_end - in_begin ) ) ; EXPECT_TRUE ( std :: equal ( std :: begin ( arr_in ) , std :: end ( arr_in ) , std :: begin ( arr_out ) , std :: end ( arr_out ) ) ) ; }
Tests that using std::copy with CheckedContiguousIterator<int> results in an
optimized code-path that does not invoke the iterator's dereference and
increment operations.
Tests that using std :: copy with CheckedContiguousIterator<int > results in an optimized code - path that does not invoke the iterator ' s dereference and increment operations .