crypto-morse

Crates.iocrypto-morse
lib.rscrypto-morse
version0.2.0
sourcesrc
created_at2020-03-25 04:11:16.346714
updated_at2020-09-21 08:17:52.418605
descriptionEncoding and decoding morse code for unicode
homepage
repositoryhttps://github.com/GalAster/crypto-moe
max_upload_size
id222548
size21,684
SasakiSaki (oovm)

documentation

README

Unicode Morse Encoding

extern crate crypto_morse;
use crypto_morse::{decode, encode, encode_raw};

#[test]
fn test_encoding() {
    assert_eq!(encode("SOS"), encode("sos"));
    assert_ne!(encode_raw("SOS"), encode("sos"));
}

#[test]
fn encode_word() {
    assert_eq!(encode("az"), "._ __..");
    assert_eq!(encode("AZ"), "._ __..");
    assert_eq!(encode_raw("AZ"), "_......_ _..__._.");
}

#[test]
fn encode_multiple_words() {
    assert_eq!(encode("中文"), "_..___..__.__._ __.._.___...___");
    assert_eq!(encode("abc xyz"), "._ _... _._. / _.._ _.__ __..");
    assert_eq!(encode_raw("A Z"), "_......_ / _..__._.");
}

#[test]
fn decode_word() {
    assert_eq!(decode("._ __.."), "az");
    assert_eq!(decode("_......_ _..__._."), "AZ");
}

#[test]
fn decode_multiple_words() {
    assert_eq!(decode("_..___..__.__._ __.._.___...___"), "中文");
    assert_eq!(decode("_......_ / _..__._."), "A Z");
}
Commit count: 25

cargo fmt