1#![cfg_attr(docsrs, feature(doc_cfg))]
19
20#[allow(non_camel_case_types)]
21#[allow(non_snake_case)]
22#[allow(non_upper_case_globals)]
23mod bindings;
24
25pub use bindings::*;
26
27#[cfg(test)]
28mod tests {
29 use super::*;
30 use std::os::raw::{c_char, c_int};
31 use std::{env, ptr};
32
33 #[test]
34 fn dll_version() {
35 #[cfg(not(feature = "pstoedit_4_00"))]
36 assert_eq!(pstoeditdllversion, 301);
37 #[cfg(feature = "pstoedit_4_00")]
38 assert_eq!(pstoeditdllversion, 401);
39 }
40
41 #[test]
42 fn init() {
43 assert!(unsafe { pstoedit_checkversion(pstoeditdllversion) } != 0);
44 }
45
46 #[test]
47 fn driver_info() {
48 init();
49 let drivers: *mut DriverDescription_S = unsafe { getPstoeditDriverInfo_plainC() };
50 assert!(drivers != ptr::null_mut());
51 unsafe { clearPstoeditDriverInfo_plainC(drivers) };
52 }
53
54 #[test]
55 fn native_driver_info() {
56 init();
57 let drivers: *mut DriverDescription_S = unsafe { getPstoeditNativeDriverInfo_plainC() };
58 assert!(drivers != ptr::null_mut());
59 unsafe { clearPstoeditDriverInfo_plainC(drivers) };
60 }
61
62 #[test]
63 fn pstoedit() {
64 init();
65 let argv = [
67 b"pstoedit\0".as_ptr() as *const c_char,
68 b"-gstest\0".as_ptr() as *const c_char,
69 ];
70 let argc = argv.len() as c_int;
71 let psinterpreter = b"gs\0".as_ptr() as *const c_char;
73 env::set_var("GS", "should_not_be_used");
74 let result = unsafe { pstoedit_plainC(argc, argv.as_ptr(), psinterpreter) };
75 assert_eq!(result, 0);
76 }
77}