snapshot before regression test
This commit is contained in:
52
Test/FormatStringTest/App/main.py
Normal file
52
Test/FormatStringTest/App/main.py
Normal file
@@ -0,0 +1,52 @@
|
||||
from stdint import *
|
||||
import t, c
|
||||
import ctraits
|
||||
import stdio
|
||||
import testcheck
|
||||
|
||||
|
||||
# ============================================================
|
||||
# FormatStringTest - 格式化字符串回归测试
|
||||
# ============================================================
|
||||
@t.CExport
|
||||
def main() -> int:
|
||||
testcheck.begin("FormatStringTest: Format String Regression")
|
||||
|
||||
b: str = "hello world"
|
||||
for i in b:
|
||||
stdio.printf("%c\n", i)
|
||||
b += 1
|
||||
print(b-11)
|
||||
|
||||
l: t.CArray[u64] = [0, 43, 2, 3, 4]
|
||||
l[0] = 1000
|
||||
for i in l:
|
||||
stdio.printf("%llu\n", i)
|
||||
|
||||
print("Value: ", f"0x{ULONGLONG(0x11)}")
|
||||
print("ULL Hex: ", f"0x{ULONGLONG(0x11):016X}")
|
||||
print("LL Hex: ", f"{LONGLONG(0x11):016X}")
|
||||
print("ULL Dec: ", f"{ULONGLONG(42):d}")
|
||||
print("LL Dec: ", f"{LONGLONG(42):d}")
|
||||
print("Hex: ", f"{0x11:016X}")
|
||||
print("Dec: ", f"{42:d}")
|
||||
print("Float: ", f"{3.14159:.2f}")
|
||||
|
||||
# f-string 赋值测试(验证不再直接 printf,而是生成字符串)
|
||||
s: str = f"Value=0x{ULONGLONG(42)}, Hex=0x{ULONGLONG(0x11):016X}"
|
||||
print("Assigned: ", s)
|
||||
|
||||
# ctraits.isptr 编译时类型判断测试
|
||||
ptr_var: INTPTR = c.Addr(s)
|
||||
val_var: int = 42
|
||||
if c.CIf(ctraits.isptr(ptr_var)):
|
||||
print("ptr_var is pointer")
|
||||
if c.CIf(not ctraits.isptr(val_var)):
|
||||
print("val_var is not pointer")
|
||||
|
||||
testcheck.section("placeholder")
|
||||
testcheck.ok("testcheck framework ready")
|
||||
testcheck.info("placeholder test")
|
||||
|
||||
return testcheck.end()
|
||||
|
||||
Reference in New Issue
Block a user