@@ -120,3 +120,44 @@ fn test_write_24_seek_start_4_write_4() {
120120 let cs_bytes = crc32fast:: hash ( & inner[ 0 .. 12 ] ) . to_be_bytes ( ) ;
121121 assert_eq ! ( inner[ 12 .. 16 ] , cs_bytes) ;
122122}
123+
124+ /// Do three things:
125+ /// A. write 24 bytes (two full segments)
126+ /// B. validate
127+ /// C. write 12 bytes (one full segment)
128+ #[ test]
129+ fn test_write_24_validate_write_12 ( ) {
130+ let mut store = empty_crc_store ( ) ;
131+
132+ // A
133+ let mut rng = rand:: thread_rng ( ) ;
134+ let data_0 = h:: random_bytes ( & mut rng, 24 ) ;
135+ store. write_all ( & data_0) . unwrap ( ) ;
136+
137+ // B
138+ let result = store. validate ( ) ;
139+ assert ! ( result. is_ok( ) ) ;
140+
141+ // C
142+ let data_1 = h:: random_bytes ( & mut rng, 12 ) ;
143+ store. write_all ( & data_1) . unwrap ( ) ;
144+ let inner = store. inner . into_inner ( ) ;
145+
146+ // segment 0
147+ let body = & data_0[ 0 .. 12 ] ;
148+ assert_eq ! ( inner[ 0 .. 12 ] , * body) ;
149+ let cs_bytes = crc32fast:: hash ( body) . to_be_bytes ( ) ;
150+ assert_eq ! ( inner[ 12 .. 16 ] , cs_bytes) ;
151+
152+ // segment 1
153+ let body = & data_0[ 12 .. 24 ] ;
154+ assert_eq ! ( inner[ 16 .. 28 ] , * body) ;
155+ let cs_bytes = crc32fast:: hash ( body) . to_be_bytes ( ) ;
156+ assert_eq ! ( inner[ 28 .. 32 ] , cs_bytes) ;
157+
158+ // segment 2
159+ let body = & data_1[ 0 .. 12 ] ;
160+ assert_eq ! ( inner[ 32 .. 44 ] , * body) ;
161+ let cs_bytes = crc32fast:: hash ( body) . to_be_bytes ( ) ;
162+ assert_eq ! ( inner[ 44 .. 48 ] , cs_bytes) ;
163+ }
0 commit comments