prophet_sys/lib.rs
1#![allow(nonstandard_style)]
2
3include!(concat!(env!("OUT_DIR"), "/bindings.rs"));
4
5#[cfg(test)]
6mod tests {
7 use std::ffi::c_int;
8
9 use super::*;
10
11 #[test]
12 fn test_probe() {
13 unsafe {
14 prophet_tb_init();
15
16 let dctx = prophet_tb_create_decompress_ctx();
17
18 // 4k3/8/8/8/8/8/4Q3/4K3 b - - 0 1
19 let pieces: [c_int; 6] = [
20 6, // white king
21 5, // white queen
22 14, // black king
23 0, // no piece
24 0, // no piece
25 0, // no piece
26 ];
27 let squares: [c_int; 6] = [
28 4, // e1
29 12, // e2
30 60, // e8
31 0, // unused
32 0, // unused
33 0, // unused
34 ];
35 let dtm = prophet_tb_probe_dtm_dctx(
36 pieces.as_ptr(),
37 squares.as_ptr(),
38 1, // black to move
39 64, // no en-passant square
40 dctx,
41 );
42 assert_eq!(dtm, -1001); // no tables added yet
43
44 assert!(11 <= prophet_tb_add_path(c"tables".as_ptr()));
45 let dtm = prophet_tb_probe_dtm_dctx(pieces.as_ptr(), squares.as_ptr(), 1, 64, dctx);
46 assert_eq!(dtm, 16);
47
48 prophet_tb_free_decompress_ctx(dctx);
49
50 prophet_tb_deinit();
51 }
52 }
53}