本文整理汇总了Python中bytesize.SizeStruct.cmp_bytes方法的典型用法代码示例。如果您正苦于以下问题:Python SizeStruct.cmp_bytes方法的具体用法?Python SizeStruct.cmp_bytes怎么用?Python SizeStruct.cmp_bytes使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类bytesize.SizeStruct
的用法示例。
在下文中一共展示了SizeStruct.cmp_bytes方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: testCmpBytes
# 需要导入模块: from bytesize import SizeStruct [as 别名]
# 或者: from bytesize.SizeStruct import cmp_bytes [as 别名]
def testCmpBytes(self):
x = SizeStruct.new_from_str("1 KiB")
# result > 0
y = 1023
cmpResult = SizeStruct.cmp_bytes(x, y, False)
self.assertGreater(cmpResult, 0)
# result < 0
y = 1025
cmpResult = SizeStruct.cmp_bytes(x, y, False)
self.assertLess(cmpResult, 0)
# result == 0
y = 1024
cmpResult = SizeStruct.cmp_bytes(x, y, False)
self.assertEqual(cmpResult, 0)
# test with abs == True
x = SizeStruct.new_from_str("-1 KiB")
# result > 0
y = 1023
cmpResult = SizeStruct.cmp_bytes(x, y, True)
self.assertGreater(cmpResult, 0)
# result < 0
y = 1025
cmpResult = SizeStruct.cmp_bytes(x, y, True)
self.assertLess(cmpResult, 0)
# result == 0
y = 1024
cmpResult = SizeStruct.cmp_bytes(x, y, True)
self.assertEqual(cmpResult, 0)