| 378 | } |
| 379 | |
| 380 | Status TestInferPrecisionAndScale() { |
| 381 | OwnedRef decimal_constructor_; |
| 382 | OwnedRef decimal_module; |
| 383 | |
| 384 | RETURN_NOT_OK(internal::ImportModule("decimal", &decimal_module)); |
| 385 | RETURN_NOT_OK( |
| 386 | internal::ImportFromModule(decimal_module.obj(), "Decimal", &decimal_constructor_)); |
| 387 | |
| 388 | std::string decimal_string("-394029506937548693.42983"); |
| 389 | PyObject* python_decimal = |
| 390 | internal::DecimalFromString(decimal_constructor_.obj(), decimal_string); |
| 391 | |
| 392 | internal::DecimalMetadata metadata; |
| 393 | ASSERT_OK(metadata.Update(python_decimal)); |
| 394 | |
| 395 | const auto expected_precision = |
| 396 | static_cast<int32_t>(decimal_string.size() - 2); // 1 for -, 1 for . |
| 397 | const int32_t expected_scale = 5; |
| 398 | |
| 399 | ASSERT_EQ(expected_precision, metadata.precision()); |
| 400 | ASSERT_EQ(expected_scale, metadata.scale()); |
| 401 | |
| 402 | return Status::OK(); |
| 403 | } |
| 404 | |
| 405 | Status TestInferPrecisionAndNegativeScale() { |
| 406 | OwnedRef decimal_constructor_; |
nothing calls this directly
no test coverage detected