Skip to content

Commit 48d7af3

Browse files
committed
test: add test for last_region
1 parent 762e48e commit 48d7af3

File tree

1 file changed

+46
-0
lines changed

1 file changed

+46
-0
lines changed

src/last_region.rs

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,3 +45,49 @@ pub(crate) fn write(region: Rectangle) -> Result<(), Error> {
4545
.write_all(region.as_str().as_bytes())?
4646
.pipe(Ok)
4747
}
48+
49+
#[cfg(test)]
50+
mod tests {
51+
use super::*;
52+
use pretty_assertions::assert_eq;
53+
54+
#[test]
55+
fn write_and_read_last_region() {
56+
let region = Rectangle {
57+
x: 42.0,
58+
y: 24.0,
59+
width: 800.0,
60+
height: 600.0,
61+
};
62+
63+
write(region).unwrap();
64+
assert_eq!(
65+
read(Rectangle {
66+
x: 0.0,
67+
y: 0.0,
68+
width: 3440.0,
69+
height: 1440.00
70+
})
71+
.unwrap(),
72+
Some(region)
73+
);
74+
let another_region = Rectangle {
75+
x: 900.0,
76+
y: 400.0,
77+
width: 800.0,
78+
height: 150.0,
79+
};
80+
81+
write(another_region).unwrap();
82+
assert_eq!(
83+
read(Rectangle {
84+
x: 0.0,
85+
y: 0.0,
86+
width: 3440.0,
87+
height: 1440.00
88+
})
89+
.unwrap(),
90+
Some(another_region)
91+
);
92+
}
93+
}

0 commit comments

Comments
 (0)