1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package de.smartics.util.lang;
17
18 import static org.hamcrest.CoreMatchers.equalTo;
19 import static org.hamcrest.CoreMatchers.is;
20 import static org.hamcrest.CoreMatchers.nullValue;
21 import static org.hamcrest.MatcherAssert.assertThat;
22
23 import org.junit.Test;
24 import org.junit.experimental.categories.Category;
25
26 import de.smartics.testdoc.annotations.TestDocHint;
27 import de.smartics.testdoc.annotations.Uut;
28 import de.smartics.testdoc.categories.Technical;
29
30
31
32
33 @Uut(type = StringFunction.class, method = "toHyphenVersion(String)")
34 public class StringFunctionToHyphenVersionTest
35 {
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50 @Test
51 @TestDocHint(sentence = "toHyphenVersion: null -> null", indexSortKey = "001")
52 public void returnsNullIfNullIsPassedAsArgument()
53 {
54 final String result = StringFunction.toHyphenVersion(null);
55 assertThat(result, is(nullValue()));
56 }
57
58 @Test
59 @TestDocHint(sentence = "toHyphenVersion: \"\" -> \"\"", indexSortKey = "002")
60 public void returnsTheEmptyStringIfTheEmptyStringIsPassedAsArgument()
61 {
62 final String result = StringFunction.toHyphenVersion("");
63 assertThat(result, is(equalTo("")));
64 }
65
66 @Test
67 @TestDocHint(sentence = "toHyphenVersion: \"abc\" -> \"abc\"",
68 indexSortKey = "003")
69 public void hyphenVersionOfAllLowerCaseInputIsUnmodified()
70 {
71 final String result = StringFunction.toHyphenVersion("abc");
72 assertThat(result, is(equalTo("abc")));
73 }
74
75 @Test
76 @TestDocHint(sentence = "toHyphenVersion: \"Abc\" -> \"abc\"",
77 indexSortKey = "004")
78 public void hyphenVersionOfFistLetterCapitalIsTransformedToAllLowerCase()
79 {
80 final String result = StringFunction.toHyphenVersion("Abc");
81 assertThat(result, is(equalTo("abc")));
82 }
83
84 @Test
85 @TestDocHint(sentence = "toHyphenVersion: \"a\" -> \"a\"",
86 indexSortKey = "005")
87 @Category(Technical.class)
88 public void alsoWorksOnASingleLowerCaseLetter()
89 {
90 final String result = StringFunction.toHyphenVersion("a");
91 assertThat(result, is(equalTo("a")));
92 }
93
94 @Test
95 @TestDocHint(sentence = "toHyphenVersion: \"A\" -> \"a\"",
96 indexSortKey = "006")
97 @Category(Technical.class)
98 public void alsoWorksOnASingleCapitalLetter()
99 {
100 final String result = StringFunction.toHyphenVersion("A");
101 assertThat(result, is(equalTo("a")));
102 }
103
104 @Test
105 @TestDocHint(sentence = "toHyphenVersion: \"aBc\" -> \"a-bc\"",
106 indexSortKey = "010")
107 public void hyphensACapitalLetter()
108 {
109 final String result = StringFunction.toHyphenVersion("aBc");
110 assertThat(result, is(equalTo("a-bc")));
111 }
112
113 @Test
114 @TestDocHint(
115 sentence = "toHyphenVersion: \"thisIsACamleCaseExample\" -> \"this-is-a-camle-case-example\"",
116 indexSortKey = "011")
117 public void hyphensMultipleCapitalLetter()
118 {
119 final String result =
120 StringFunction.toHyphenVersion("thisIsACamleCaseExample");
121 assertThat(result, is(equalTo("this-is-a-camle-case-example")));
122 }
123
124
125 }