43 lines
1.3 KiB
Rust
43 lines
1.3 KiB
Rust
use flate2::read::DeflateDecoder;
|
|
use flate2::write::DeflateEncoder;
|
|
use flate2::Compression;
|
|
use std::fs::File;
|
|
use std::io::{Read, Write};
|
|
use tempfile::tempfile;
|
|
use gemma::test_compression::TestCompression;
|
|
|
|
const TEST_OUTPUT_SAMPLE_DIR: &str = "../resources/test/";
|
|
const TEST_ROMS_SAMPLE_DIR: &str = "../resources/roms/";
|
|
|
|
#[test]
|
|
fn smoke() {
|
|
assert!(true)
|
|
}
|
|
|
|
/// Read a compressed test result and return the expected result
|
|
/// as a string
|
|
pub fn read_compressed_test_result(suffix: &str) -> String {
|
|
let full_path = std::env::current_dir().unwrap().display().to_string()
|
|
+ "/"
|
|
+ &*TEST_OUTPUT_SAMPLE_DIR.to_owned()
|
|
+ suffix
|
|
+ ".deflated";
|
|
println!("LOADING {}", full_path);
|
|
let mut compressed_file = File::open(&full_path)
|
|
.expect(format!("Unable to load test result [{}]", full_path.clone()).as_str());
|
|
let mut compressed_data = Vec::new();
|
|
compressed_file
|
|
.read_to_end(&mut compressed_data)
|
|
.expect("Unable to compress data");
|
|
|
|
TestCompression::decompress_to_string(&compressed_data).unwrap()
|
|
}
|
|
|
|
pub fn load_compressed_result(suffix: &str) -> String {
|
|
read_compressed_test_result(suffix)
|
|
}
|
|
|
|
pub fn load_rom(to_load: &str) -> Vec<u8> {
|
|
std::fs::read(format!("{}{}.ch8", TEST_ROMS_SAMPLE_DIR, to_load)).unwrap()
|
|
}
|