MCPcopy Create free account
hub / github.com/abess-team/abess / test_boolean

Function test_boolean

python/include/unsupported/test/cxx11_tensor_expr.cpp:194–223  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

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

Callers 1

test_cxx11_tensor_exprFunction · 0.85

Calls 2

constantMethod · 0.80
dataMethod · 0.45

Tested by

no test coverage detected