Skip to content

Commit

Permalink
Tests fix
Browse files Browse the repository at this point in the history
Signed-off-by: Dmitry Chigarev <[email protected]>
  • Loading branch information
dchigarev committed Jan 15, 2021
1 parent fc4fd9c commit 9e45b7d
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 12 deletions.
10 changes: 5 additions & 5 deletions cpp/src/arrow/util/basic_decimal.h
Original file line number Diff line number Diff line change
Expand Up @@ -341,10 +341,10 @@ template<uint32_t width>
class ARROW_EXPORT BasicDecimalAnyWidth {
public:
using ValueType = typename IntTypes<width>::signed_type;
/// \brief Empty constructor creates a BasicDecimal256 with a value of 0.
/// \brief Empty constructor creates a BasicDecimal with a value of 0.
constexpr BasicDecimalAnyWidth() noexcept : value(0) {}

/// \brief Convert any integer value into a BasicDecimal256.
/// \brief Convert any integer value into a BasicDecimal.
template <typename T,
typename = typename std::enable_if<
std::is_integral<T>::value &&
Expand All @@ -359,7 +359,7 @@ class ARROW_EXPORT BasicDecimalAnyWidth {
constexpr BasicDecimalAnyWidth(const BasicDecimalAnyWidth<_width>& other) noexcept
: value(static_cast<ValueType>(other.Value())) {}

/// \brief Create a BasicDecimal256 from an array of bytes. Bytes are assumed to be in
/// \brief Create a BasicDecimal from an array of bytes. Bytes are assumed to be in
/// native-endian byte order.
explicit BasicDecimalAnyWidth(const uint8_t* bytes);

Expand All @@ -375,14 +375,14 @@ class ARROW_EXPORT BasicDecimalAnyWidth {
DecimalStatus Divide(const BasicDecimalAnyWidth& divisor, BasicDecimalAnyWidth* result,
BasicDecimalAnyWidth* remainder) const;

// \brief Scale multiplier for given scale value.
/// \brief Scale multiplier for given scale value.
static BasicDecimalAnyWidth GetScaleMultiplier(int32_t scale);

/// \brief Return the raw bytes of the value in native-endian byte order.
std::array<uint8_t, (width >> 3)> ToBytes() const;
void ToBytes(uint8_t* out) const;

/// \brief Convert BasicDecimal128 from one scale to another
/// \brief Convert BasicDecimal from one scale to another
DecimalStatus Rescale(int32_t original_scale, int32_t new_scale,
BasicDecimalAnyWidth* out) const;

Expand Down
12 changes: 5 additions & 7 deletions cpp/src/arrow/util/decimal_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1735,21 +1735,19 @@ TYPED_TEST(DecimalAnyWidthTest, BinaryOperations) {
using ArrowValueType = typename arrow::CTypeTraits<ValueType>::ArrowType;

auto DecimalFns = DecimalAnyWidthBinaryParams<TypeParam>::value;
auto NumericFns = DecimalAnyWidthBinaryParams<ValueType>::value;
auto NumericFns = DecimalAnyWidthBinaryParams<int64_t>::value;

for (size_t i = 0; i < DecimalFns.size(); i++){
for (auto x : GetRandomNumbers<ArrowValueType>(8)) {
for (auto y : GetRandomNumbers<ArrowValueType>(8)) {
TypeParam d1(x), d2(y);
ASSERT_EQ(NumericFns[i].second(x, y), DecimalFns[i].second(d1, d2))
<< d1 << DecimalFns[i].first << " " << d2 << " " << " != " << NumericFns[i].second(x, y);
auto result = DecimalFns[i].second(d1, d2);
auto reference = static_cast<ValueType>(NumericFns[i].second(x, y));
ASSERT_EQ(reference, result)
<< d1 << " " << DecimalFns[i].first << " " << d2 << " " << " != " << result;
}
}
}
}





} // namespace arrow

0 comments on commit 9e45b7d

Please sign in to comment.