Пример #1
0
 def test_cast_from_decimal_to_decimal(self):
     self.assertEqual(
         cast_to_decimal(cast_to_decimal(1.526,
                                         FloatType(),
                                         DecimalType(scale=2),
                                         options=BASE_OPTIONS),
                         DecimalType(scale=2),
                         DecimalType(scale=3),
                         options=BASE_OPTIONS), 1.53)
Пример #2
0
 def test_cast_map_to_map(self):
     self.assertEqual(
         cast_to_map({
             1: "1",
             2: "2"
         },
                     MapType(ByteType(), StringType()),
                     MapType(StringType(), FloatType()),
                     options=BASE_OPTIONS), {
                         '1': 1.0,
                         '2': 2.0
                     })
Пример #3
0
 def test_cast_float_to_decimal_with_scale_and_other_rounding(self):
     self.assertEqual(
         cast_to_decimal(10.987654321,
                         FloatType(),
                         DecimalType(precision=10, scale=8),
                         options=BASE_OPTIONS), 10.98765432)
Пример #4
0
 def test_cast_float_to_decimal_with_scale(self):
     self.assertEqual(
         cast_to_decimal(10.123456789,
                         FloatType(),
                         DecimalType(precision=10, scale=8),
                         options=BASE_OPTIONS), 10.12345679)
Пример #5
0
 def test_cast_float_to_short_with_loop(self):
     self.assertEqual(
         cast_to_short(32768, FloatType(), options=BASE_OPTIONS), -32768)
Пример #6
0
 def test_cast_float_to_short(self):
     self.assertEqual(
         cast_to_short(32767, FloatType(), options=BASE_OPTIONS), 32767)
Пример #7
0
 def test_cast_float_to_byte_with_loop(self):
     self.assertEqual(
         cast_to_byte(-730.8, FloatType(), options=BASE_OPTIONS), 38)
Пример #8
0
 def test_cast_float_to_byte(self):
     self.assertEqual(
         cast_to_byte(-128.8, FloatType(), options=BASE_OPTIONS), -128)