comparison formats/src/th06/pbg3.rs @ 760:eba9a3d0c484

formats: Fix the tests.
author Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
date Tue, 05 Jan 2021 04:28:45 +0100
parents 21b186be2590
children f506ad5c9b17
comparison
equal deleted inserted replaced
759:abcb586566e6 760:eba9a3d0c484
164 } 164 }
165 165
166 #[cfg(test)] 166 #[cfg(test)]
167 mod tests { 167 mod tests {
168 use super::*; 168 use super::*;
169 use crate::util::SeekableSlice; 169 use std::io::Cursor;
170 use std::fs::File;
171 170
172 #[test] 171 #[test]
173 fn bitstream() { 172 fn bitstream() {
174 let data = SeekableSlice::new(b"Hello world!\0"); 173 let data = Cursor::new(b"Hello world!\0");
175 let bitstream = BitStream::new(data); 174 let bitstream = BitStream::new(data);
176 let mut pbg3 = PBG3BitStream::new(bitstream); 175 let mut pbg3 = PBG3BitStream::new(bitstream);
177 assert_eq!(pbg3.read_string(42).unwrap(), b"Hello world!"); 176 assert_eq!(pbg3.read_string(42).unwrap(), b"Hello world!");
178 } 177 }
179 178
191 let file = File::open("EoSD/MD.DAT").unwrap(); 190 let file = File::open("EoSD/MD.DAT").unwrap();
192 let file = io::BufReader::new(file); 191 let file = io::BufReader::new(file);
193 let mut pbg3 = PBG3::from_file(file).unwrap(); 192 let mut pbg3 = PBG3::from_file(file).unwrap();
194 let files = pbg3.list_files().cloned().collect::<Vec<String>>(); 193 let files = pbg3.list_files().cloned().collect::<Vec<String>>();
195 for filename in files { 194 for filename in files {
196 pbg3.get_file(filename, true).unwrap(); 195 pbg3.get_file(&filename, true).unwrap();
197 } 196 }
198 } 197 }
199 } 198 }