summaryrefslogtreecommitdiff
path: root/src/main.rs
blob: 07b1c893cf6d6243cd3d6dcf30361dcce833b520 (plain)
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
59
60
61
62
63
64
65
66
mod db;
mod flac;

fn main() {
    if let Err(err) = flac::encode_file(std::path::Path::new("16bit.flac")) {
        println!("{}", err)
    };
}

#[cfg(test)]
mod tests {
    use super::*;
    use metaflac::Tag;
    #[test]
    fn bit16() {
        flac::encode_file(std::path::Path::new("16bit.flac")).unwrap();
        let target_md5 = Tag::read_from_path("16bit.flac.tmp")
            .unwrap()
            .get_streaminfo()
            .unwrap()
            .md5
            .clone();
        let source_md5 = Tag::read_from_path("16bit.flac")
            .unwrap()
            .get_streaminfo()
            .unwrap()
            .md5
            .clone();
        assert_eq!(target_md5, source_md5);
    }
    #[test]
    fn bit24() {
        flac::encode_file(std::path::Path::new("24bit.flac")).unwrap();
        let target_md5 = Tag::read_from_path("24bit.flac.tmp")
            .unwrap()
            .get_streaminfo()
            .unwrap()
            .md5
            .clone();
        let source_md5 = Tag::read_from_path("24bit.flac")
            .unwrap()
            .get_streaminfo()
            .unwrap()
            .md5
            .clone();
        assert_eq!(target_md5, source_md5);
    }
    #[test]
    #[should_panic]
    fn bit32() {
        flac::encode_file(std::path::Path::new("32bit.flac")).unwrap();
        let target_md5 = Tag::read_from_path("32bit.flac.tmp")
            .unwrap()
            .get_streaminfo()
            .unwrap()
            .md5
            .clone();
        let source_md5 = Tag::read_from_path("32bit.flac")
            .unwrap()
            .get_streaminfo()
            .unwrap()
            .md5
            .clone();
        assert_eq!(target_md5, source_md5);
    }
}