fix value serialization and add test for boolean value for regression
This commit is contained in:
parent
c81a72ae36
commit
cc6ce1c625
2 changed files with 34 additions and 4 deletions
|
|
@ -90,7 +90,7 @@ impl Apk {
|
|||
static_fields = self.get_field_list_from_dex(&data.static_fields, dex)?;
|
||||
instance_fields = self.get_field_list_from_dex(&data.instance_fields, dex)?;
|
||||
}
|
||||
/*
|
||||
|
||||
if class_item.static_values_off != 0 {
|
||||
let values = dex
|
||||
.get_struct_at_offset::<EncodedArray>(class_item.static_values_off)?
|
||||
|
|
@ -109,7 +109,7 @@ impl Apk {
|
|||
for field in static_fields.iter_mut().skip(values.len()) {
|
||||
field.value = None;
|
||||
}
|
||||
}*/
|
||||
}
|
||||
Ok(Class {
|
||||
name,
|
||||
superclass,
|
||||
|
|
|
|||
|
|
@ -250,7 +250,7 @@ impl Serializable for EncodedValue {
|
|||
})?;
|
||||
let [byte] = buffer;
|
||||
let arg = (byte & 0b1110_0000) >> 5;
|
||||
match ValueType(byte & 0b0011_1111) {
|
||||
match ValueType(byte & 0b0001_1111) {
|
||||
VALUE_BYTE => {
|
||||
if arg != 0 {
|
||||
Err(Error::DeserializationError(format!(
|
||||
|
|
@ -669,4 +669,34 @@ impl Serializable for Idx {
|
|||
}
|
||||
}
|
||||
|
||||
// TODO: TESTS!!!
|
||||
// TODO: more TESTS!!!
|
||||
|
||||
#[cfg(test)]
|
||||
mod test {
|
||||
use super::*;
|
||||
|
||||
#[test]
|
||||
fn boolean_deserialize() {
|
||||
assert_eq!(
|
||||
EncodedValue::deserialize_from_slice(&[0b0001_1111]).unwrap(),
|
||||
EncodedValue::Boolean(false)
|
||||
);
|
||||
assert_eq!(
|
||||
EncodedValue::deserialize_from_slice(&[0b0011_1111]).unwrap(),
|
||||
EncodedValue::Boolean(true)
|
||||
);
|
||||
assert!(EncodedValue::deserialize_from_slice(&[0b0101_1111]).is_err());
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn boolean_serialize() {
|
||||
assert_eq!(
|
||||
EncodedValue::Boolean(false).serialize_to_vec().unwrap(),
|
||||
vec![0b0001_1111]
|
||||
);
|
||||
assert_eq!(
|
||||
EncodedValue::Boolean(true).serialize_to_vec().unwrap(),
|
||||
vec![0b0011_1111]
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue