kou commented on a change in pull request #8612:
URL: https://github.com/apache/arrow/pull/8612#discussion_r526619025



##########
File path: cpp/src/arrow/compute/kernels/vector_sort_test.cc
##########
@@ -228,134 +233,165 @@ TYPED_TEST(TestNthToIndicesRandom, RandomValues) {
 using arrow::internal::checked_pointer_cast;
 
 template <typename ArrowType>
-class TestSortToIndicesKernel : public TestBase {
+class TestArraySortIndicesKernel : public TestBase {
  private:
-  void AssertSortToIndicesArrays(const std::shared_ptr<Array> values,
-                                 const std::shared_ptr<Array> expected) {
-    ASSERT_OK_AND_ASSIGN(std::shared_ptr<Array> actual, 
SortToIndices(*values));
+  void AssertArraysSortIndices(const std::shared_ptr<Array> values, SortOrder 
order,
+                               const std::shared_ptr<Array> expected) {
+    ASSERT_OK_AND_ASSIGN(std::shared_ptr<Array> actual, SortIndices(*values, 
order));
     ASSERT_OK(actual->ValidateFull());
     AssertArraysEqual(*expected, *actual);
   }
 
  protected:
-  virtual void AssertSortToIndices(const std::string& values,
-                                   const std::string& expected) {
+  virtual void AssertSortIndices(const std::string& values, SortOrder order,
+                                 const std::string& expected) {
     auto type = TypeTraits<ArrowType>::type_singleton();
-    AssertSortToIndicesArrays(ArrayFromJSON(type, values),
-                              ArrayFromJSON(uint64(), expected));
+    AssertArraysSortIndices(ArrayFromJSON(type, values), order,
+                            ArrayFromJSON(uint64(), expected));
+  }
+
+  virtual void AssertSortIndices(const std::string& values, const std::string& 
expected) {
+    AssertSortIndices(values, SortOrder::ASCENDING, expected);
   }
 };
 
 template <typename ArrowType>
-class TestSortToIndicesKernelForReal : public 
TestSortToIndicesKernel<ArrowType> {};
-TYPED_TEST_SUITE(TestSortToIndicesKernelForReal, RealArrowTypes);
+class TestArraySortIndicesKernelForReal : public 
TestArraySortIndicesKernel<ArrowType> {};
+TYPED_TEST_SUITE(TestArraySortIndicesKernelForReal, RealArrowTypes);
 
 template <typename ArrowType>
-class TestSortToIndicesKernelForIntegral : public 
TestSortToIndicesKernel<ArrowType> {};
-TYPED_TEST_SUITE(TestSortToIndicesKernelForIntegral, IntegralArrowTypes);
+class TestArraySortIndicesKernelForIntegral
+    : public TestArraySortIndicesKernel<ArrowType> {};
+TYPED_TEST_SUITE(TestArraySortIndicesKernelForIntegral, IntegralArrowTypes);
 
 template <typename ArrowType>
-class TestSortToIndicesKernelForStrings : public 
TestSortToIndicesKernel<ArrowType> {};
-TYPED_TEST_SUITE(TestSortToIndicesKernelForStrings, 
testing::Types<StringType>);
+class TestArraySortIndicesKernelForStrings
+    : public TestArraySortIndicesKernel<ArrowType> {};
+TYPED_TEST_SUITE(TestArraySortIndicesKernelForStrings, 
testing::Types<StringType>);
+
+TYPED_TEST(TestArraySortIndicesKernelForReal, SortReal) {
+  this->AssertSortIndices("[]", "[]");
+
+  this->AssertSortIndices("[3.4, 2.6, 6.3]", "[1, 0, 2]");
+  this->AssertSortIndices("[1.1, 2.4, 3.5, 4.3, 5.1, 6.8, 7.3]", 
"[0,1,2,3,4,5,6]");

Review comment:
       Added a space after `,` including existing JSON values.




----------------------------------------------------------------
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]


Reply via email to