def test_cython_decimal_coder(self): import decimal data = [decimal.Decimal('0.00001'), decimal.Decimal('1.23E-8')] python_field_coders = [ coder_impl.DecimalCoderImpl(38, 18) for _ in range(len(data)) ] cython_field_coders = [ fast_coder_impl.DecimalCoderImpl(38, 18) for _ in range(len(data)) ] self.check_cython_coder(python_field_coders, cython_field_coders, [data]) decimal.getcontext().prec = 2 data = [decimal.Decimal('1.001')] python_field_coders = [ coder_impl.DecimalCoderImpl(4, 3) for _ in range(len(data)) ] cython_field_coders = [ fast_coder_impl.DecimalCoderImpl(4, 3) for _ in range(len(data)) ] self.check_cython_coder(python_field_coders, cython_field_coders, [data]) self.assertEqual(decimal.getcontext().prec, 2)
def _create_impl(self): return coder_impl.DecimalCoderImpl(self.precision, self.scale)