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
33
34
35
36
37
38
39
40
41
42
43
//! rANS 4x8 codec.

mod decode;
mod encode;
mod order;

pub use self::order::Order;
pub(crate) use self::{decode::decode, encode::encode};

#[cfg(test)]
mod tests {
    use std::io;

    use super::*;

    #[test]
    fn test_self_0() -> io::Result<()> {
        let data = b"noodles";

        let compressed_data = encode(Order::Zero, data)?;

        let mut reader = &compressed_data[..];
        let decompressed_data = decode(&mut reader)?;

        assert_eq!(decompressed_data, data);

        Ok(())
    }

    #[test]
    fn test_self_1() -> io::Result<()> {
        let data = b"noodles";

        let compressed_data = encode(Order::One, data)?;

        let mut reader = &compressed_data[..];
        let decompressed_data = decode(&mut reader)?;

        assert_eq!(decompressed_data, data);

        Ok(())
    }
}