pitrou commented on a change in pull request #10530:
URL: https://github.com/apache/arrow/pull/10530#discussion_r651642966
##########
File path: cpp/src/arrow/compute/kernels/scalar_arithmetic_test.cc
##########
@@ -299,6 +299,67 @@ class TestBinaryArithmeticUnsigned : public
TestBinaryArithmeticIntegral<T> {};
template <typename T>
class TestBinaryArithmeticFloating : public TestBinaryArithmetic<T> {};
+template <typename T>
+class TestBitWiseArithmetic : public TestBase {
+ protected:
+ using ArrowType = T;
+ using CType = typename ArrowType::c_type;
+
+ static std::shared_ptr<DataType> type_singleton() {
+ return TypeTraits<ArrowType>::type_singleton();
+ }
+
+ void AssertUnaryOp(const std::string& func, const std::vector<uint8_t>& args,
+ const std::vector<uint8_t>& expected) {
+ auto input = ExpandByteArray(args);
+ auto output = ExpandByteArray(expected);
+ ASSERT_OK_AND_ASSIGN(Datum actual, CallFunction(func, {input}));
+ ValidateAndAssertEqual(actual.make_array(), output);
+ for (int64_t i = 0; i < output->length(); i++) {
+ ASSERT_OK_AND_ASSIGN(Datum actual, CallFunction(func,
{*input->GetScalar(i)}));
+ const auto expected_scalar = *output->GetScalar(i);
+ AssertScalarsEqual(*expected_scalar, *actual.scalar(), /*verbose=*/true);
+ }
+ }
+
+ void AssertBinaryOp(const std::string& func, const std::vector<uint8_t>&
arg0,
+ const std::vector<uint8_t>& arg1,
+ const std::vector<uint8_t>& expected) {
+ auto input0 = ExpandByteArray(arg0);
+ auto input1 = ExpandByteArray(arg1);
+ auto output = ExpandByteArray(expected);
+ ASSERT_OK_AND_ASSIGN(Datum actual, CallFunction(func, {input0, input1}));
+ ValidateAndAssertEqual(actual.make_array(), output);
+ for (int64_t i = 0; i < output->length(); i++) {
+ ASSERT_OK_AND_ASSIGN(Datum actual, CallFunction(func,
{*input0->GetScalar(i),
+
*input1->GetScalar(i)}));
+ const auto expected_scalar = *output->GetScalar(i);
+ AssertScalarsEqual(*expected_scalar, *actual.scalar(), /*verbose=*/true);
+ }
+ }
+
+ // To make it easier to test different widths, tests give bytes which get
repeated to
+ // make an array of the actual type
+ std::shared_ptr<Array> ExpandByteArray(const std::vector<uint8_t>& values) {
+ constexpr size_t count = TypeTraits<ArrowType>::bytes_required(1);
Review comment:
This is just `sizeof(CType)`?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]