Skip to content

Commit

Permalink
feat(cpp): Remove scalar regacy as a draft
Browse files Browse the repository at this point in the history
  • Loading branch information
llama90 committed Dec 2, 2023
1 parent 47dadb0 commit 373bf10
Showing 1 changed file with 13 additions and 10 deletions.
23 changes: 13 additions & 10 deletions cpp/src/arrow/scalar_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
#include "arrow/array.h"
#include "arrow/array/util.h"
#include "arrow/buffer.h"
#include "arrow/compute/cast.h"
#include "arrow/memory_pool.h"
#include "arrow/scalar.h"
#include "arrow/status.h"
Expand All @@ -40,6 +41,8 @@

namespace arrow {

using compute::Cast;

using internal::checked_cast;
using internal::checked_pointer_cast;

Expand Down Expand Up @@ -1039,22 +1042,22 @@ TYPED_TEST(TestNumericScalar, Cast) {
std::shared_ptr<Scalar> other_scalar;
ASSERT_OK_AND_ASSIGN(other_scalar, Scalar::Parse(other_type, repr));

ASSERT_OK_AND_ASSIGN(auto cast_to_other, scalar->CastTo(other_type))
ASSERT_EQ(*cast_to_other, *other_scalar);
ASSERT_OK_AND_ASSIGN(auto cast_to_other, Cast(scalar, other_type))
ASSERT_EQ(*cast_to_other.scalar(), *other_scalar);

ASSERT_OK_AND_ASSIGN(auto cast_from_other, other_scalar->CastTo(type))
ASSERT_EQ(*cast_from_other, *scalar);
ASSERT_OK_AND_ASSIGN(auto cast_from_other, Cast(other_scalar, type))
ASSERT_EQ(*cast_from_other.scalar(), *scalar);
}

ASSERT_OK_AND_ASSIGN(auto cast_from_string,
StringScalar(std::string(repr)).CastTo(type));
ASSERT_EQ(*cast_from_string, *scalar);
Cast(StringScalar(std::string(repr)), type));
ASSERT_EQ(*cast_from_string.scalar(), *scalar);

if (is_integer_type<TypeParam>::value) {
ASSERT_OK_AND_ASSIGN(auto cast_to_string, scalar->CastTo(utf8()));
ASSERT_EQ(
std::string_view(*checked_cast<const StringScalar&>(*cast_to_string).value),
repr);
ASSERT_OK_AND_ASSIGN(auto cast_to_string, Cast(scalar, utf8()));
ASSERT_EQ(std::string_view(
*checked_cast<const StringScalar&>(*cast_to_string.scalar()).value),
repr);
}
}
}
Expand Down

0 comments on commit 373bf10

Please sign in to comment.