1
exercism fetch rust run-length-encoding

tests/run-length-encoding.rs

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
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
extern crate run_length_encoding as rle;

// encoding tests

#[test]
fn test_encode_empty_string() {
    assert_eq!("", rle::encode(""));
}

#[test]
#[ignore]
fn test_encode_single_characters() {
    assert_eq!("XYZ", rle::encode("XYZ"));
}

#[test]
#[ignore]
fn test_encode_string_with_no_single_characters() {
    assert_eq!("2A3B4C", rle::encode("AABBBCCCC"));
}

#[test]
#[ignore]
fn test_encode_single_characters_mixed_with_repeated_characters() {
    assert_eq!("12WB12W3B24WB", rle::encode(
        "WWWWWWWWWWWWBWWWWWWWWWWWWBBBWWWWWWWWWWWWWWWWWWWWWWWWB"));
}

#[test]
#[ignore]
fn test_encode_multiple_whitespace_mixed_in_string() {
    assert_eq!("2 hs2q q2w2 ", rle::encode("  hsqq qww  "));
}

#[test]
#[ignore]
fn test_encode_lowercase_characters() {
    assert_eq!("2a3b4c", rle::encode("aabbbcccc"));
}

// decoding tests

#[test]
#[ignore]
fn test_decode_empty_string() {
    assert_eq!("", rle::decode(""));
}

#[test]
#[ignore]
fn test_decode_single_characters_only() {
    assert_eq!("XYZ", rle::decode("XYZ"));
}

#[test]
#[ignore]
fn test_decode_string_with_no_single_characters() {
    assert_eq!("AABBBCCCC", rle::decode("2A3B4C"));
}

#[test]
#[ignore]
fn test_decode_single_characters_with_repeated_characters() {
    assert_eq!("WWWWWWWWWWWWBWWWWWWWWWWWWBBBWWWWWWWWWWWWWWWWWWWWWWWWB",
               rle::decode("12WB12W3B24WB"));
}

#[test]
#[ignore]
fn test_decode_multiple_whitespace_mixed_in_string() {
    assert_eq!("  hsqq qww  ", rle::decode("2 hs2q q2w2 "));
}

#[test]
#[ignore]
fn test_decode_lower_case_string() {
    assert_eq!("aabbbcccc", rle::decode("2a3b4c"));
}

// consistency test

#[test]
#[ignore]
fn test_consistency() {
    assert_eq!("zzz ZZ  zZ", rle::decode(rle::encode("zzz ZZ  zZ").as_str()));
}