aboutsummaryrefslogtreecommitdiff
path: root/rust/acronym/tests/acronym.rs
blob: 079cf89e8d75fb6f57a6054fd9e1c2a2ad26490e (plain) (blame)
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
#[test]
fn empty() {
    assert_eq!(acronym::abbreviate(""), "");
}

#[test]
fn basic() {
    assert_eq!(acronym::abbreviate("Portable Network Graphics"), "PNG");
}

#[test]
fn lowercase_words() {
    assert_eq!(acronym::abbreviate("Ruby on Rails"), "ROR");
}

#[test]
fn camelcase() {
    assert_eq!(acronym::abbreviate("HyperText Markup Language"), "HTML");
}

#[test]
fn punctuation() {
    assert_eq!(acronym::abbreviate("First In, First Out"), "FIFO");
}

#[test]
fn all_caps_word() {
    assert_eq!(
        acronym::abbreviate("GNU Image Manipulation Program"),
        "GIMP"
    );
}

#[test]
fn all_caps_word_with_punctuation() {
    assert_eq!(acronym::abbreviate("PHP: Hypertext Preprocessor"), "PHP");
}

#[test]
fn punctuation_without_whitespace() {
    assert_eq!(
        acronym::abbreviate("Complementary metal-oxide semiconductor"),
        "CMOS"
    );
}

#[test]
fn very_long_abbreviation() {
    assert_eq!(
        acronym::abbreviate(
            "Rolling On The Floor Laughing So Hard That My Dogs Came Over And Licked Me"
        ),
        "ROTFLSHTMDCOALM"
    );
}

#[test]
fn consecutive_delimiters() {
    assert_eq!(
        acronym::abbreviate("Something - I made up from thin air"),
        "SIMUFTA"
    );
}

#[test]
fn apostrophes() {
    assert_eq!(acronym::abbreviate("Halley's Comet"), "HC");
}

#[test]
fn underscore_emphasis() {
    assert_eq!(acronym::abbreviate("The Road _Not_ Taken"), "TRNT");
}