From 7c5541c2a91ee6afd5ec5def5425e1f6c58fcf0a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rafa=C5=82=20Harabie=C5=84?= Date: Wed, 30 May 2018 01:39:34 +0200 Subject: [PATCH] Add test for lowercase SFN (short LFN encoded in SFN) --- src/dir_entry.rs | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/src/dir_entry.rs b/src/dir_entry.rs index 4842878..c99aba1 100644 --- a/src/dir_entry.rs +++ b/src/dir_entry.rs @@ -725,4 +725,22 @@ mod tests { raw_short_name.copy_from_slice("FOO ".as_bytes()); assert_eq!(ShortName::new(&raw_short_name).to_str(), "FOO"); } + + #[test] + fn lowercase_short_name() { + let mut raw_short_name = [0u8;11]; + raw_short_name.copy_from_slice("FOO RS ".as_bytes()); + let mut raw_entry = DirFileEntryData { + name: raw_short_name, + reserved_0: (1 << 3) | (1 << 4), + ..Default::default() + }; + assert_eq!(raw_entry.lowercase_name(), "foo.rs"); + raw_entry.reserved_0 = 1 << 3; + assert_eq!(raw_entry.lowercase_name(), "foo.RS"); + raw_entry.reserved_0 = 1 << 4; + assert_eq!(raw_entry.lowercase_name(), "FOO.rs"); + raw_entry.reserved_0 = 0; + assert_eq!(raw_entry.lowercase_name(), "FOO.RS"); + } }