1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
//             DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
//                    Version 2, December 2004
//
// Copyright (C) 2018 Thomas Bailleux <thomas@bailleux.me>
//
// Everyone is permitted to copy and distribute verbatim or modified
// copies of this license document, and changing it is allowed as long
// as the name is changed.
//
//            DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
//   TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
//
//  0. You just DO WHAT THE FUCK YOU WANT TO.
//
// Author: zadig <thomas chr(0x40) bailleux.me>

extern crate memmap;
pub(crate) mod util;
pub(crate) mod constants;
pub mod analyzer;
pub mod error;

pub(crate) use error::Result;
pub use error::Error;

#[cfg(test)]
mod tests {

  use super::*;

  fn prelude(path: &str) -> error::Result<analyzer::FAT> {
    analyzer::FAT::from_path(path)
  }

  #[test]
  fn new() {
    let fat = prelude("assets/example_fat.dd");
    assert_eq!(fat.is_ok(), true);
  }

  #[test]
  fn fat_detection() {
    let fat = prelude("assets/simple_fat16.dd").unwrap();
    assert_eq!(fat.ftype(), analyzer::FATType::FAT16);
  }

  #[test]
  fn fat32_detection() {
    let fat = prelude("assets/simple_fat32.dd").unwrap();
    assert_eq!(fat.ftype(), analyzer::FATType::FAT32);
  }

  #[test]
  fn fat12_detection() {
    let fat = prelude("assets/simple_fat12.dd").unwrap();
    assert_eq!(fat.ftype(), analyzer::FATType::FAT12);
  }
}