1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
//! Bindings to [Hiredis][1].
//!
//! [1]: https://github.com/redis/hiredis

extern crate libc;

mod read;
mod redis;

pub use read::*;
pub use redis::*;

#[cfg(test)]
mod tests {
    macro_rules! ok(
        ($result:expr) => ($result.unwrap());
    );

    macro_rules! c_str(
        ($string:expr) => (ok!(::std::ffi::CString::new($string)).as_ptr());
    );

    #[test]
    fn connect() {
        unsafe {
            let context = ::redisConnect(c_str!("127.0.0.1"), 6379);
            assert!(!context.is_null());
            assert!((*context).err == ::REDIS_OK);
            ::redisFree(context);
        }
    }
}