Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 27 additions & 2 deletions src/main/java/se/cygni/palmithor/tdd/StringUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,25 @@ public class StringUtils {


public boolean isPalindrome(final String str) {
throw new RuntimeException("Not yet implemented");

if(str == null) {
return false;
}


for(int leftIndex = 0; leftIndex != str.length() / 2; leftIndex++){

int rightIndex = str.length() - 1 - leftIndex;

if(str.charAt(leftIndex) != str.charAt(rightIndex)){
return false;
}

}

return true;

//throw new RuntimeException("Not yet implemented");
}


Expand All @@ -15,6 +33,13 @@ public boolean isPalindrome(final String str) {
* @return true if str is null, empty or whitespace only, otherwise false
*/
public boolean isBlank(final String str) {
throw new RuntimeException("Not yet implemented");

if(str == null){
return true;
}

return str.trim().isEmpty();


}
}
6 changes: 5 additions & 1 deletion src/test/java/se/cygni/palmithor/tdd/CalculatorTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,11 @@ public class CalculatorTest {

@Test
public void test() {
assertThat(calculator.sumAll().get()).isEqualTo(1); // TODO failing on purpose please fix
assertThat(calculator.sumAll().get()).isEqualTo(0);
assertThat(calculator.sumAll(1,2).get()).isEqualTo(3);
assertThat(calculator.sumAll(null).isEmpty()).isTrue();


}


Expand Down
5 changes: 4 additions & 1 deletion src/test/java/se/cygni/palmithor/tdd/StringUtilsTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,9 @@ public void isPalindrome() {
*/
@Test
public void isBlank() {
// stringUtils.isBlank()
assertThat(stringUtils.isBlank(null)).isTrue();
assertThat(stringUtils.isBlank("")).isTrue();
assertThat(stringUtils.isBlank(" ")).isTrue();
assertThat(stringUtils.isBlank(" asd")).isFalse();
}
}