diff options
author | Akshay <[email protected]> | 2021-03-07 04:57:45 +0000 |
---|---|---|
committer | Akshay <[email protected]> | 2021-03-07 04:57:45 +0000 |
commit | 3d25a69b686c68f463ba313b2da112df135f1f0c (patch) | |
tree | a2d6f612404b5a2136f31d9274df258602130645 /tests | |
parent | a570dc384279bf9b38ff0cc9d4635c2081aa3147 (diff) |
add integration tests
Diffstat (limited to 'tests')
-rw-r--r-- | tests/integration.rs | 38 |
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 @@ | |||
1 | use std::io::Cursor; | ||
2 | |||
3 | use obi::{error::OBIResult, Image}; | ||
4 | |||
5 | #[test] | ||
6 | fn 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] | ||
16 | fn 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] | ||
30 | fn 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 | } | ||