Files
TransPyV/Test/App/testcheck_test.py
2026-07-19 13:18:46 +08:00

38 lines
1.1 KiB
Python
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
import stdio
import t, c
import string
import testcheck
# ============================================================
# testcheck_test - 测试 includes/testcheck 库导入与调用
#
# 验证命名空间隔离下import testcheck + 模块限定函数调用能正常工作。
# 同时测试 string 库的模块限定调用。
# ============================================================
def testcheck_test() -> int:
testcheck.begin("testcheck_test")
testcheck.section("Arithmetic")
a: int = 3 + 4
testcheck.check(a == 7, "3+4=7", "3+4!=7")
b: int = 10 - 3
testcheck.check(b == 7, "10-3=7", "10-3!=7")
m: int = 6 * 7
testcheck.check(m == 42, "6*7=42", "6*7!=42")
testcheck.section("String")
slen: int = string.strlen("hello")
testcheck.check(slen == 5, "strlen(hello)=5", "strlen(hello)!=5")
scmp: int = string.strcmp("abc", "abc")
testcheck.check(scmp == 0, "strcmp(abc,abc)=0", "strcmp(abc,abc)!=0")
testcheck.section("Module Import")
testcheck.info("testcheck module imported and called successfully")
testcheck.ok("import testcheck works")
return testcheck.end()