chore(test): 迁移测试夹具到新语法
机械规则 R2/R3/R4/R6/R7/R8/R13 + R16 保守子集,共 86 文件 2127 行。R1(T | t.CPtr)与 R12(while 下标循环)未做,仍列为待办。全量 77/77 顺序回归通过。
This commit is contained in:
1 parent
c9d741c202
commit
f5da836fbb
86 files changed
+2121
-2121
No files matched your search
+14
-14
@@ -12,17 +12,17 @@ import w32.win32console
|
||||
# ==============================================
|
||||
# 工具函数:打印十六进制哈希串
|
||||
# ==============================================
|
||||
def print_hex(buf: t.CUInt8T | t.CPtr, length: t.CInt):
|
||||
def print_hex(buf: uint8 | t.CPtr, length: int):
|
||||
for i in range(length):
|
||||
stdio.printf("%02x", buf[i])
|
||||
stdio.printf("\n")
|
||||
|
||||
|
||||
def default_value_test_function(a: t.CInt, b: t.CInt = 1):
|
||||
def default_value_test_function(a: int, b: int = 1):
|
||||
print(a, b)
|
||||
|
||||
|
||||
def main() -> t.CInt | t.CExport:
|
||||
def main() -> int | t.CExport:
|
||||
w32.win32console.SetConsoleCP(65001)
|
||||
w32.win32console.SetConsoleOutputCP(65001)
|
||||
|
||||
@@ -32,7 +32,7 @@ def main() -> t.CInt | t.CExport:
|
||||
testcheck.section("HASHLIB")
|
||||
plain: str = "hello123"
|
||||
|
||||
md5_buf: t.CArray[t.CUInt8T, hashlib.MD5_DIGEST_LEN]
|
||||
md5_buf: t.CArray[uint8, hashlib.MD5_DIGEST_LEN]
|
||||
mctx = hashlib.md5()
|
||||
mctx.update(plain)
|
||||
mctx.final(md5_buf)
|
||||
@@ -40,7 +40,7 @@ def main() -> t.CInt | t.CExport:
|
||||
print_hex(md5_buf, hashlib.MD5_DIGEST_LEN)
|
||||
testcheck.ok("HASHLIB md5 completed")
|
||||
|
||||
sha1_buf: t.CArray[t.CUInt8T, hashlib.SHA1_DIGEST_LEN]
|
||||
sha1_buf: t.CArray[uint8, hashlib.SHA1_DIGEST_LEN]
|
||||
s1ctx = hashlib.sha1()
|
||||
s1ctx.update(plain)
|
||||
s1ctx.final(sha1_buf)
|
||||
@@ -48,7 +48,7 @@ def main() -> t.CInt | t.CExport:
|
||||
print_hex(sha1_buf, hashlib.SHA1_DIGEST_LEN)
|
||||
testcheck.ok("HASHLIB sha1 completed")
|
||||
|
||||
sha256_buf: t.CArray[t.CUInt8T, hashlib.SHA256_DIGEST_LEN]
|
||||
sha256_buf: t.CArray[uint8, hashlib.SHA256_DIGEST_LEN]
|
||||
s2ctx = hashlib.sha256()
|
||||
s2ctx.update(plain)
|
||||
s2ctx.final(sha256_buf)
|
||||
@@ -56,7 +56,7 @@ def main() -> t.CInt | t.CExport:
|
||||
print_hex(sha256_buf, hashlib.SHA256_DIGEST_LEN)
|
||||
testcheck.ok("HASHLIB sha256 completed")
|
||||
|
||||
sha512_buf: t.CArray[t.CUInt8T, hashlib.SHA512_DIGEST_LEN]
|
||||
sha512_buf: t.CArray[uint8, hashlib.SHA512_DIGEST_LEN]
|
||||
s5ctx = hashlib.sha512()
|
||||
s5ctx.update(plain)
|
||||
s5ctx.final(sha512_buf)
|
||||
@@ -69,11 +69,11 @@ def main() -> t.CInt | t.CExport:
|
||||
|
||||
# ---------- base64 编解码测试 ----------
|
||||
testcheck.section("BASE64")
|
||||
b64_out: t.CArray[t.CChar, 256]
|
||||
b64_dec: t.CArray[t.CUInt8T, 256]
|
||||
b64_out: t.CArray[char, 256]
|
||||
b64_dec: t.CArray[uint8, 256]
|
||||
base64.b64encode(plain, b64_out)
|
||||
print("Base64 编码:", b64_out)
|
||||
dlen: t.CSizeT = base64.b64decode(b64_out, b64_dec)
|
||||
dlen: sizet = base64.b64decode(b64_out, b64_dec)
|
||||
b64_dec[dlen] = 0
|
||||
print("Base64 解码:", b64_dec)
|
||||
testcheck.ok("BASE64 encode/decode completed")
|
||||
@@ -82,7 +82,7 @@ def main() -> t.CInt | t.CExport:
|
||||
testcheck.section("BINASCII")
|
||||
binascii.init_binascii()
|
||||
raw: str = "HelloWorld!"
|
||||
raw_length: t.CInt = 11
|
||||
raw_length: int = 11
|
||||
|
||||
hex_out: str = binascii.b2a_hex(raw, raw_length)
|
||||
if hex_out:
|
||||
@@ -90,7 +90,7 @@ def main() -> t.CInt | t.CExport:
|
||||
stdlib.free(hex_out)
|
||||
testcheck.ok("BINASCII b2a_hex completed")
|
||||
|
||||
crc_val: t.CUnsignedInt = binascii.crc32(raw, raw_length, 0)
|
||||
crc_val: uint = binascii.crc32(raw, raw_length, 0)
|
||||
stdio.printf("CRC32: %u\n", crc_val)
|
||||
testcheck.ok("BINASCII crc32 completed")
|
||||
|
||||
@@ -106,7 +106,7 @@ def main() -> t.CInt | t.CExport:
|
||||
stdlib.free(uu_out)
|
||||
testcheck.ok("BINASCII b2a_uu completed")
|
||||
|
||||
hqx_in: t.CArray[t.CChar, 4] = ['A', 'B', 'C', '\0']
|
||||
hqx_in: t.CArray[char, 4] = ['A', 'B', 'C', '\0']
|
||||
hqx_crc: t.CUnsignedShort = 0
|
||||
hqx_out: str
|
||||
unhqx: str
|
||||
@@ -116,7 +116,7 @@ def main() -> t.CInt | t.CExport:
|
||||
stdlib.free(hqx_out); stdlib.free(unhqx)
|
||||
testcheck.ok("BINASCII hqx completed")
|
||||
|
||||
adler_val: t.CUnsignedInt = binascii.adler32(raw, raw_length, 1)
|
||||
adler_val: uint = binascii.adler32(raw, raw_length, 1)
|
||||
stdio.printf("Adler32: %u\n", adler_val)
|
||||
testcheck.ok("BINASCII adler32 completed")
|
||||
|
||||
|
||||
Reference in new issue
Block a user