This commit is contained in:
Jean-Marie Mineau 2024-04-15 18:00:46 +02:00
parent ef6a2196a7
commit 11f09f7b93
Signed by: histausse
GPG key ID: B66AEEDA9B645AD2
3 changed files with 17 additions and 2 deletions

File diff suppressed because one or more lines are too long

View file

@ -386,8 +386,8 @@ fn check_valid_offset_and_size(
} }
#[test] #[test]
fn test_load_from_json() { fn test_1_from_json() {
let filename = "test_class.json"; let filename = "test_class1.json";
let hello_world_dex = format!("{}/src/tests/{}", env!("CARGO_MANIFEST_DIR"), filename); let hello_world_dex = format!("{}/src/tests/{}", env!("CARGO_MANIFEST_DIR"), filename);
let mut file = File::open(&hello_world_dex).expect(&format!("{} not found", filename)); let mut file = File::open(&hello_world_dex).expect(&format!("{} not found", filename));
let mut json = String::new(); let mut json = String::new();
@ -534,3 +534,17 @@ fn test_load_from_json() {
panic!("Map is missing Class Def entry"); panic!("Map is missing Class Def entry");
} }
} }
#[test]
fn test_2_from_json() {
let filename = "app1.json";
let json_path = format!("{}/src/tests/{}", env!("CARGO_MANIFEST_DIR"), filename);
let mut file = File::open(&json_path).expect(&format!("{} not found", filename));
let mut json = String::new();
file.read_to_string(&mut json).unwrap();
let apk: Apk = serde_json::from_str(&json).unwrap();
let dex = apk.gen_raw_dex().unwrap().pop().unwrap();
let mut new_apk = Apk::new();
new_apk.add_dex_file(&dex).unwrap();
assert_eq!(apk, new_apk);
}