Files
TransPyC/Test/HashLibTest/App/main.vp
T
TermiNexus 6644d6ce3b test: TestProject/2/3 拆分为 10 个具体测试项目; ZlibTest 并入标准 zlib 库
新项目(各含 project.json + App/main.vp):
- LoopMathTest/LogicFlowTest/ClassArrayTest/NumpyTest (原 TestProject)
- HashLibTest (原 TestProject2 去 zlib)
- GenericOopTest/EnumTest/MpoolOopTest/VectorGenericTest/FileIoTest (原 TestProject3)
ZlibTest 增加"标准 zlib 库(zlib.pyzlib)" section 与 __zlib 并存验证。
2026-08-09 04:06:26 +08:00

27 lines
671 B
Plaintext

import t, c
import testcheck
import hashlib
import binascii
import w32.win32console
def main() -> t.CInt | t.CExport:
w32.win32console.SetConsoleCP(65001)
w32.win32console.SetConsoleOutputCP(65001)
testcheck.begin("HashLibTest: 哈希与校验测试")
testcheck.section("HASHLIB")
md5_buf: t.CArray[t.CUInt8T, hashlib.MD5_DIGEST_LEN]
mctx = hashlib.md5()
mctx.update("hello")
mctx.final(md5_buf)
testcheck.ok("HASHLIB md5 completed")
testcheck.section("BINASCII")
binascii.init_binascii()
crc_val: t.CUnsignedInt = binascii.crc32("hello", 5, 0)
testcheck.ok("BINASCII crc32 completed")
return testcheck.end()