File tree 1 file changed +46
-0
lines changed
1 file changed +46
-0
lines changed Original file line number Diff line number Diff line change @@ -45,3 +45,49 @@ pub(crate) fn write(region: Rectangle) -> Result<(), Error> {
45
45
. write_all ( region. as_str ( ) . as_bytes ( ) ) ?
46
46
. pipe ( Ok )
47
47
}
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
+ }
You can’t perform that action at this time.
0 commit comments