diff options
| author | Federico Igne <git@federicoigne.com> | 2020-12-28 11:00:15 +0000 |
|---|---|---|
| committer | Federico Igne <git@federicoigne.com> | 2021-11-03 18:55:08 +0000 |
| commit | f7620da880e3dade5fdce6fd0f51f290d4353654 (patch) | |
| tree | 2103819c757ad6f61d5e7a91362a89d424ca3740 /rust/acronym/tests | |
| parent | 11fd2671d7021f0672a89f9ea20ec42643e693bf (diff) | |
| download | exercism-f7620da880e3dade5fdce6fd0f51f290d4353654.tar.gz exercism-f7620da880e3dade5fdce6fd0f51f290d4353654.zip | |
[rust] Acronym
Diffstat (limited to 'rust/acronym/tests')
| -rw-r--r-- | rust/acronym/tests/acronym.rs | 73 |
1 files changed, 73 insertions, 0 deletions
diff --git a/rust/acronym/tests/acronym.rs b/rust/acronym/tests/acronym.rs new file mode 100644 index 0000000..079cf89 --- /dev/null +++ b/rust/acronym/tests/acronym.rs | |||
| @@ -0,0 +1,73 @@ | |||
| 1 | #[test] | ||
| 2 | fn empty() { | ||
| 3 | assert_eq!(acronym::abbreviate(""), ""); | ||
| 4 | } | ||
| 5 | |||
| 6 | #[test] | ||
| 7 | fn basic() { | ||
| 8 | assert_eq!(acronym::abbreviate("Portable Network Graphics"), "PNG"); | ||
| 9 | } | ||
| 10 | |||
| 11 | #[test] | ||
| 12 | fn lowercase_words() { | ||
| 13 | assert_eq!(acronym::abbreviate("Ruby on Rails"), "ROR"); | ||
| 14 | } | ||
| 15 | |||
| 16 | #[test] | ||
| 17 | fn camelcase() { | ||
| 18 | assert_eq!(acronym::abbreviate("HyperText Markup Language"), "HTML"); | ||
| 19 | } | ||
| 20 | |||
| 21 | #[test] | ||
| 22 | fn punctuation() { | ||
| 23 | assert_eq!(acronym::abbreviate("First In, First Out"), "FIFO"); | ||
| 24 | } | ||
| 25 | |||
| 26 | #[test] | ||
| 27 | fn all_caps_word() { | ||
| 28 | assert_eq!( | ||
| 29 | acronym::abbreviate("GNU Image Manipulation Program"), | ||
| 30 | "GIMP" | ||
| 31 | ); | ||
| 32 | } | ||
| 33 | |||
| 34 | #[test] | ||
| 35 | fn all_caps_word_with_punctuation() { | ||
| 36 | assert_eq!(acronym::abbreviate("PHP: Hypertext Preprocessor"), "PHP"); | ||
| 37 | } | ||
| 38 | |||
| 39 | #[test] | ||
| 40 | fn punctuation_without_whitespace() { | ||
| 41 | assert_eq!( | ||
| 42 | acronym::abbreviate("Complementary metal-oxide semiconductor"), | ||
| 43 | "CMOS" | ||
| 44 | ); | ||
| 45 | } | ||
| 46 | |||
| 47 | #[test] | ||
| 48 | fn very_long_abbreviation() { | ||
| 49 | assert_eq!( | ||
| 50 | acronym::abbreviate( | ||
| 51 | "Rolling On The Floor Laughing So Hard That My Dogs Came Over And Licked Me" | ||
| 52 | ), | ||
| 53 | "ROTFLSHTMDCOALM" | ||
| 54 | ); | ||
| 55 | } | ||
| 56 | |||
| 57 | #[test] | ||
| 58 | fn consecutive_delimiters() { | ||
| 59 | assert_eq!( | ||
| 60 | acronym::abbreviate("Something - I made up from thin air"), | ||
| 61 | "SIMUFTA" | ||
| 62 | ); | ||
| 63 | } | ||
| 64 | |||
| 65 | #[test] | ||
| 66 | fn apostrophes() { | ||
| 67 | assert_eq!(acronym::abbreviate("Halley's Comet"), "HC"); | ||
| 68 | } | ||
| 69 | |||
| 70 | #[test] | ||
| 71 | fn underscore_emphasis() { | ||
| 72 | assert_eq!(acronym::abbreviate("The Road _Not_ Taken"), "TRNT"); | ||
| 73 | } | ||
