Skip to content

Commit

Permalink
Add test for string sanitization mode
Browse files Browse the repository at this point in the history
  • Loading branch information
sorokya committed Oct 13, 2024
1 parent 844494f commit d8adae3
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions src/data/eo_writer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -259,4 +259,16 @@ mod tests {
let result = writer.add_int(-i32::MAX).unwrap_err();
assert_eq!(result, EoWriterError::InvalidIntValue(i32::MAX as i64 * 2));
}

#[test]
fn string_sanitization_mode() {
let mut writer = EoWriter::new();
writer.add_string("ÿ");
assert_eq!(&writer.to_byte_array()[..], &[0xff]);

let mut writer = EoWriter::new();
writer.set_string_sanitization_mode(true);
writer.add_string("ÿ");
assert_eq!(&writer.to_byte_array()[..], &[0x79]);
}
}

0 comments on commit d8adae3

Please sign in to comment.