|
1 |
| -import org.junit.Test; |
| 1 | +import org.junit.jupiter.api.DisplayName; |
| 2 | +import org.junit.jupiter.api.Tag; |
| 3 | +import org.junit.jupiter.api.Test; |
2 | 4 |
|
3 | 5 | import static org.assertj.core.api.Assertions.assertThat;
|
4 | 6 |
|
5 | 7 | public class SqueakyCleanTest {
|
6 | 8 |
|
7 | 9 | @Test
|
| 10 | + @Tag("task:1") |
| 11 | + @DisplayName("The clean method returns empty string when invoked on empty string") |
8 | 12 | public void empty() {
|
9 | 13 | assertThat(SqueakyClean.clean("")).isEmpty();
|
10 | 14 | }
|
11 | 15 |
|
12 | 16 | @Test
|
| 17 | + @Tag("task:1") |
| 18 | + @DisplayName("The clean method returns the same string when invoked on a single letter string") |
13 | 19 | public void single_letter() {
|
14 | 20 | assertThat(SqueakyClean.clean("A")).isEqualTo("A");
|
15 | 21 | }
|
16 | 22 |
|
17 | 23 | @Test
|
| 24 | + @Tag("task:1") |
| 25 | + @DisplayName("The clean method returns the same string when invoked on a string of three letters") |
18 | 26 | public void string() {
|
19 | 27 | assertThat(SqueakyClean.clean("àḃç")).isEqualTo("àḃç");
|
20 | 28 | }
|
21 | 29 |
|
22 | 30 | @Test
|
| 31 | + @Tag("task:1") |
| 32 | + @DisplayName("The clean method replaces whitespaces with underscores in the middle of the string") |
23 | 33 | public void spaces() {
|
24 | 34 | assertThat(SqueakyClean.clean("my Id")).isEqualTo("my___Id");
|
25 | 35 | }
|
26 | 36 |
|
27 | 37 | @Test
|
| 38 | + @Tag("task:1") |
| 39 | + @DisplayName("The clean method replaces leading and trailing whitespaces with underscores") |
28 | 40 | public void leading_and_trailing_spaces() {
|
29 | 41 | assertThat(SqueakyClean.clean(" myId ")).isEqualTo("_myId_");
|
30 | 42 | }
|
31 | 43 |
|
32 | 44 | @Test
|
| 45 | + @Tag("task:2") |
| 46 | + @DisplayName("The clean method replaces control characters with CTRL") |
33 | 47 | public void ctrl() {
|
34 | 48 | assertThat(SqueakyClean.clean("my\0\r\u007FId")).isEqualTo("myCTRLCTRLCTRLId");
|
35 | 49 | }
|
36 | 50 |
|
37 | 51 | @Test
|
| 52 | + @Tag("task:4") |
| 53 | + @DisplayName("The clean method returns an empty string when invoked on a string with no letters") |
38 | 54 | public void string_with_no_letters() {
|
39 | 55 | assertThat(SqueakyClean.clean("\uD83D\uDE00\uD83D\uDE00\uD83D\uDE00")).isEmpty();
|
40 | 56 | }
|
41 | 57 |
|
42 | 58 | @Test
|
43 |
| - public void keep_only_letters() { |
44 |
| - assertThat(SqueakyClean.clean("a1\uD83D\uDE002\uD83D\uDE003\uD83D\uDE00b")).isEqualTo("ab"); |
45 |
| - } |
46 |
| - |
47 |
| - @Test |
| 59 | + @Tag("task:3") |
| 60 | + @DisplayName("The clean method converts kebab to camel case after removing a dash") |
48 | 61 | public void kebab_to_camel_case() {
|
49 | 62 | assertThat(SqueakyClean.clean("à-ḃç")).isEqualTo("àḂç");
|
50 | 63 | }
|
51 | 64 |
|
52 | 65 | @Test
|
| 66 | + @Tag("task:3") |
| 67 | + @DisplayName("The clean method returns a string in camel case after removing a dash and a number") |
53 | 68 | public void kebab_to_camel_case_no_letter() {
|
54 | 69 | assertThat(SqueakyClean.clean("a-1C")).isEqualTo("aC");
|
55 | 70 | }
|
56 | 71 |
|
57 | 72 | @Test
|
| 73 | + @Tag("task:4") |
| 74 | + @DisplayName("The clean method removes all characters that are not letters") |
| 75 | + public void keep_only_letters() { |
| 76 | + assertThat(SqueakyClean.clean("a1\uD83D\uDE002\uD83D\uDE003\uD83D\uDE00b")).isEqualTo("ab"); |
| 77 | + } |
| 78 | + |
| 79 | + @Test |
| 80 | + @Tag("task:5") |
| 81 | + @DisplayName("The clean method removes all lowercase greek letters") |
58 | 82 | public void omit_lower_case_greek_letters() {
|
59 | 83 | assertThat(SqueakyClean.clean("MyΟβιεγτFinder")).isEqualTo("MyΟFinder");
|
60 | 84 | }
|
61 | 85 |
|
62 | 86 | @Test
|
| 87 | + @Tag("task:5") |
| 88 | + @DisplayName("The clean method returns the correct result after performing a few cleaning operations") |
63 | 89 | public void combine_conversions() {
|
64 | 90 | assertThat(SqueakyClean.clean("9 -abcĐ\uD83D\uDE00ω\0")).isEqualTo("_AbcĐCTRL");
|
65 | 91 | }
|
|
0 commit comments