| 745 | } |
| 746 | |
| 747 | Status TestMixedPrecisionAndScale() { |
| 748 | std::vector<std::string> strings{{"0.001", "1.01E5", "1.01E5"}}; |
| 749 | |
| 750 | OwnedRef list_ref(PyList_New(static_cast<Py_ssize_t>(strings.size()))); |
| 751 | PyObject* list = list_ref.obj(); |
| 752 | |
| 753 | ASSERT_NE(list, nullptr); |
| 754 | |
| 755 | OwnedRef decimal_constructor_; |
| 756 | OwnedRef decimal_module; |
| 757 | RETURN_NOT_OK(internal::ImportModule("decimal", &decimal_module)); |
| 758 | RETURN_NOT_OK( |
| 759 | internal::ImportFromModule(decimal_module.obj(), "Decimal", &decimal_constructor_)); |
| 760 | // PyList_SetItem steals a reference to the item so we don't decref it later |
| 761 | PyObject* decimal_constructor = decimal_constructor_.obj(); |
| 762 | for (Py_ssize_t i = 0; i < static_cast<Py_ssize_t>(strings.size()); ++i) { |
| 763 | const int result = PyList_SetItem( |
| 764 | list, i, internal::DecimalFromString(decimal_constructor, strings.at(i))); |
| 765 | ASSERT_EQ(0, result); |
| 766 | } |
| 767 | |
| 768 | auto arr = std::move(ConvertPySequence(list, nullptr, {})).ValueOrDie(); |
| 769 | const auto& type = checked_cast<const DecimalType&>(*arr->type()); |
| 770 | |
| 771 | int32_t expected_precision = 9; |
| 772 | int32_t expected_scale = 3; |
| 773 | ASSERT_EQ(expected_precision, type.precision()); |
| 774 | ASSERT_EQ(expected_scale, type.scale()); |
| 775 | |
| 776 | return Status::OK(); |
| 777 | } |
| 778 | |
| 779 | Status TestMixedPrecisionAndScaleSequenceConvert() { |
| 780 | OwnedRef decimal_constructor_; |
nothing calls this directly
no test coverage detected