本文整理汇总了Python中pyndn.Name.appendImplicitSha256Digest方法的典型用法代码示例。如果您正苦于以下问题:Python Name.appendImplicitSha256Digest方法的具体用法?Python Name.appendImplicitSha256Digest怎么用?Python Name.appendImplicitSha256Digest使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pyndn.Name
的用法示例。
在下文中一共展示了Name.appendImplicitSha256Digest方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_implicit_sha256_digest
# 需要导入模块: from pyndn import Name [as 别名]
# 或者: from pyndn.Name import appendImplicitSha256Digest [as 别名]
def test_implicit_sha256_digest(self):
name = Name()
digest = bytearray([
0x28, 0xba, 0xd4, 0xb5, 0x27, 0x5b, 0xd3, 0x92,
0xdb, 0xb6, 0x70, 0xc7, 0x5c, 0xf0, 0xb6, 0x6f,
0x13, 0xf7, 0x94, 0x2b, 0x21, 0xe8, 0x0f, 0x55,
0xc0, 0xe8, 0x6b, 0x37, 0x47, 0x53, 0xa5, 0x48,
0x00, 0x00
])
name.appendImplicitSha256Digest(digest[0:32])
name.appendImplicitSha256Digest(digest[0:32])
self.assertEqual(name.get(0), name.get(1))
gotError = True
try:
name.appendImplicitSha256Digest(digest[0:34])
gotError = False
except:
pass
if not gotError:
self.fail("Expected error in appendImplicitSha256Digest")
gotError = True
try:
name.appendImplicitSha256Digest(digest[0:30])
gotError = False
except:
pass
if not gotError:
self.fail("Expected error in appendImplicitSha256Digest")
# Add name.get(2) as a generic component.
name.append(digest[0:32])
self.assertTrue(name.get(0).compare(name.get(2)) < 0)
self.assertEqual(name.get(0).getValue(), name.get(2).getValue())
# Add name.get(3) as a generic component whose first byte is greater.
name.append(digest[1:32])
self.assertTrue(name.get(0).compare(name.get(3)) < 0)
self.assertEqual(
name.get(0).toEscapedString(),
"sha256digest=" +
"28bad4b5275bd392dbb670c75cf0b66f13f7942b21e80f55c0e86b374753a548")
self.assertEqual(name.get(0).isImplicitSha256Digest(), True)
self.assertEqual(name.get(2).isImplicitSha256Digest(), False)
gotError = True
try:
Name("/hello/sha256digest=hmm")
gotError = False
except:
pass
if not gotError:
self.fail("Expected error in new Name from URI")
# Check canonical URI encoding (lower case).
name2 = Name(
"/hello/sha256digest=" +
"28bad4b5275bd392dbb670c75cf0b66f13f7942b21e80f55c0e86b374753a548")
self.assertEqual(name.get(0), name2.get(1))
# Check that it will accept a hex value in upper case too.
name2 = Name(
"/hello/sha256digest=" +
"28BAD4B5275BD392DBB670C75CF0B66F13F7942B21E80F55C0E86B374753A548")
self.assertEqual(name.get(0), name2.get(1))