当前位置: 首页>>代码示例>>Python>>正文


Python SizeStruct.new_from_bytes方法代码示例

本文整理汇总了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)
开发者ID:rhinstaller,项目名称:libbytesize,代码行数:9,代码来源:libbytesize_unittest.py

示例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)
开发者ID:rhinstaller,项目名称:libbytesize,代码行数:32,代码来源:libbytesize_unittest.py

示例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)
开发者ID:dashea,项目名称:libbytesize,代码行数:14,代码来源:libbytesize_unittest.py

示例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)
开发者ID:rhinstaller,项目名称:libbytesize,代码行数:16,代码来源:libbytesize_unittest.py

示例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)
开发者ID:rhinstaller,项目名称:libbytesize,代码行数:17,代码来源:libbytesize_unittest.py

示例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)
开发者ID:rhinstaller,项目名称:libbytesize,代码行数:19,代码来源:libbytesize_unittest.py

示例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)
开发者ID:rhinstaller,项目名称:libbytesize,代码行数:7,代码来源:libbytesize_unittest.py


注:本文中的bytesize.SizeStruct.new_from_bytes方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。