| 144 | } |
| 145 | |
| 146 | static bool TestPointerIterators() { |
| 147 | // Ensure that TF_FOR_ALL works with iterators that are raw pointers. |
| 148 | |
| 149 | static const int data[] = { 3, 2, 1 }; |
| 150 | TfSpan<const int> span(data, TfArraySize(data)); |
| 151 | |
| 152 | int sum = 0; |
| 153 | int count = 0; |
| 154 | TF_FOR_ALL(it, span) { |
| 155 | sum += *it; |
| 156 | ++count; |
| 157 | } |
| 158 | TF_AXIOM(sum == 6); |
| 159 | TF_AXIOM(count == 3); |
| 160 | |
| 161 | TfSpan<std::string> empty(nullptr, nullptr); |
| 162 | |
| 163 | sum = 0; |
| 164 | count = 0; |
| 165 | TF_FOR_ALL(it, empty) { |
| 166 | sum += it->size(); |
| 167 | ++count; |
| 168 | } |
| 169 | TF_AXIOM(sum == 0); |
| 170 | TF_AXIOM(count == 0); |
| 171 | |
| 172 | return true; |
| 173 | } |
| 174 | |
| 175 | static bool |
| 176 | Test_TfIterator() |
no test coverage detected