code wiki / (root) / nx_cpp_calc_test.nx

nx_cpp_calc_test.nx source

↩ module page · 34 lines · 1959 B

1// nx_cpp_calc_test.nx -- gate for the cost-per-page calculator (nx_cpp_calc). Unique exit codes per invariant: 2// 1-3 ISO CPP (price*1000/yield); bad yield -> -1 3// 10-12 REAL CPP at our coverage: =ISO at 5%, doubles at 10%, =4400 mc/pg at the Brother's measured 5.28% 4// 20-21 real pages from coverage (1200 @5%, 600 @10%) 5// 30-31 genuine-vs-aftermarket savings: 3000 milli-cents/page, 75% cheaper 6// expect_exit: 0 ; license_tier: ORIGINAL ; genealogy_id: project-printer-management-ipp-sclass-2026-06-20 7 8import "nx_syscalls.nx" 9import "nx_cpp_calc.nx" 10 11func t_puts(s: *u8) -> i64 { var n: i64 = 0; while s[n] != (0 as u8) { n = n + 1 } sys_write(1, s, n); return 0 } 12 13func main() -> i64 { 14 // ISO CPP: $48 cartridge / 1200 pages = 4.000 cents/page (4000 milli-cents) 15 if nx_cpp_iso(4800, 1200) != 4000 { return 1 } 16 if nx_cpp_iso(1200, 1200) != 1000 { return 2 } 17 if nx_cpp_iso(5000, 0) != (0 - 1) { return 3 } 18 19 // REAL CPP at measured coverage 20 if nx_cpp_real(4800, 1200, 50000) != 4000 { return 10 } // 5% coverage == ISO number 21 if nx_cpp_real(4800, 1200, 100000) != 8000 { return 11 } // 10% coverage -> double cost/page 22 if nx_cpp_real(5000, 1200, 52800) != 4400 { return 12 } // Brother job49 real 5.28% -> 4.4 c/pg 23 24 // real pages from coverage 25 if nx_cpp_real_pages(1200, 50000) != 1200 { return 20 } 26 if nx_cpp_real_pages(1200, 100000) != 600 { return 21 } // heavier pages -> fewer pages/cartridge 27 28 // genuine ($48) vs aftermarket ($12), same 1200-page yield 29 if nx_cpp_savings(4800, 1200, 1200, 1200) != 3000 { return 30 } // save 3.000 cents/page 30 if nx_cpp_savings_pct(4800, 1200, 1200, 1200) != 75 { return 31 }// 75% cheaper per page 31 32 t_puts("nx_cpp_calc: PASS ISO CPP + REAL CPP at measured coverage (Brother 5.28% -> 4.4c/pg) + real pages + genuine-vs-aftermarket savings (3.0c/pg, 75% cheaper -- the gap DRM defends)\n") 33 return 0 34}