module main import engine #flag @REFERENCE_C@ #include "@REFERENCE_H@" fn C.reference_vercmp(&u8, &u8) int fn main() { mut versions := ['', ':', '-', '0:', '1:1.0-1', '1.0', '1.0-', '1.0--', '1.0a', '1.0.a', '2___a', '2_a', 'abc:1-3', '000:1-1', '999999999999999999999999999999'] mut state := u64(42) alphabet := '001239abAB._-:~+' for _ in 0 .. 400 { mut chars := []u8{} state = state * 6364136223846793005 + 1 count := int((state >> 32) % 24) for _ in 0 .. count { state = state * 6364136223846793005 + 1 chars << alphabet[int((state >> 32) % u64(alphabet.len))] } versions << chars.bytestr() } for a in versions { for b in versions { expected := C.reference_vercmp(a.str, b.str) actual := engine.pkg_vercmp(a, b) assert actual == expected, '${a} versus ${b}: V=${actual}, C=${expected}' } } println('${versions.len * versions.len} comparisons matched pacman version.c') }