|
| 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 | + |
| 25 | +namespace absl { |
| 26 | +ABSL_NAMESPACE_BEGIN |
| 27 | +namespace base_internal { |
| 28 | +namespace { |
| 29 | + |
| 30 | +TEST(IsAtLeastIteratorTest, IsAtLeastIterator) { |
| 31 | + EXPECT_TRUE((IsAtLeastIterator<std::input_iterator_tag, int*>())); |
| 32 | + EXPECT_TRUE((IsAtLeastIterator<std::forward_iterator_tag, int*>())); |
| 33 | + EXPECT_TRUE((IsAtLeastIterator<std::bidirectional_iterator_tag, int*>())); |
| 34 | + EXPECT_TRUE((IsAtLeastIterator<std::random_access_iterator_tag, int*>())); |
| 35 | + EXPECT_TRUE((IsAtLeastIterator<std::input_iterator_tag, |
| 36 | + std::vector<int>::iterator>())); |
| 37 | + EXPECT_TRUE((IsAtLeastIterator<std::forward_iterator_tag, |
| 38 | + std::vector<int>::iterator>())); |
| 39 | + EXPECT_TRUE((IsAtLeastIterator<std::bidirectional_iterator_tag, |
| 40 | + std::vector<int>::iterator>())); |
| 41 | + EXPECT_TRUE((IsAtLeastIterator<std::random_access_iterator_tag, |
| 42 | + std::vector<int>::iterator>())); |
| 43 | + |
| 44 | + EXPECT_TRUE( |
| 45 | + (IsAtLeastIterator<std::input_iterator_tag, std::list<int>::iterator>())); |
| 46 | + EXPECT_TRUE((IsAtLeastIterator<std::forward_iterator_tag, |
| 47 | + std::list<int>::iterator>())); |
| 48 | + EXPECT_TRUE((IsAtLeastIterator<std::bidirectional_iterator_tag, |
| 49 | + std::list<int>::iterator>())); |
| 50 | + EXPECT_FALSE((IsAtLeastIterator<std::random_access_iterator_tag, |
| 51 | + std::list<int>::iterator>())); |
| 52 | + |
| 53 | + EXPECT_TRUE((IsAtLeastIterator<std::input_iterator_tag, |
| 54 | + std::forward_list<int>::iterator>())); |
| 55 | + EXPECT_TRUE((IsAtLeastIterator<std::forward_iterator_tag, |
| 56 | + std::forward_list<int>::iterator>())); |
| 57 | + EXPECT_FALSE((IsAtLeastIterator<std::bidirectional_iterator_tag, |
| 58 | + std::forward_list<int>::iterator>())); |
| 59 | + EXPECT_FALSE((IsAtLeastIterator<std::random_access_iterator_tag, |
| 60 | + std::forward_list<int>::iterator>())); |
| 61 | + |
| 62 | + EXPECT_TRUE((IsAtLeastIterator<std::input_iterator_tag, |
| 63 | + std::istream_iterator<int>>())); |
| 64 | + EXPECT_FALSE((IsAtLeastIterator<std::forward_iterator_tag, |
| 65 | + std::istream_iterator<int>>())); |
| 66 | + EXPECT_FALSE((IsAtLeastIterator<std::bidirectional_iterator_tag, |
| 67 | + std::istream_iterator<int>>())); |
| 68 | + EXPECT_FALSE((IsAtLeastIterator<std::random_access_iterator_tag, |
| 69 | + std::istream_iterator<int>>())); |
| 70 | +} |
| 71 | + |
| 72 | +} // namespace |
| 73 | +} // namespace base_internal |
| 74 | +ABSL_NAMESPACE_END |
| 75 | +} // namespace absl |
0 commit comments