forked from M-Labs/rust-fatfs
Add more unit tests
This commit is contained in:
parent
0e96b05054
commit
d455540707
20
src/dir.rs
20
src/dir.rs
@ -610,3 +610,23 @@ impl<'a> Iterator for LfnEntriesGenerator<'a> {
|
||||
// name_parts_iter is ExactSizeIterator so size_hint returns one limit
|
||||
#[cfg(feature = "alloc")]
|
||||
impl<'a> ExactSizeIterator for LfnEntriesGenerator<'a> {}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
|
||||
#[test]
|
||||
fn test_split_path() {
|
||||
assert_eq!(split_path("aaa/bbb/ccc"), ("aaa", Some("bbb/ccc")));
|
||||
assert_eq!(split_path("aaa/bbb"), ("aaa", Some("bbb")));
|
||||
assert_eq!(split_path("aaa"), ("aaa", None));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_generate_short_name() {
|
||||
assert_eq!(&generate_short_name("Foo"), "FOO ".as_bytes());
|
||||
assert_eq!(&generate_short_name("Foo.b"), "FOO B ".as_bytes());
|
||||
assert_eq!(&generate_short_name("Foo.baR"), "FOO BAR".as_bytes());
|
||||
assert_eq!(&generate_short_name("Foo+1.baR"), "FOO?1 BAR".as_bytes());
|
||||
}
|
||||
}
|
||||
|
@ -707,3 +707,22 @@ impl <'a, 'b> fmt::Debug for DirEntry<'a, 'b> {
|
||||
self.data.fmt(f)
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
|
||||
#[test]
|
||||
fn short_name_with_ext() {
|
||||
let mut raw_short_name = [0u8;11];
|
||||
raw_short_name.copy_from_slice("FOO BAR".as_bytes());
|
||||
assert_eq!(ShortName::new(&raw_short_name).to_str(), "FOO.BAR");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn short_name_without_ext() {
|
||||
let mut raw_short_name = [0u8;11];
|
||||
raw_short_name.copy_from_slice("FOO ".as_bytes());
|
||||
assert_eq!(ShortName::new(&raw_short_name).to_str(), "FOO");
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user