File indexing completed on 2025-08-28 08:27:10
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018 #pragma once
0019
0020 #include <iosfwd>
0021
0022 #include "arrow/testing/gtest_util.h"
0023 #include "arrow/util/iterator.h"
0024
0025 namespace arrow {
0026
0027 struct TestInt {
0028 TestInt();
0029 TestInt(int i);
0030 int value;
0031
0032 bool operator==(const TestInt& other) const;
0033
0034 friend std::ostream& operator<<(std::ostream& os, const TestInt& v);
0035 };
0036
0037 template <>
0038 struct IterationTraits<TestInt> {
0039 static TestInt End() { return TestInt(); }
0040 static bool IsEnd(const TestInt& val) { return val == IterationTraits<TestInt>::End(); }
0041 };
0042
0043 struct TestStr {
0044 TestStr();
0045 TestStr(const std::string& s);
0046 TestStr(const char* s);
0047 explicit TestStr(const TestInt& test_int);
0048 std::string value;
0049
0050 bool operator==(const TestStr& other) const;
0051
0052 friend std::ostream& operator<<(std::ostream& os, const TestStr& v);
0053 };
0054
0055 template <>
0056 struct IterationTraits<TestStr> {
0057 static TestStr End() { return TestStr(); }
0058 static bool IsEnd(const TestStr& val) { return val == IterationTraits<TestStr>::End(); }
0059 };
0060
0061 std::vector<TestInt> RangeVector(unsigned int max, unsigned int step = 1);
0062
0063 template <typename T>
0064 inline Iterator<T> VectorIt(std::vector<T> v) {
0065 return MakeVectorIterator<T>(std::move(v));
0066 }
0067
0068 template <typename T>
0069 inline Iterator<T> PossiblySlowVectorIt(std::vector<T> v, bool slow = false) {
0070 auto iterator = MakeVectorIterator<T>(std::move(v));
0071 if (slow) {
0072 return MakeTransformedIterator<T, T>(std::move(iterator),
0073 [](T item) -> Result<TransformFlow<T>> {
0074 SleepABit();
0075 return TransformYield(item);
0076 });
0077 } else {
0078 return iterator;
0079 }
0080 }
0081
0082 template <typename T>
0083 inline void AssertIteratorExhausted(Iterator<T>& it) {
0084 ASSERT_OK_AND_ASSIGN(T next, it.Next());
0085 ASSERT_TRUE(IsIterationEnd(next));
0086 }
0087
0088 Transformer<TestInt, TestStr> MakeFilter(std::function<bool(TestInt&)> filter);
0089
0090 }