本文整理汇总了Python中bytesize.SizeStruct.new_from_bytes方法的典型用法代码示例。如果您正苦于以下问题:Python SizeStruct.new_from_bytes方法的具体用法?Python SizeStruct.new_from_bytes怎么用?Python SizeStruct.new_from_bytes使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类bytesize.SizeStruct
的用法示例。
在下文中一共展示了SizeStruct.new_from_bytes方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: testGrow
# 需要导入模块: from bytesize import SizeStruct [as 别名]
# 或者: from bytesize.SizeStruct import new_from_bytes [as 别名]
def testGrow(self):
x = SizeStruct.new_from_bytes(16, 1)
y = SizeStruct.new_from_bytes(8, 1)
x.grow(y)
actual = x.get_bytes()
expected = (24, 1)
self.assertEqual(actual, expected)
示例2: testSub
# 需要导入模块: from bytesize import SizeStruct [as 别名]
# 或者: from bytesize.SizeStruct import new_from_bytes [as 别名]
def testSub(self):
x = SizeStruct.new_from_bytes(8, 1)
y = SizeStruct.new_from_bytes(16, 1)
actual = x.sub(y).get_bytes()
expected = (8, -1)
self.assertEqual(actual, expected)
x = SizeStruct.new_from_bytes(8, -1)
y = SizeStruct.new_from_bytes(16, 1)
actual = x.sub(y).get_bytes()
expected = (24, -1)
self.assertEqual(actual, expected)
x = SizeStruct.new_from_bytes(8, -1)
y = SizeStruct.new_from_bytes(16, -1)
actual = x.sub(y).get_bytes()
expected = (8, 1)
self.assertEqual(actual, expected)
x = SizeStruct.new_from_bytes(0, 0)
y = SizeStruct.new_from_bytes(16, -1)
actual = x.sub(y).get_bytes()
expected = (16, 1)
self.assertEqual(actual, expected)
x = SizeStruct.new_from_bytes(0, 0)
y = SizeStruct.new_from_bytes(0, 0)
actual = x.sub(y).get_bytes()
expected = (0, 0)
self.assertEqual(actual, expected)
示例3: testNewFromBytes
# 需要导入模块: from bytesize import SizeStruct [as 别名]
# 或者: from bytesize.SizeStruct import new_from_bytes [as 别名]
def testNewFromBytes(self):
actual = SizeStruct.new_from_bytes(0, 0).get_bytes()
expected = (0, 0)
self.assertEqual(actual, expected)
actual = SizeStruct.new_from_bytes(10, 1).get_bytes()
expected = (10, 1)
self.assertEqual(actual, expected)
actual = SizeStruct.new_from_bytes(1024, -1).get_bytes()
expected = (1024, -1)
self.assertEqual(actual, expected)
示例4: testShrink
# 需要导入模块: from bytesize import SizeStruct [as 别名]
# 或者: from bytesize.SizeStruct import new_from_bytes [as 别名]
def testShrink(self):
x = SizeStruct.new_from_bytes(16, 1)
y = SizeStruct.new_from_bytes(8, 1)
x.shrink(y)
actual = x.get_bytes()
expected = (8, 1)
self.assertEqual(actual, expected)
x = SizeStruct.new_from_bytes(8, 1)
y = SizeStruct.new_from_bytes(16, 1)
x.shrink(y)
actual = x.get_bytes()
expected = (8, -1)
self.assertEqual(actual, expected)
示例5: testSubBytes
# 需要导入模块: from bytesize import SizeStruct [as 别名]
# 或者: from bytesize.SizeStruct import new_from_bytes [as 别名]
def testSubBytes(self):
x = SizeStruct.new_from_bytes(8, 1)
actual = x.sub_bytes(16).get_bytes()
expected = (8, -1)
self.assertEqual(actual, expected)
x = SizeStruct.new_from_bytes(8, 1)
actual = x.sub_bytes(8).get_bytes()
expected = (0, 0)
self.assertEqual(actual, expected)
x = SizeStruct.new_from_bytes(8, -1)
actual = x.sub_bytes(0).get_bytes()
expected = (8, -1)
self.assertEqual(actual, expected)
示例6: testNewFromBytes
# 需要导入模块: from bytesize import SizeStruct [as 别名]
# 或者: from bytesize.SizeStruct import new_from_bytes [as 别名]
def testNewFromBytes(self):
actual = SizeStruct.new_from_bytes(0, 0).get_bytes()
expected = (0, 0)
self.assertEqual(actual, expected)
actual = SizeStruct.new_from_bytes(10, 1).get_bytes()
expected = (10, 1)
self.assertEqual(actual, expected)
actual = SizeStruct.new_from_bytes(1024, -1).get_bytes()
expected = (1024, -1)
self.assertEqual(actual, expected)
# now let's try something bigger than MAXUINT32
actual = SizeStruct.new_from_bytes(5718360*1024, 1).get_bytes()
expected = (5718360*1024, 1)
self.assertEqual(actual, expected)
示例7: testNewFromSizeStruct
# 需要导入模块: from bytesize import SizeStruct [as 别名]
# 或者: from bytesize.SizeStruct import new_from_bytes [as 别名]
def testNewFromSizeStruct(self):
tempSizeStruct = SizeStruct.new_from_bytes(17, 1)
actual = SizeStruct.new_from_size(tempSizeStruct).get_bytes()
expected = (17, 1)
self.assertEqual(actual, expected)