| 194 | } |
| 195 | |
| 196 | static void test_boolean() |
| 197 | { |
| 198 | const int kSize = 31; |
| 199 | Tensor<int, 1> vec(kSize); |
| 200 | std::iota(vec.data(), vec.data() + kSize, 0); |
| 201 | |
| 202 | // Test ||. |
| 203 | Tensor<bool, 1> bool1 = vec < vec.constant(1) || vec > vec.constant(4); |
| 204 | for (int i = 0; i < kSize; ++i) { |
| 205 | bool expected = i < 1 || i > 4; |
| 206 | VERIFY_IS_EQUAL(bool1[i], expected); |
| 207 | } |
| 208 | |
| 209 | // Test &&, including cast of operand vec. |
| 210 | Tensor<bool, 1> bool2 = vec.cast<bool>() && vec < vec.constant(4); |
| 211 | for (int i = 0; i < kSize; ++i) { |
| 212 | bool expected = bool(i) && i < 4; |
| 213 | VERIFY_IS_EQUAL(bool2[i], expected); |
| 214 | } |
| 215 | |
| 216 | // Compilation tests: |
| 217 | // Test Tensor<bool> against results of cast or comparison; verifies that |
| 218 | // CoeffReturnType is set to match Op return type of bool for Unary and Binary |
| 219 | // Ops. |
| 220 | Tensor<bool, 1> bool3 = vec.cast<bool>() && bool2; |
| 221 | bool3 = vec < vec.constant(4) && bool2; |
| 222 | } |
| 223 | |
| 224 | static void test_functors() |
| 225 | { |
no test coverage detected