예제 #1
0
 def test_complexunion_fromValue(self) -> None:
     tiny = 2 ** 7 - 1
     large = 2 ** 63 - 1
     afloat = 3.141592025756836  # Hand crafted to be representable as float
     adouble = 3.14159265358
     union = ComplexUnion.fromValue(tiny)
     self.assertEqual(union.type, ComplexUnion.Type.tiny)
     union = ComplexUnion.fromValue(large)
     self.assertEqual(union.type, ComplexUnion.Type.large)
     union = ComplexUnion.fromValue(afloat)
     self.assertEqual(union.value, afloat)
     self.assertEqual(union.type, ComplexUnion.Type.float_val)
     union = ComplexUnion.fromValue(adouble)
     self.assertEqual(union.value, adouble)
     self.assertEqual(union.type, ComplexUnion.Type.double_val)
     union = ComplexUnion.fromValue(Color.red)
     self.assertEqual(union.type, ComplexUnion.Type.color)
     union = ComplexUnion.fromValue(easy())
     self.assertEqual(union.type, ComplexUnion.Type.easy_struct)
     union = ComplexUnion.fromValue("foo")
     self.assertEqual(union.type, ComplexUnion.Type.text)
     union = ComplexUnion.fromValue(b"ar")
     self.assertEqual(union.type, ComplexUnion.Type.raw)
     union = ComplexUnion.fromValue(True)
     self.assertEqual(union.type, ComplexUnion.Type.truthy)
예제 #2
0
파일: unions.py 프로젝트: facebook/fbthrift
 def test_complexunion_fromValue(self) -> None:
     tiny = 2 ** 7 - 1
     large = 2 ** 63 - 1
     afloat = 3.141592025756836  # Hand crafted to be representable as float
     adouble = 3.14159265358
     union = ComplexUnion.fromValue(tiny)
     self.assertEqual(union.type, ComplexUnion.Type.tiny)
     union = ComplexUnion.fromValue(large)
     self.assertEqual(union.type, ComplexUnion.Type.large)
     union = ComplexUnion.fromValue(afloat)
     self.assertEqual(union.value, afloat)
     self.assertEqual(union.type, ComplexUnion.Type.float_val)
     union = ComplexUnion.fromValue(adouble)
     self.assertEqual(union.value, adouble)
     self.assertEqual(union.type, ComplexUnion.Type.double_val)
     union = ComplexUnion.fromValue(Color.red)
     self.assertEqual(union.type, ComplexUnion.Type.color)
     union = ComplexUnion.fromValue(easy())
     self.assertEqual(union.type, ComplexUnion.Type.easy_struct)
     union = ComplexUnion.fromValue("foo")
     self.assertEqual(union.type, ComplexUnion.Type.text)
     union = ComplexUnion.fromValue(b"ar")
     self.assertEqual(union.type, ComplexUnion.Type.raw)
     union = ComplexUnion.fromValue(True)
     self.assertEqual(union.type, ComplexUnion.Type.truthy)