aboutsummaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
Diffstat (limited to 'tests')
-rw-r--r--tests/integration.rs38
1 files changed, 38 insertions, 0 deletions
diff --git a/tests/integration.rs b/tests/integration.rs
new file mode 100644
index 0000000..d355a47
--- /dev/null
+++ b/tests/integration.rs
@@ -0,0 +1,38 @@
1use std::io::Cursor;
2
3use obi::{error::OBIResult, Image};
4
5#[test]
6fn encode_modify_decode() {
7 let mut img = Image::new(50, 5);
8 img.set(2, 3, true).expect("Indexing error");
9 let encoded = img.encode().unwrap();
10 let mut cursor = Cursor::new(encoded);
11 let decoded = Image::decode(&mut cursor).unwrap();
12 assert!(decoded.get(2, 3).unwrap());
13}
14
15#[test]
16fn encode_modify_decode_padded_byte_edge_case() -> OBIResult<()> {
17 let mut img = Image::new(1, 4);
18 img.set(0, 2, true)?;
19 let encoded = img.encode()?;
20 let mut cursor = Cursor::new(encoded);
21 let decoded = Image::decode(&mut cursor)?;
22 assert!(!decoded.get(0, 0)?);
23 assert!(!decoded.get(0, 1)?);
24 assert!(decoded.get(0, 2)?);
25 assert!(!decoded.get(0, 3)?);
26 Ok(())
27}
28
29#[test]
30fn encode_modify_decode_padded_byte_edge_case_big_image() -> OBIResult<()> {
31 let mut img = Image::new(25, 10);
32 img.set(24, 9, true)?;
33 let encoded = img.encode()?;
34 let mut cursor = Cursor::new(encoded);
35 let decoded = Image::decode(&mut cursor)?;
36 assert!(decoded.get(24, 9)?);
37 Ok(())
38}