Sha256: 891c035ced1c040358ec49bed647b2f9cf4e05165cecc52a4d51a65d48c76b0f

Contents?: true

Size: 1.75 KB

Versions: 9

Compression:

Stored size: 1.75 KB

Contents

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())
    );
}

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
trackler-2.2.1.180 tracks/rust/exercises/run-length-encoding/tests/run-length-encoding.rs
trackler-2.2.1.179 tracks/rust/exercises/run-length-encoding/tests/run-length-encoding.rs
trackler-2.2.1.178 tracks/rust/exercises/run-length-encoding/tests/run-length-encoding.rs
trackler-2.2.1.177 tracks/rust/exercises/run-length-encoding/tests/run-length-encoding.rs
trackler-2.2.1.176 tracks/rust/exercises/run-length-encoding/tests/run-length-encoding.rs
trackler-2.2.1.175 tracks/rust/exercises/run-length-encoding/tests/run-length-encoding.rs
trackler-2.2.1.174 tracks/rust/exercises/run-length-encoding/tests/run-length-encoding.rs
trackler-2.2.1.173 tracks/rust/exercises/run-length-encoding/tests/run-length-encoding.rs
trackler-2.2.1.172 tracks/rust/exercises/run-length-encoding/tests/run-length-encoding.rs