Skip to content

Commit

Permalink
Update test to include more packages
Browse files Browse the repository at this point in the history
  • Loading branch information
snpefk committed Dec 23, 2024
1 parent 2bb12fb commit 9bbc668
Show file tree
Hide file tree
Showing 13 changed files with 72 additions and 13 deletions.
1 change: 1 addition & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
*.siq filter=lfs diff=lfs merge=lfs -text
54 changes: 41 additions & 13 deletions crates/opensi-core/tests/check_data.rs
Original file line number Diff line number Diff line change
@@ -1,24 +1,52 @@
use opensi_core::prelude::*;

const PATH: &str = "tests/data/slamjam2.siq";
use std::fs;
use std::path::PathBuf;

#[test]
fn open_pack() {
let package = Package::open_zip_file(PATH);
assert_eq!(package.is_ok(), true);
}
const PACKS_DIR: &str = "tests/data";

#[test]
fn read_package_name() {
let package = Package::open_zip_file(PATH).expect("pack is not found");
assert_eq!(package.name, "SLAM JAM 2".to_owned());
fn open_packs() {
for pack in get_packs() {
let package = Package::open_zip_file(&pack);
let package_name = pack.file_name().unwrap().to_str().unwrap();

assert!(package.is_ok(), "Can't open package {}, error is {}", package_name, package.err().unwrap());
}
}

#[test]
fn resave_test() {
let package_original = Package::open_zip_file(PATH).expect("Pack is not found");
let bytes = &package_original.to_bytes().expect("Can't serialize package to bytes");
let package_resaved = Package::from_zip_buffer(bytes).expect("Can't read package from buffer");
for pack in get_packs() {
let package_original = Package::open_zip_file(&pack).expect("Pack is not found");
let bytes = &package_original.to_bytes().expect("Can't serialize package to bytes");
let package_resaved =
Package::from_zip_buffer(bytes).expect("Can't read package from buffer");

let package_name = pack.file_name().unwrap().to_str().unwrap();

assert_eq!(
package_original,
package_resaved,
"Package {} resaving produced different results",
package_name
);
}
}

fn get_packs() -> Vec<PathBuf> {
let mut packs = Vec::new();

if let Ok(entries) = fs::read_dir(PACKS_DIR) {
for entry in entries {
if let Ok(entry) = entry {
let path = entry.path();
if path.is_file() && path.extension().unwrap_or_default() == "siq" {
packs.push(path);
}
}
}
}

assert_eq!(package_original, package_resaved);
packs
}
3 changes: 3 additions & 0 deletions crates/opensi-core/tests/data/ABOBA_1.siq
Git LFS file not shown
3 changes: 3 additions & 0 deletions crates/opensi-core/tests/data/Dedushkiny_Bredni.siq
Git LFS file not shown
3 changes: 3 additions & 0 deletions crates/opensi-core/tests/data/Lastovy_Bolshoy_Pak.siq
Git LFS file not shown
Git LFS file not shown
3 changes: 3 additions & 0 deletions crates/opensi-core/tests/data/Poshla_Yobka.siq
Git LFS file not shown
3 changes: 3 additions & 0 deletions crates/opensi-core/tests/data/Solyanka.siq
Git LFS file not shown
3 changes: 3 additions & 0 deletions crates/opensi-core/tests/data/Solyanka_Dlya_Petushatni.siq
Git LFS file not shown
3 changes: 3 additions & 0 deletions crates/opensi-core/tests/data/Solyanka_Namber_Sri.siq
Git LFS file not shown
3 changes: 3 additions & 0 deletions crates/opensi-core/tests/data/WorldMain_1.siq
Git LFS file not shown
Binary file modified crates/opensi-core/tests/data/slamjam2.siq
Binary file not shown.
3 changes: 3 additions & 0 deletions crates/opensi-core/tests/data/test-pack.siq
Git LFS file not shown

0 comments on commit 9bbc668

Please sign in to comment.