code wiki / _hdl_build / _pe_seohead_test.nx

_pe_seohead_test.nx source

↩ module page · 34 lines · 1723 B

1// AUTHORED BY THE NISHI BUILDER (pattern: TEMPLATE_TABLE test) -- byte-exact KATs derived from the table 2import "_pe_seohead.nx" 3import "nx_syscalls.nx" 4func _tt_eq(a: *u8, n: i64, b: *u8) -> i64 { 5 var i: i64 = 0 6 while i < n { if a[i] != b[i] { return 0 } i = i + 1 } 7 if b[n] != (0 as u8) { return 0 } 8 return 1 9} 10func main() -> i64 { 11 var bad: i64 = 0 12 let out: *u8 = sys_mmap(8192) 13 var n: i64 = 0 14 n = _pe_seohead_one(1, "x" as *u8, 1, out, 8191) 15 if _tt_eq(out, n, "<title>x</title>" as *u8) != 1 { bad = bad + 1 } 16 n = _pe_seohead_one(1, "<" as *u8, 1, out, 8191) 17 if _tt_eq(out, n, "<title>&lt;</title>" as *u8) != 1 { bad = bad + 1 } 18 n = _pe_seohead_one(2, "x" as *u8, 1, out, 8191) 19 if _tt_eq(out, n, "<meta name=\"description\" content=\"x\">" as *u8) != 1 { bad = bad + 1 } 20 n = _pe_seohead_one(3, "x" as *u8, 1, out, 8191) 21 if _tt_eq(out, n, "<meta property=\"og:title\" content=\"x\">" as *u8) != 1 { bad = bad + 1 } 22 n = _pe_seohead_one(4, "x" as *u8, 1, out, 8191) 23 if _tt_eq(out, n, "<meta property=\"og:description\" content=\"x\">" as *u8) != 1 { bad = bad + 1 } 24 n = _pe_seohead_one(5, "x" as *u8, 1, out, 8191) 25 if _tt_eq(out, n, "<meta property=\"og:image\" content=\"x\">" as *u8) != 1 { bad = bad + 1 } 26 n = _pe_seohead_one(6, "x" as *u8, 1, out, 8191) 27 if _tt_eq(out, n, "<link rel=\"canonical\" href=\"x\">" as *u8) != 1 { bad = bad + 1 } 28 n = _pe_seohead_one(7, "x" as *u8, 1, out, 8191) 29 if _tt_eq(out, n, "<meta property=\"og:type\" content=\"x\">" as *u8) != 1 { bad = bad + 1 } 30 if _pe_seohead_one(8, "x" as *u8, 1, out, 8191) + 1 != 0 { bad = bad + 1 } 31 if bad == 0 { sys_exit(0) } 32 sys_exit(1) 33 return 1 34}