Skip to content

Commit

Permalink
fixup! Refactor attributes API
Browse files Browse the repository at this point in the history
  • Loading branch information
robin-nitrokey committed Aug 16, 2024
1 parent ebe321a commit 1afd16e
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions src/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -443,6 +443,21 @@ fn attributes() {
assert_eq!(data, attribute.data());
assert_eq!(data.len(), attribute.total_size());

// if the buffer is smaller than the attribute, it is truncated and the
// full size is returned
let mut small_buffer = [0; 5];
let attribute = fs.attribute(filename, 37, &mut small_buffer)?.unwrap();
assert_eq!(&data[..5], attribute.data());
assert_eq!(data.len(), attribute.total_size());

// if the input data is too long, an error is returned
let long_data = &[0xff; 1024];
assert!(long_data.len() > Attribute::MAX_SIZE as _);
assert_eq!(
Err(Error::NO_SPACE),
fs.set_attribute(filename, 37, long_data)
);

// // not sure if we should have this method (may be quite expensive)
// let attributes = unsafe { fs.attributes("some.file", &mut storage).unwrap() };
// assert!(attributes[37]);
Expand Down

0 comments on commit 1afd16e

Please sign in to comment.