38 lines
1.1 KiB
Python
38 lines
1.1 KiB
Python
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()
|