Skip to content

Commit

Permalink
Resolve Issue elissonmichael#33 | Adiciona Solução do Aluno Eduardo S…
Browse files Browse the repository at this point in the history
…antos (implementação + tests em java)
  • Loading branch information
e3duardo committed Nov 6, 2018
1 parent d014b97 commit 9aec538
Showing 1 changed file with 61 additions and 0 deletions.
61 changes: 61 additions & 0 deletions #33 extensao_para_string/2018-2/EduardoExtensaoStringTest.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
import java.util.stream.Collectors;
import java.util.stream.Stream;

import junit.framework.TestCase;

class ExtensaoString {
public static String titleize(String frase) {
return Stream.of(frase.split(" "))
.map(word -> String.valueOf(word.charAt(0)).toUpperCase() + word.substring(1).toLowerCase())
.collect(Collectors.joining(" "));
}

public static boolean isBlank(Object frase){
return String.valueOf(frase).matches("^\\s*$");
}
}

public class EduardoExtensaoStringTest extends TestCase {

public void test_titleize_escreve_com_maiuscula_cada_palavra_em_uma_string() {
assertEquals("Imagine All The People", ExtensaoString.titleize("imagine all the people"));
}

public void test_titleize_escreve_com_maiuscula_strings_de_uma_palavra() {
assertEquals("Eduardo", ExtensaoString.titleize("eduardo"));
}

public void test_titleize_escreve_com_maiuscula_uma_string_toda_em_maiusculo() {
assertEquals("Imagine All The People", ExtensaoString.titleize("IMAGINE ALL THE PEOPLE"));
}

public void test_titleize_escreve_com_maiuscula_uma_string_com_letras_misturadas() {
assertEquals("Imagine All The People", ExtensaoString.titleize("iMaGinE aLL tHe pEoPLe"));
}

public void test_blank_retorna_true_quando_a_string_e_vazia() {
assertEquals(true, ExtensaoString.isBlank(""));
}

public void test_blank_retorna_true_quando_a_string_contem_apenas_espacos() {
assertEquals(true, ExtensaoString.isBlank(" "));
}

public void test_blank_retorna_true_quando_a_string_contem_apenas_tabs() {
assertEquals(true, ExtensaoString.isBlank(" "));
// # exemplo: "\t\t\t"
}

public void test_blank_retorna_true_quando_a_string_contem_apenas_espacos_e_tabs() {
assertEquals(true, ExtensaoString.isBlank(" "));
}

public void test_blank_retorna_false_se_a_string_contem_uma_letra() {
assertEquals(false, ExtensaoString.isBlank("a"));
}

public void test_blank_retorna_false_se_a_string_contem_um_numero() {
assertEquals(false, ExtensaoString.isBlank(1));
}

}

0 comments on commit 9aec538

Please sign in to comment.