コード例 #1
0
ファイル: structs.py プロジェクト: lucyge/FBThrift
 def test_float_to_int_unqualified_field(self) -> None:
     with self.assertRaises(TypeError):
         numerical(  # type: ignore
             req_int_val=5,
             req_float_val=math.pi,
             int_val=math.pi
         )
コード例 #2
0
ファイル: structs.py プロジェクト: ryandesign/fbthrift
 def test_float_to_int_list(self) -> None:
     with self.assertRaises(TypeError):
         numerical(
             req_int_val=5,
             req_float_val=math.pi,
             int_list=[math.pi, math.e],  # type: ignore
         )
コード例 #3
0
ファイル: structs.py プロジェクト: killight98/fbthrift
 def test_float_to_int_unqualified_field(self) -> None:
     with self.assertRaises(TypeError):
         numerical(
             float_val=math.pi,
             # pyre-fixme[6]: Expected `Optional[int]` for 3rd param but got `float`.
             int_val=math.pi,
         )
コード例 #4
0
ファイル: structs.py プロジェクト: facebook/fbthrift
 def test_float_to_int_list(self) -> None:
     with self.assertRaises(TypeError):
         numerical(
             req_int_val=5,
             req_float_val=math.pi,
             int_list=[math.pi, math.e],  # type: ignore
         )
コード例 #5
0
 def test_float_to_int_list(self) -> None:
     with self.assertRaises(TypeError):
         numerical(
             req_int_val=5,
             req_float_val=math.pi,
             # pyre-fixme[6]: Expected `Optional[typing.Sequence[int]]` for 3rd
             #  param but got `List[float]`.
             int_list=[math.pi, math.e],
         )
コード例 #6
0
 def test_int_to_float(self) -> None:
     x = numerical(req_int_val=5,
                   req_float_val=5,
                   float_val=5,
                   float_list=[1, 5, 6])
     x(req_float_val=10)
     x(float_val=10)
     x(float_list=[6, 7, 8])
コード例 #7
0
 def test_float_to_int_required_field(self) -> None:
     with self.assertRaises(TypeError):
         # pyre-fixme[6]: Expected `Optional[int]` for 1st param but got `float`.
         numerical(req_int_val=math.pi, req_float_val=math.pi)
コード例 #8
0
 def test_int_to_i64(self) -> None:
     large = 2**63 - 1
     numerical(req_int_val=5, req_float_val=5, i64_val=int(large))
     too_large = 2**65 - 1
     with self.assertRaises(OverflowError):
         numerical(req_int_val=5, req_float_val=5, i64_val=int(too_large))
コード例 #9
0
    def test_overflow(self) -> None:
        with self.assertRaises(OverflowError):
            numerical(req_float_val=5, req_int_val=2**63 - 1)

        with self.assertRaises(OverflowError):
            numerical(req_float_val=5, req_int_val=2, int_list=[5, 2**32])
コード例 #10
0
ファイル: structs.py プロジェクト: ryandesign/fbthrift
 def test_float_to_int_required_field(self) -> None:
     with self.assertRaises(TypeError):
         numerical(req_int_val=math.pi, req_float_val=math.pi)  # type: ignore
コード例 #11
0
ファイル: structs.py プロジェクト: facebook/fbthrift
 def test_float_to_int_unqualified_field(self) -> None:
     with self.assertRaises(TypeError):
         numerical(  # type: ignore
             req_int_val=5, req_float_val=math.pi, int_val=math.pi
         )
コード例 #12
0
ファイル: structs.py プロジェクト: facebook/fbthrift
 def test_float_to_int_required_field(self) -> None:
     with self.assertRaises(TypeError):
         numerical(req_int_val=math.pi, req_float_val=math.pi)  # type: ignore
コード例 #13
0
ファイル: structs.py プロジェクト: facebook/fbthrift
 def test_int_to_float(self) -> None:
     x = numerical(req_int_val=5, req_float_val=5, float_val=5, float_list=[1, 5, 6])
     x(req_float_val=10)
     x(float_val=10)
     x(float_list=[6, 7, 8])
コード例 #14
0
ファイル: structs.py プロジェクト: facebook/fbthrift
    def test_overflow(self) -> None:
        with self.assertRaises(OverflowError):
            numerical(req_float_val=5, req_int_val=2 ** 63 - 1)

        with self.assertRaises(OverflowError):
            numerical(req_float_val=5, req_int_val=2, int_list=[5, 2 ** 32])