tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

iterator_traits_test.cc (3942B)


      1 // Copyright 2025 The Abseil Authors
      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 //     https://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 "absl/base/internal/iterator_traits.h"
     16 
     17 #include <forward_list>
     18 #include <iterator>
     19 #include <list>
     20 #include <vector>
     21 
     22 #include "gtest/gtest.h"
     23 #include "absl/base/config.h"
     24 #include "absl/base/internal/iterator_traits_test_helper.h"
     25 
     26 namespace absl {
     27 ABSL_NAMESPACE_BEGIN
     28 namespace base_internal {
     29 namespace {
     30 
     31 TEST(IsAtLeastIteratorTest, IsAtLeastIterator) {
     32  EXPECT_TRUE((IsAtLeastIterator<std::input_iterator_tag, int*>()));
     33  EXPECT_TRUE((IsAtLeastIterator<std::forward_iterator_tag, int*>()));
     34  EXPECT_TRUE((IsAtLeastIterator<std::bidirectional_iterator_tag, int*>()));
     35  EXPECT_TRUE((IsAtLeastIterator<std::random_access_iterator_tag, int*>()));
     36  EXPECT_TRUE((IsAtLeastIterator<std::input_iterator_tag,
     37                                 std::vector<int>::iterator>()));
     38  EXPECT_TRUE((IsAtLeastIterator<std::forward_iterator_tag,
     39                                 std::vector<int>::iterator>()));
     40  EXPECT_TRUE((IsAtLeastIterator<std::bidirectional_iterator_tag,
     41                                 std::vector<int>::iterator>()));
     42  EXPECT_TRUE((IsAtLeastIterator<std::random_access_iterator_tag,
     43                                 std::vector<int>::iterator>()));
     44 
     45  EXPECT_TRUE(
     46      (IsAtLeastIterator<std::input_iterator_tag, std::list<int>::iterator>()));
     47  EXPECT_TRUE((IsAtLeastIterator<std::forward_iterator_tag,
     48                                 std::list<int>::iterator>()));
     49  EXPECT_TRUE((IsAtLeastIterator<std::bidirectional_iterator_tag,
     50                                 std::list<int>::iterator>()));
     51  EXPECT_FALSE((IsAtLeastIterator<std::random_access_iterator_tag,
     52                                  std::list<int>::iterator>()));
     53 
     54  EXPECT_TRUE((IsAtLeastIterator<std::input_iterator_tag,
     55                                 std::forward_list<int>::iterator>()));
     56  EXPECT_TRUE((IsAtLeastIterator<std::forward_iterator_tag,
     57                                 std::forward_list<int>::iterator>()));
     58  EXPECT_FALSE((IsAtLeastIterator<std::bidirectional_iterator_tag,
     59                                  std::forward_list<int>::iterator>()));
     60  EXPECT_FALSE((IsAtLeastIterator<std::random_access_iterator_tag,
     61                                  std::forward_list<int>::iterator>()));
     62 
     63  EXPECT_TRUE((IsAtLeastIterator<std::input_iterator_tag,
     64                                 std::istream_iterator<int>>()));
     65  EXPECT_FALSE((IsAtLeastIterator<std::forward_iterator_tag,
     66                                  std::istream_iterator<int>>()));
     67  EXPECT_FALSE((IsAtLeastIterator<std::bidirectional_iterator_tag,
     68                                  std::istream_iterator<int>>()));
     69  EXPECT_FALSE((IsAtLeastIterator<std::random_access_iterator_tag,
     70                                  std::istream_iterator<int>>()));
     71 
     72  EXPECT_TRUE((IsAtLeastIterator<std::input_iterator_tag,
     73                                 Cpp20ForwardZipIterator<int*>>()));
     74  EXPECT_TRUE((IsAtLeastIterator<std::forward_iterator_tag,
     75                                 Cpp20ForwardZipIterator<int*>>()));
     76  EXPECT_FALSE((IsAtLeastIterator<std::bidirectional_iterator_tag,
     77                                  Cpp20ForwardZipIterator<int*>>()));
     78  EXPECT_FALSE((IsAtLeastIterator<std::random_access_iterator_tag,
     79                                  Cpp20ForwardZipIterator<int*>>()));
     80 }
     81 
     82 }  // namespace
     83 }  // namespace base_internal
     84 ABSL_NAMESPACE_END
     85 }  // namespace absl