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
pub mod utils;
pub mod fuzz;

#[cfg(test)]
mod tests {
    use fuzz;
    use utils;
    #[test]
    fn identity() {
        assert_eq!(fuzz::ratio("hello", "hello"), 100);
    }

    #[test]
    fn world() {
        assert_eq!(fuzz::ratio("hello test", "hello world"), 57);
        assert_eq!(fuzz::ratio("hello test", "hello worlasdfasd"), 52);
    }

    #[test]
    fn case_insensitive() {
        assert!(fuzz::ratio("hello WORLD", "hello world") != 100);
        assert_eq!(fuzz::ratio(&utils::full_process("hello WORLD", false),
                               &utils::full_process("hello world", false)),
                   100);
    }

    #[test]
    fn token_sort() {
        assert_eq!(fuzz::token_sort_ratio("hello world", "world hello", false, false),
                   100);
    }

    #[test]
    fn partial() {
        assert_eq!(fuzz::partial_ratio("hello", "hello world"), 100);
    }

    #[test]
    fn partial_token_sort() {
        assert_eq!(fuzz::partial_token_set_ratio("new york mets vs atlanta braves",
                                                 "atlanta braves vs new york mets",
                                                 false,
                                                 false),
                   100);
    }

    #[test]
    fn token_set() {
        assert_eq!(fuzz::token_set_ratio("new york mets vs atlanta braves",
                                         "atlanta braves vs new york mets",
                                         false,
                                         false),
                   100);
    }

    #[test]
    fn partial_token_set() {
        assert_eq!(fuzz::partial_token_set_ratio("new york mets vs atlanta braves",
                                                 "new york city mets - atlanta braves",
                                                 false,
                                                 false),
                   100);
    }
}