| 2865 | |
| 2866 | template <typename CType> |
| 2867 | void CheckModes(const Datum& array, const ModeOptions options, |
| 2868 | const std::vector<CType>& expected_modes, |
| 2869 | const std::vector<int64_t>& expected_counts) { |
| 2870 | ARROW_SCOPED_TRACE("Mode Options: ", options.ToString()); |
| 2871 | ASSERT_OK_AND_ASSIGN(Datum out, Mode(array, options)); |
| 2872 | ValidateOutput(out); |
| 2873 | const StructArray out_array(out.array()); |
| 2874 | ASSERT_EQ(out_array.length(), expected_modes.size()); |
| 2875 | ASSERT_EQ(out_array.num_fields(), 2); |
| 2876 | |
| 2877 | const CType* out_modes = out_array.field(0)->data()->GetValues<CType>(1); |
| 2878 | const int64_t* out_counts = out_array.field(1)->data()->GetValues<int64_t>(1); |
| 2879 | for (int i = 0; i < out_array.length(); ++i) { |
| 2880 | // equal or nan equal |
| 2881 | ASSERT_TRUE((expected_modes[i] == out_modes[i]) || |
| 2882 | (expected_modes[i] != expected_modes[i] && out_modes[i] != out_modes[i])) |
| 2883 | << " Actual Value: " << out_modes[i] << "\n" |
| 2884 | << "Expected Value: " << expected_modes[i]; |
| 2885 | ASSERT_EQ(expected_counts[i], out_counts[i]); |
| 2886 | } |
| 2887 | } |
| 2888 | |
| 2889 | template <> |
| 2890 | void CheckModes<bool>(const Datum& array, const ModeOptions options, |
no test coverage detected