aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/lib.rs28
1 files changed, 28 insertions, 0 deletions
diff --git a/src/lib.rs b/src/lib.rs
new file mode 100644
index 0000000..e3c7e47
--- /dev/null
+++ b/src/lib.rs
@@ -0,0 +1,28 @@
+#![allow(non_upper_case_globals)]
+#![allow(non_camel_case_types)]
+#![allow(non_snake_case)]
+
+include!(concat!(env!("OUT_DIR"), "/bindings.rs"));
+
+#[cfg(test)]
+mod tests {
+ use super::*;
+ use std::ffi::CString;
+
+ #[test]
+ fn two_plus_two() {
+ unsafe {
+ let interp = Tcl_CreateInterp();
+ let script = CString::new("expr 2 + 2").unwrap();
+ let eval_status = Tcl_Eval(interp, script.as_ptr());
+ assert_eq!(eval_status, TCL_OK as i32);
+ let result = Tcl_GetObjResult(interp);
+ let mut result_value = 0;
+ let get_int_status = Tcl_GetIntFromObj(interp, result, &mut result_value);
+ assert_eq!(get_int_status, TCL_OK as i32);
+ assert_eq!(result_value, 4);
+
+ Tcl_DeleteInterp(interp);
+ }
+ }
+}