本文整理匯總了Python中aifc._HUGE_VAL屬性的典型用法代碼示例。如果您正苦於以下問題:Python aifc._HUGE_VAL屬性的具體用法?Python aifc._HUGE_VAL怎麽用?Python aifc._HUGE_VAL使用的例子?那麽, 這裏精選的屬性代碼示例或許可以為您提供幫助。您也可以進一步了解該屬性所在類aifc
的用法示例。
在下文中一共展示了aifc._HUGE_VAL屬性的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: test_read_written
# 需要導入模塊: import aifc [as 別名]
# 或者: from aifc import _HUGE_VAL [as 別名]
def test_read_written(self):
def read_written(self, what):
f = io.BytesIO()
getattr(aifc, '_write_' + what)(f, x)
f.seek(0)
return getattr(aifc, '_read_' + what)(f)
for x in (-1, 0, 0.1, 1):
self.assertEqual(read_written(x, 'float'), x)
for x in (float('NaN'), float('Inf')):
self.assertEqual(read_written(x, 'float'), aifc._HUGE_VAL)
for x in ('', 'foo', 'a' * 255):
self.assertEqual(read_written(x, 'string'), x)
for x in (-0x7FFFFFFF, -1, 0, 1, 0x7FFFFFFF):
self.assertEqual(read_written(x, 'long'), x)
for x in (0, 1, 0xFFFFFFFF):
self.assertEqual(read_written(x, 'ulong'), x)
for x in (-0x7FFF, -1, 0, 1, 0x7FFF):
self.assertEqual(read_written(x, 'short'), x)
for x in (0, 1, 0xFFFF):
self.assertEqual(read_written(x, 'ushort'), x)
示例2: test_read_written
# 需要導入模塊: import aifc [as 別名]
# 或者: from aifc import _HUGE_VAL [as 別名]
def test_read_written(self):
def read_written(self, what):
f = io.BytesIO()
getattr(aifc, '_write_' + what)(f, x)
f.seek(0)
return getattr(aifc, '_read_' + what)(f)
for x in (-1, 0, 0.1, 1):
self.assertEqual(read_written(x, 'float'), x)
for x in (float('NaN'), float('Inf')):
self.assertEqual(read_written(x, 'float'), aifc._HUGE_VAL)
for x in (b'', b'foo', b'a' * 255):
self.assertEqual(read_written(x, 'string'), x)
for x in (-0x7FFFFFFF, -1, 0, 1, 0x7FFFFFFF):
self.assertEqual(read_written(x, 'long'), x)
for x in (0, 1, 0xFFFFFFFF):
self.assertEqual(read_written(x, 'ulong'), x)
for x in (-0x7FFF, -1, 0, 1, 0x7FFF):
self.assertEqual(read_written(x, 'short'), x)
for x in (0, 1, 0xFFFF):
self.assertEqual(read_written(x, 'ushort'), x)