code wiki / (root) / nx_http_get_ua_test.nx

nx_http_get_ua_test.nx source

↩ module page · 15 lines · 575 B

1// nx_http_get_ua_test.nx -- KAT for the UA request builder (pure, deterministic). 2// Native sovereign lane; exit 0 = pass, N = assertion N failed. 3 4import "nx_str.nx" 5import "nx_http_get_ua.nx" 6 7func main() -> i64 { 8 let out: *u8 = sys_mmap(512) 9 let n: i64 = nx_http_ua_build_request("/wiki", 5, "host.com", 8, "NishiBot/1.0", 12, out) 10 out[n] = 0 11 let exp: *u8 = "GET /wiki HTTP/1.1\r\nHost: host.com\r\nUser-Agent: NishiBot/1.0\r\nConnection: close\r\n\r\n" 12 if n != nx_str_len(exp) { return 1 } 13 if nx_str_eq(out, exp) != 1 { return 2 } 14 return 0 15}